DocWrapper([width, initial_indent, ...]) | Wrap text in a document, processing each paragraph individually. |
trim(docstring) | Docstring trimmer from PEP0257 |
Inheritance diagram for mmf.utils.text:
Provides a subclass of textwrap.TextWrapper that allows for multiple paragraphs. Based on http://code.activestate.com/recipes/358228/
Bases: textwrap.TextWrapper
Wrap text in a document, processing each paragraph individually.
>>> DocWrapper(initial_indent=' ').fill("Hi")
' Hi'
>>> a = '''This is an example of how to use a
... long multiline string to document a
... parameter. This paragraph will be
... wrapped, but special formatting should
... be preserved if it is indented:
... 1) A series of points
... 2) Here is a longer point
...
... You can use paragraphs too! They will
... also be wrapped for you.'''
>>> print DocWrapper(width=66).fill(a)
This is an example of how to use a long multiline string to
document a parameter. This paragraph will be wrapped, but special
formatting should be preserved if it is indented:
1) A series of points
2) Here is a longer point
You can use paragraphs too! They will also be wrapped for you.
>>> b = ('''This is an example of a docstring which has some
... formatting:
... 1) Here is an indented point w/o wrapping.
... 2) Another indented point. This one is a''' +
... ''' very long line. This should *not* be wrapped.
... ''')
>>> print DocWrapper(width=66).fill(b)
This is an example of a docstring which has some formatting:
1) Here is an indented point w/o wrapping.
2) Another indented point. This one is a very long line. This should *not* be wrapped.
Methods
fill((text : string) -> string) | Reformat the single paragraph in ‘text’ to fit in lines of no |
wrap(text) | Override textwrap.TextWrapper to process ‘text’ properly when |