29 - def __init__(self, text, **options):
30 self._verbatim = options.get('verbatim', 1)
31 if text is None: raise ValueError, 'Bad text value (expected a str)'
32 self._text = text
33
34 - def to_html(self, docstring_linker, **options):
35 if options.get('verbatim', self._verbatim) == 0:
36 return plaintext_to_html(self.to_plaintext(docstring_linker))
37 else:
38 return ParsedDocstring.to_html(self, docstring_linker, **options)
39
40 - def to_latex(self, docstring_linker, **options):
41 if options.get('verbatim', self._verbatim) == 0:
42 return plaintext_to_latex(self.to_plaintext(docstring_linker))
43 else:
44 return ParsedDocstring.to_latex(self, docstring_linker, **options)
45
46 - def to_plaintext(self, docstring_linker, **options):
47 if 'indent' in options:
48 indent = options['indent']
49 lines = self._text.split('\n')
50 return '\n'.join([' '*indent+l for l in lines])+'\n'
51 return self._text+'\n'
52
54 m = re.match(r'(\s*[\w\W]*?\.)(\s|$)', self._text)
55 if m:
56 return ParsedPlaintextDocstring(m.group(1), verbatim=0)
57 else:
58 summary = self._text.split('\n', 1)[0]+'...'
59 return ParsedPlaintextDocstring(summary, verbatim=0)