Commit 285f4a7d authored by Greg Ward's avatar Greg Ward

Don't list all the keyword args to the TextWrapper constructor in the

classdesc -- just use "..." with prose explaining the correspondence
between keyword args and instance attributes.

Document 'width' along with the other instance attributes.

Describe default values consistently.

Typo fixes.
parent cadb9eb8
...@@ -42,11 +42,10 @@ instance is not reused, so for applications that wrap/fill many text ...@@ -42,11 +42,10 @@ instance is not reused, so for applications that wrap/fill many text
strings, it will be more efficient for you to create your own strings, it will be more efficient for you to create your own
\class{TextWrapper} object. \class{TextWrapper} object.
\begin{classdesc}{TextWrapper}{width, initial_indent, subsequent_indent, \begin{classdesc}{TextWrapper}{...}
expand_tabs, replace_whitespace, The \class{TextWrapper} constructor accepts a number of optional
fix_sentence_endings, break_long_words} keyword arguments. Each argument corresponds to one instance attribute,
Each keyword argument to the constructor corresponds to an instance so for example
attribute, so for example
\begin{verbatim} \begin{verbatim}
wrapper = TextWrapper(initial_indent="* ") wrapper = TextWrapper(initial_indent="* ")
\end{verbatim} \end{verbatim}
...@@ -61,17 +60,24 @@ can change any of its options through direct assignment to instance ...@@ -61,17 +60,24 @@ can change any of its options through direct assignment to instance
attributes between uses. attributes between uses.
\end{classdesc} \end{classdesc}
The \class{TextWrapper} instance attributes (and keyword arguments to
the constructor) are as follows:
The effects of the instance attributes are as follows: \begin{memberdesc}{width}
(default: 70) The maximum length of wrapped lines. As long as there are
no individual words in the input text longer than \var{width},
\class{TextWrapper} guarantees that no output line will be longer than
\var{width} characters.
\end{memberdesc}
\begin{memberdesc}{expand_tabs} \begin{memberdesc}{expand_tabs}
If true (the default), then all tab characters in \var{text} will be (default: \code{True}) If true, then all tab characters in \var{text}
expanded to spaces using the \method{expand_tabs()} method of will be expanded to spaces using the \method{expand_tabs()} method of
\var{text}. \var{text}.
\end{memberdesc} \end{memberdesc}
\begin{memberdesc}{replace_whitespace} \begin{memberdesc}{replace_whitespace}
If true (the default), each whitespace character (as defined by (default: \code{True}) If true, each whitespace character (as defined by
\var{string.whitespace}) remaining after tab expansion will be replaced \var{string.whitespace}) remaining after tab expansion will be replaced
by a single space. \note{If \var{expand_tabs} is false and by a single space. \note{If \var{expand_tabs} is false and
\var{replace_whitespace} is true, each tab character will be replaced by \var{replace_whitespace} is true, each tab character will be replaced by
...@@ -97,14 +103,15 @@ font. However, the sentence detection algorithm is imperfect: it ...@@ -97,14 +103,15 @@ font. However, the sentence detection algorithm is imperfect: it
assumes that a sentence ending consists of a lowercase letter followed assumes that a sentence ending consists of a lowercase letter followed
by one of \character{.}, by one of \character{.},
\character{!}, or \character{?}, possibly followed by one of \character{!}, or \character{?}, possibly followed by one of
\character{"} or \character{'}. One problem with this is algoritm is \character{"} or \character{'}, followed by a space. One problem
that it is unable to detect the difference between ``Dr.'' in with this is algorithm is that it is unable to detect the difference
between ``Dr.'' in
\begin{verbatim} \begin{verbatim}
[...] Dr. Frankenstein's monster [...] [...] Dr. Frankenstein's monster [...]
\end{verbatim} \end{verbatim}
and ``Spot.'' in and ``Spot.'' in
\begin{verbatim} \begin{verbatim}
[...] See Spot. See Spot run [...] [...] See Spot. See Spot run [...]
\end{verbatim} \end{verbatim}
Furthermore, since it relies on \var{string.lowercase} for the Furthermore, since it relies on \var{string.lowercase} for the
definition of ``lowercase letter'', it is specific to English-language definition of ``lowercase letter'', it is specific to English-language
...@@ -112,9 +119,10 @@ texts. Thus, \var{fix_sentence_endings} is false by default. ...@@ -112,9 +119,10 @@ texts. Thus, \var{fix_sentence_endings} is false by default.
\end{memberdesc} \end{memberdesc}
\begin{memberdesc}{break_long_words} \begin{memberdesc}{break_long_words}
If true (the default), then words longer than \var{width} will be broken (default: \code{True}) If true, then words longer than
in order to ensure that no lines are longer than \var{width}. If it is \var{width} will be broken in order to ensure that no lines are longer
false, long words will not be broken, and some lines may be longer than than \var{width}. If it is false, long words will not be broken, and
some lines may be longer than
\var{width}. (Long words will be put on a line by themselves, in order \var{width}. (Long words will be put on a line by themselves, in order
to minimize the amount by which \var{width} is exceeded.) to minimize the amount by which \var{width} is exceeded.)
\end{memberdesc} \end{memberdesc}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment