def run(self):
<EOL>if self.err is not None:<EOL><INDENT>assert self.source is None<EOL>msg = "<STR_LIT>" % (<EOL>rst_prefix,<EOL>rst_fail_load,<EOL>"<STR_LIT>" % self.err,<EOL>)<EOL>yield <NUM_LIT:0>, <NUM_LIT:0>, msg, type(self)<EOL>module = []<EOL><DEDENT>try:<EOL><INDENT>module = parse(StringIO(self.source), self.filename)<EOL><DEDENT>except SyntaxError as err:<EOL><INDENT>msg = "<STR_LIT>" % (<EOL>rst_prefix,<EOL>rst_fail_parse,<EOL>"<STR_LIT>" % err,<EOL>)<EOL>yield <NUM_LIT:0>, <NUM_LIT:0>, msg, type(self)<EOL>module = []<EOL><DEDENT>except AllError:<EOL><INDENT>msg = "<STR_LIT>" % (<EOL>rst_prefix,<EOL>rst_fail_all,<EOL>"<STR_LIT>",<EOL>)<EOL>yield <NUM_LIT:0>, <NUM_LIT:0>, msg, type(self)<EOL>module = []<EOL><DEDENT>for definition in module:<EOL><INDENT>if not definition.docstring:<EOL><INDENT>continue<EOL><DEDENT>try:<EOL><INDENT>unindented = trim(dequote_docstring(definition.docstring))<EOL>rst_errors = list(rst_lint.lint(unindented))<EOL><DEDENT>except Exception as err:<EOL><INDENT>msg = "<STR_LIT>" % (<EOL>rst_prefix,<EOL>rst_fail_lint,<EOL>"<STR_LIT>" % (definition.name, err),<EOL>)<EOL>yield definition.start, <NUM_LIT:0>, msg, type(self)<EOL>continue<EOL><DEDENT>for rst_error in rst_errors:<EOL><INDENT>if rst_error.level <= <NUM_LIT:1>:<EOL><INDENT>continue<EOL><DEDENT>msg = rst_error.message.split("<STR_LIT:\n>", <NUM_LIT:1>)[<NUM_LIT:0>]<EOL>code = code_mapping(rst_error.level, msg)<EOL>assert code < <NUM_LIT:100>, code<EOL>code += <NUM_LIT:100> * rst_error.level<EOL>msg = "<STR_LIT>" % (rst_prefix, code, msg)<EOL>yield definition.start + rst_error.line, <NUM_LIT:0>, msg, type(self)<EOL><DEDENT><DEDENT>
Use docutils to check docstrings are valid RST.