def comment_to_ast(self, comment, link_resolver):
assert comment is not None<EOL>text = comment.description<EOL>if (self.remove_xml_tags or comment.filename in<EOL>self.gdbus_codegen_sources):<EOL><INDENT>text = re.sub('<STR_LIT>', '<STR_LIT>', text)<EOL><DEDENT>if self.escape_html:<EOL><INDENT>text = cgi.escape(text)<EOL><DEDENT>ast, diagnostics = cmark.gtkdoc_to_ast(text, link_resolver)<EOL>for diag in diagnostics:<EOL><INDENT>if (comment.filename and comment.filename not in<EOL>self.gdbus_codegen_sources):<EOL><INDENT>column = diag.column + comment.col_offset<EOL>if diag.lineno == <NUM_LIT:0>:<EOL><INDENT>column += comment.initial_col_offset<EOL><DEDENT>lines = text.split('<STR_LIT:\n>')<EOL>line = lines[diag.lineno]<EOL>i = <NUM_LIT:0><EOL>while line[i] == '<STR_LIT:U+0020>':<EOL><INDENT>i += <NUM_LIT:1><EOL><DEDENT>column += i - <NUM_LIT:1><EOL>if diag.lineno > <NUM_LIT:0> and any([c != '<STR_LIT:U+0020>' for c in<EOL>lines[diag.lineno - <NUM_LIT:1>]]):<EOL><INDENT>column += <NUM_LIT:1><EOL><DEDENT>lineno = -<NUM_LIT:1><EOL>if comment.lineno != -<NUM_LIT:1>:<EOL><INDENT>lineno = (comment.lineno - <NUM_LIT:1> + comment.line_offset +<EOL>diag.lineno)<EOL><DEDENT>warn(<EOL>diag.code,<EOL>message=diag.message,<EOL>filename=comment.filename,<EOL>lineno=lineno,<EOL>column=column)<EOL><DEDENT><DEDENT>return ast<EOL>
Given a gtk-doc comment string, returns an opaque PyCapsule
containing the document root.

This is an optimization allowing to parse the docstring only
once, and to render it multiple times with
`ast_to_html`, links discovery and
most of the link resolution being lazily done in that second phase.

If you don't care about performance, you should simply
use `translate`.

Args:
    text: unicode, the docstring to parse.
    link_resolver: hotdoc.core.links.LinkResolver, an object
        which will be called to retrieve `hotdoc.core.links.Link`
        objects.

Returns:
    capsule: A PyCapsule wrapping an opaque C pointer, which
        can be passed to `ast_to_html`
        afterwards.
    diagnostics: A list of diagnostics as output by the gtk-doc cmark
        extension