3 import epydoc.markup.epytext
4 from epydoc.markup import DocstringLinker
5 from epydoc.markup.epytext import parse_docstring, ParseError, _colorize
6 from rest_formatter import read_safe, print_safe
9 def _add_para(doc, para_token, stack, indent_stack, errors):
10 """Colorize the given paragraph, and add it to the DOM tree."""
11 para = _colorize(doc, para_token, errors)
13 para.attribs['inline'] = True
14 stack[-1].children.append(para)
17 epydoc.markup.epytext._add_para = _add_para
18 ParseError.is_fatal = lambda self: False
24 class EmptyLinker(DocstringLinker):
25 def translate_indexterm(self, indexterm):
28 def translate_identifier_xref(self, identifier, label=None):
32 docstring = parse_docstring(src, errors)
33 docstring, fields = docstring.split_fields()
34 html = docstring.to_html(EmptyLinker())
36 if errors and not html:
37 print_safe(u'Error parsing docstring:\n', error=True)
39 # This script is run only with Python 2 interpreter
40 print_safe(unicode(error) + "\n", error=True)