summaryrefslogtreecommitdiffstats
path: root/Doc/library/textwrap.rst
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-04-25 01:59:09 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-04-25 01:59:09 (GMT)
commite41251e864e94885d785b5a9bf8f824753316296 (patch)
treef530db7682d71f4920b22b8d7f84c89727647ab5 /Doc/library/textwrap.rst
parent768db92b438038586c1580b711c528363a97d3f4 (diff)
downloadcpython-e41251e864e94885d785b5a9bf8f824753316296.zip
cpython-e41251e864e94885d785b5a9bf8f824753316296.tar.gz
cpython-e41251e864e94885d785b5a9bf8f824753316296.tar.bz2
Merged revisions 62490 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r62490 | benjamin.peterson | 2008-04-24 20:29:10 -0500 (Thu, 24 Apr 2008) | 2 lines reformat some documentation of classes so methods and attributes are under the class directive ........
Diffstat (limited to 'Doc/library/textwrap.rst')
-rw-r--r--Doc/library/textwrap.rst123
1 files changed, 62 insertions, 61 deletions
diff --git a/Doc/library/textwrap.rst b/Doc/library/textwrap.rst
index 350354c..9b2ad11 100644
--- a/Doc/library/textwrap.rst
+++ b/Doc/library/textwrap.rst
@@ -85,103 +85,104 @@ indentation from strings that have unwanted whitespace to the left of the text.
change any of its options through direct assignment to instance attributes
between uses.
-The :class:`TextWrapper` instance attributes (and keyword arguments to the
-constructor) are as follows:
+ The :class:`TextWrapper` instance attributes (and keyword arguments to the
+ constructor) are as follows:
-.. attribute:: TextWrapper.width
+ .. attribute:: width
- (default: ``70``) The maximum length of wrapped lines. As long as there are no
- individual words in the input text longer than :attr:`width`,
- :class:`TextWrapper` guarantees that no output line will be longer than
- :attr:`width` characters.
+ (default: ``70``) The maximum length of wrapped lines. As long as there
+ are no individual words in the input text longer than :attr:`width`,
+ :class:`TextWrapper` guarantees that no output line will be longer than
+ :attr:`width` characters.
-.. attribute:: TextWrapper.expand_tabs
+ .. attribute:: expand_tabs
- (default: ``True``) If true, then all tab characters in *text* will be expanded
- to spaces using the :meth:`expandtabs` method of *text*.
+ (default: ``True``) If true, then all tab characters in *text* will be
+ expanded to spaces using the :meth:`expandtabs` method of *text*.
-.. attribute:: TextWrapper.replace_whitespace
+ .. attribute:: replace_whitespace
- (default: ``True``) If true, each whitespace character (as defined by
- ``string.whitespace``) remaining after tab expansion will be replaced by a
- single space.
+ (default: ``True``) If true, each whitespace character (as defined by
+ ``string.whitespace``) remaining after tab expansion will be replaced by a
+ single space.
- .. note::
+ .. note::
- If :attr:`expand_tabs` is false and :attr:`replace_whitespace` is true, each tab
- character will be replaced by a single space, which is *not* the same as tab
- expansion.
+ If :attr:`expand_tabs` is false and :attr:`replace_whitespace` is true,
+ each tab character will be replaced by a single space, which is *not*
+ the same as tab expansion.
-.. attribute:: TextWrapper.drop_whitespace
+ .. attribute:: drop_whitespace
- (default: ``True``) If true, whitespace that, after wrapping, happens to end up
- at the beginning or end of a line is dropped (leading whitespace in the first
- line is always preserved, though).
+ (default: ``True``) If true, whitespace that, after wrapping, happens to
+ end up at the beginning or end of a line is dropped (leading whitespace in
+ the first line is always preserved, though).
-.. attribute:: TextWrapper.initial_indent
+ .. attribute:: initial_indent
- (default: ``''``) String that will be prepended to the first line of wrapped
- output. Counts towards the length of the first line.
+ (default: ``''``) String that will be prepended to the first line of
+ wrapped output. Counts towards the length of the first line.
-.. attribute:: TextWrapper.subsequent_indent
+ .. attribute:: subsequent_indent
- (default: ``''``) String that will be prepended to all lines of wrapped output
- except the first. Counts towards the length of each line except the first.
+ (default: ``''``) String that will be prepended to all lines of wrapped
+ output except the first. Counts towards the length of each line except
+ the first.
-.. attribute:: TextWrapper.fix_sentence_endings
+ .. attribute:: fix_sentence_endings
- (default: ``False``) If true, :class:`TextWrapper` attempts to detect sentence
- endings and ensure that sentences are always separated by exactly two spaces.
- This is generally desired for text in a monospaced font. However, the sentence
- detection algorithm is imperfect: it assumes that a sentence ending consists of
- a lowercase letter followed by one of ``'.'``, ``'!'``, or ``'?'``, possibly
- followed by one of ``'"'`` or ``"'"``, followed by a space. One problem with
- this is algorithm is that it is unable to detect the difference between "Dr." in
- ::
+ (default: ``False``) If true, :class:`TextWrapper` attempts to detect
+ sentence endings and ensure that sentences are always separated by exactly
+ two spaces. This is generally desired for text in a monospaced font.
+ However, the sentence detection algorithm is imperfect: it assumes that a
+ sentence ending consists of a lowercase letter followed by one of ``'.'``,
+ ``'!'``, or ``'?'``, possibly followed by one of ``'"'`` or ``"'"``,
+ followed by a space. One problem with this is algorithm is that it is
+ unable to detect the difference between "Dr." in ::
- [...] Dr. Frankenstein's monster [...]
+ [...] Dr. Frankenstein's monster [...]
- and "Spot." in ::
+ and "Spot." in ::
- [...] See Spot. See Spot run [...]
+ [...] See Spot. See Spot run [...]
- :attr:`fix_sentence_endings` is false by default.
+ :attr:`fix_sentence_endings` is false by default.
- Since the sentence detection algorithm relies on ``string.lowercase`` for the
- definition of "lowercase letter," and a convention of using two spaces after
- a period to separate sentences on the same line, it is specific to
- English-language texts.
+ Since the sentence detection algorithm relies on ``string.lowercase`` for
+ the definition of "lowercase letter," and a convention of using two spaces
+ after a period to separate sentences on the same line, it is specific to
+ English-language texts.
-.. attribute:: TextWrapper.break_long_words
+ .. attribute:: break_long_words
- (default: ``True``) If true, then words longer than :attr:`width` will be broken
- in order to ensure that no lines are longer than :attr:`width`. If it is false,
- long words will not be broken, and some lines may be longer than :attr:`width`.
- (Long words will be put on a line by themselves, in order to minimize the amount
- by which :attr:`width` is exceeded.)
+ (default: ``True``) If true, then words longer than :attr:`width` will be
+ broken in order to ensure that no lines are longer than :attr:`width`. If
+ it is false, long words will not be broken, and some lines may be longer
+ than :attr:`width`. (Long words will be put on a line by themselves, in
+ order to minimize the amount by which :attr:`width` is exceeded.)
-:class:`TextWrapper` also provides two public methods, analogous to the
-module-level convenience functions:
+ :class:`TextWrapper` also provides two public methods, analogous to the
+ module-level convenience functions:
-.. method:: TextWrapper.wrap(text)
+ .. method:: wrap(text)
- Wraps the single paragraph in *text* (a string) so every line is at most
- :attr:`width` characters long. All wrapping options are taken from instance
- attributes of the :class:`TextWrapper` instance. Returns a list of output lines,
- without final newlines.
+ Wraps the single paragraph in *text* (a string) so every line is at most
+ :attr:`width` characters long. All wrapping options are taken from
+ instance attributes of the :class:`TextWrapper` instance. Returns a list
+ of output lines, without final newlines.
-.. method:: TextWrapper.fill(text)
+ .. method:: fill(text)
- Wraps the single paragraph in *text*, and returns a single string containing the
- wrapped paragraph.
+ Wraps the single paragraph in *text*, and returns a single string
+ containing the wrapped paragraph.