blob: d7c5a6b83bf3750cabaa3a09b044f7e797fa57c3 [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{formatter} ---
Fred Drakeda573651999-02-19 23:48:05 +00002 Generic output formatting}
Fred Drakeb91e9341998-07-23 17:59:49 +00003
Fred Drakeda573651999-02-19 23:48:05 +00004\declaremodule{standard}{formatter}
Fred Drakeb91e9341998-07-23 17:59:49 +00005\modulesynopsis{Generic output formatter and device interface.}
6
Fred Drakee83b30d1996-10-08 21:53:33 +00007
Fred Drakee83b30d1996-10-08 21:53:33 +00008
Thomas Woutersf8316632000-07-16 19:01:10 +00009This module supports two interface definitions, each with multiple
Fred Drakee83b30d1996-10-08 21:53:33 +000010implementations. The \emph{formatter} interface is used by the
Fred Drakeffbe6871999-04-22 21:23:22 +000011\class{HTMLParser} class of the \refmodule{htmllib} module, and the
Fred Drakee83b30d1996-10-08 21:53:33 +000012\emph{writer} interface is required by the formatter interface.
Fred Drake858f7871998-04-04 06:25:27 +000013\withsubitem{(class in htmllib)}{\ttindex{HTMLParser}}
Fred Drakee83b30d1996-10-08 21:53:33 +000014
15Formatter objects transform an abstract flow of formatting events into
16specific output events on writer objects. Formatters manage several
17stack structures to allow various properties of a writer object to be
18changed and restored; writers need not be able to handle relative
19changes nor any sort of ``change back'' operation. Specific writer
20properties which may be controlled via formatter objects are
21horizontal alignment, font, and left margin indentations. A mechanism
22is provided which supports providing arbitrary, non-exclusive style
23settings to a writer as well. Additional interfaces facilitate
24formatting events which are not reversible, such as paragraph
25separation.
26
27Writer objects encapsulate device interfaces. Abstract devices, such
28as file formats, are supported as well as physical devices. The
29provided implementations all work with abstract devices. The
30interface makes available mechanisms for setting the properties which
31formatter objects manage and inserting data into the output.
32
33
Fred Drakeda573651999-02-19 23:48:05 +000034\subsection{The Formatter Interface \label{formatter-interface}}
Fred Drakee83b30d1996-10-08 21:53:33 +000035
36Interfaces to create formatters are dependent on the specific
37formatter class being instantiated. The interfaces described below
38are the required interfaces which all formatters must support once
39initialized.
40
41One data element is defined at the module level:
42
Fred Drake8fe533e1998-03-27 05:27:08 +000043
Fred Drakee83b30d1996-10-08 21:53:33 +000044\begin{datadesc}{AS_IS}
45Value which can be used in the font specification passed to the
46\code{push_font()} method described below, or as the new value to any
47other \code{push_\var{property}()} method. Pushing the \code{AS_IS}
48value allows the corresponding \code{pop_\var{property}()} method to
49be called without having to track whether the property was changed.
50\end{datadesc}
51
52The following attributes are defined for formatter instance objects:
53
Fred Drake8f925951996-10-09 16:13:22 +000054
Fred Drake8fe533e1998-03-27 05:27:08 +000055\begin{memberdesc}[formatter]{writer}
Fred Drakee83b30d1996-10-08 21:53:33 +000056The writer instance with which the formatter interacts.
Fred Drake8fe533e1998-03-27 05:27:08 +000057\end{memberdesc}
Fred Drakee83b30d1996-10-08 21:53:33 +000058
59
Fred Drake8fe533e1998-03-27 05:27:08 +000060\begin{methoddesc}[formatter]{end_paragraph}{blanklines}
Fred Drake3b5da761998-03-12 15:33:05 +000061Close any open paragraphs and insert at least \var{blanklines}
Fred Drakee83b30d1996-10-08 21:53:33 +000062before the next paragraph.
Fred Drake8fe533e1998-03-27 05:27:08 +000063\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +000064
Fred Drake8fe533e1998-03-27 05:27:08 +000065\begin{methoddesc}[formatter]{add_line_break}{}
Fred Drakee83b30d1996-10-08 21:53:33 +000066Add a hard line break if one does not already exist. This does not
67break the logical paragraph.
Fred Drake8fe533e1998-03-27 05:27:08 +000068\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +000069
Fred Drake8fe533e1998-03-27 05:27:08 +000070\begin{methoddesc}[formatter]{add_hor_rule}{*args, **kw}
Fred Drakee83b30d1996-10-08 21:53:33 +000071Insert a horizontal rule in the output. A hard break is inserted if
72there is data in the current paragraph, but the logical paragraph is
73not broken. The arguments and keywords are passed on to the writer's
Fred Drake3b5da761998-03-12 15:33:05 +000074\method{send_line_break()} method.
Fred Drake8fe533e1998-03-27 05:27:08 +000075\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +000076
Fred Drake8fe533e1998-03-27 05:27:08 +000077\begin{methoddesc}[formatter]{add_flowing_data}{data}
Thomas Woutersf8316632000-07-16 19:01:10 +000078Provide data which should be formatted with collapsed whitespace.
79Whitespace from preceding and successive calls to
Fred Drake3b5da761998-03-12 15:33:05 +000080\method{add_flowing_data()} is considered as well when the whitespace
Fred Drakee83b30d1996-10-08 21:53:33 +000081collapse is performed. The data which is passed to this method is
82expected to be word-wrapped by the output device. Note that any
83word-wrapping still must be performed by the writer object due to the
84need to rely on device and font information.
Fred Drake8fe533e1998-03-27 05:27:08 +000085\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +000086
Fred Drake8fe533e1998-03-27 05:27:08 +000087\begin{methoddesc}[formatter]{add_literal_data}{data}
Fred Drakee83b30d1996-10-08 21:53:33 +000088Provide data which should be passed to the writer unchanged.
89Whitespace, including newline and tab characters, are considered legal
Fred Drake3b5da761998-03-12 15:33:05 +000090in the value of \var{data}.
Fred Drake8fe533e1998-03-27 05:27:08 +000091\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +000092
Fred Drake8fe533e1998-03-27 05:27:08 +000093\begin{methoddesc}[formatter]{add_label_data}{format, counter}
Fred Drakee83b30d1996-10-08 21:53:33 +000094Insert a label which should be placed to the left of the current left
95margin. This should be used for constructing bulleted or numbered
Fred Drake3b5da761998-03-12 15:33:05 +000096lists. If the \var{format} value is a string, it is interpreted as a
97format specification for \var{counter}, which should be an integer.
Fred Drakee83b30d1996-10-08 21:53:33 +000098The result of this formatting becomes the value of the label; if
Fred Drake3b5da761998-03-12 15:33:05 +000099\var{format} is not a string it is used as the label value directly.
Fred Drakee83b30d1996-10-08 21:53:33 +0000100The label value is passed as the only argument to the writer's
Fred Drake3b5da761998-03-12 15:33:05 +0000101\method{send_label_data()} method. Interpretation of non-string label
Fred Drakee83b30d1996-10-08 21:53:33 +0000102values is dependent on the associated writer.
103
104Format specifications are strings which, in combination with a counter
105value, are used to compute label values. Each character in the format
106string is copied to the label value, with some characters recognized
107to indicate a transform on the counter value. Specifically, the
Fred Drake3b5da761998-03-12 15:33:05 +0000108character \character{1} represents the counter value formatter as an
Thomas Woutersf8316632000-07-16 19:01:10 +0000109Arabic number, the characters \character{A} and \character{a}
Fred Drake3b5da761998-03-12 15:33:05 +0000110represent alphabetic representations of the counter value in upper and
111lower case, respectively, and \character{I} and \character{i}
112represent the counter value in Roman numerals, in upper and lower
113case. Note that the alphabetic and roman transforms require that the
114counter value be greater than zero.
Fred Drake8fe533e1998-03-27 05:27:08 +0000115\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000116
Fred Drake8fe533e1998-03-27 05:27:08 +0000117\begin{methoddesc}[formatter]{flush_softspace}{}
Fred Drakee83b30d1996-10-08 21:53:33 +0000118Send any pending whitespace buffered from a previous call to
Fred Drake3b5da761998-03-12 15:33:05 +0000119\method{add_flowing_data()} to the associated writer object. This
Fred Drakee83b30d1996-10-08 21:53:33 +0000120should be called before any direct manipulation of the writer object.
Fred Drake8fe533e1998-03-27 05:27:08 +0000121\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000122
Fred Drake8fe533e1998-03-27 05:27:08 +0000123\begin{methoddesc}[formatter]{push_alignment}{align}
Fred Drakee83b30d1996-10-08 21:53:33 +0000124Push a new alignment setting onto the alignment stack. This may be
Fred Drake3b5da761998-03-12 15:33:05 +0000125\constant{AS_IS} if no change is desired. If the alignment value is
126changed from the previous setting, the writer's \method{new_alignment()}
127method is called with the \var{align} value.
Fred Drake8fe533e1998-03-27 05:27:08 +0000128\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000129
Fred Drake8fe533e1998-03-27 05:27:08 +0000130\begin{methoddesc}[formatter]{pop_alignment}{}
Fred Drakee83b30d1996-10-08 21:53:33 +0000131Restore the previous alignment.
Fred Drake8fe533e1998-03-27 05:27:08 +0000132\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000133
Fred Drake8fe533e1998-03-27 05:27:08 +0000134\begin{methoddesc}[formatter]{push_font}{\code{(}size, italic, bold, teletype\code{)}}
Fred Drakee83b30d1996-10-08 21:53:33 +0000135Change some or all font properties of the writer object. Properties
Fred Drake3b5da761998-03-12 15:33:05 +0000136which are not set to \constant{AS_IS} are set to the values passed in
Fred Drakee83b30d1996-10-08 21:53:33 +0000137while others are maintained at their current settings. The writer's
Fred Drake3b5da761998-03-12 15:33:05 +0000138\method{new_font()} method is called with the fully resolved font
Fred Drakee83b30d1996-10-08 21:53:33 +0000139specification.
Fred Drake8fe533e1998-03-27 05:27:08 +0000140\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000141
Fred Drake8fe533e1998-03-27 05:27:08 +0000142\begin{methoddesc}[formatter]{pop_font}{}
Fred Drakee83b30d1996-10-08 21:53:33 +0000143Restore the previous font.
Fred Drake8fe533e1998-03-27 05:27:08 +0000144\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000145
Fred Drake8fe533e1998-03-27 05:27:08 +0000146\begin{methoddesc}[formatter]{push_margin}{margin}
Fred Drakee83b30d1996-10-08 21:53:33 +0000147Increase the number of left margin indentations by one, associating
Fred Drake3b5da761998-03-12 15:33:05 +0000148the logical tag \var{margin} with the new indentation. The initial
Fred Drakee83b30d1996-10-08 21:53:33 +0000149margin level is \code{0}. Changed values of the logical tag must be
Fred Drake3b5da761998-03-12 15:33:05 +0000150true values; false values other than \constant{AS_IS} are not
151sufficient to change the margin.
Fred Drake8fe533e1998-03-27 05:27:08 +0000152\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000153
Fred Drake8fe533e1998-03-27 05:27:08 +0000154\begin{methoddesc}[formatter]{pop_margin}{}
Fred Drakee83b30d1996-10-08 21:53:33 +0000155Restore the previous margin.
Fred Drake8fe533e1998-03-27 05:27:08 +0000156\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000157
Fred Drake8fe533e1998-03-27 05:27:08 +0000158\begin{methoddesc}[formatter]{push_style}{*styles}
Fred Drakee83b30d1996-10-08 21:53:33 +0000159Push any number of arbitrary style specifications. All styles are
160pushed onto the styles stack in order. A tuple representing the
Fred Drake3b5da761998-03-12 15:33:05 +0000161entire stack, including \constant{AS_IS} values, is passed to the
162writer's \method{new_styles()} method.
Fred Drake8fe533e1998-03-27 05:27:08 +0000163\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000164
Fred Drake8fe533e1998-03-27 05:27:08 +0000165\begin{methoddesc}[formatter]{pop_style}{\optional{n\code{ = 1}}}
Fred Drake3b5da761998-03-12 15:33:05 +0000166Pop the last \var{n} style specifications passed to
167\method{push_style()}. A tuple representing the revised stack,
168including \constant{AS_IS} values, is passed to the writer's
169\method{new_styles()} method.
Fred Drake8fe533e1998-03-27 05:27:08 +0000170\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000171
Fred Drake8fe533e1998-03-27 05:27:08 +0000172\begin{methoddesc}[formatter]{set_spacing}{spacing}
Fred Drakee83b30d1996-10-08 21:53:33 +0000173Set the spacing style for the writer.
Fred Drake8fe533e1998-03-27 05:27:08 +0000174\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000175
Fred Drake8fe533e1998-03-27 05:27:08 +0000176\begin{methoddesc}[formatter]{assert_line_data}{\optional{flag\code{ = 1}}}
Fred Drakee83b30d1996-10-08 21:53:33 +0000177Inform the formatter that data has been added to the current paragraph
178out-of-band. This should be used when the writer has been manipulated
Fred Drake3b5da761998-03-12 15:33:05 +0000179directly. The optional \var{flag} argument can be set to false if
Fred Drakee83b30d1996-10-08 21:53:33 +0000180the writer manipulations produced a hard line break at the end of the
181output.
Fred Drake8fe533e1998-03-27 05:27:08 +0000182\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000183
184
Fred Drakeda573651999-02-19 23:48:05 +0000185\subsection{Formatter Implementations \label{formatter-impls}}
Fred Drakee83b30d1996-10-08 21:53:33 +0000186
Fred Drake8f925951996-10-09 16:13:22 +0000187Two implementations of formatter objects are provided by this module.
188Most applications may use one of these classes without modification or
189subclassing.
190
Fred Drake3b5da761998-03-12 15:33:05 +0000191\begin{classdesc}{NullFormatter}{\optional{writer}}
192A formatter which does nothing. If \var{writer} is omitted, a
193\class{NullWriter} instance is created. No methods of the writer are
194called by \class{NullFormatter} instances. Implementations should
195inherit from this class if implementing a writer interface but don't
196need to inherit any implementation.
197\end{classdesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000198
Fred Drake3b5da761998-03-12 15:33:05 +0000199\begin{classdesc}{AbstractFormatter}{writer}
Fred Drakee83b30d1996-10-08 21:53:33 +0000200The standard formatter. This implementation has demonstrated wide
201applicability to many writers, and may be used directly in most
Fred Drake8f925951996-10-09 16:13:22 +0000202circumstances. It has been used to implement a full-featured
Fred Drake8ee679f2001-07-14 02:50:55 +0000203World Wide Web browser.
Fred Drake3b5da761998-03-12 15:33:05 +0000204\end{classdesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000205
206
207
Fred Drakeda573651999-02-19 23:48:05 +0000208\subsection{The Writer Interface \label{writer-interface}}
Fred Drakee83b30d1996-10-08 21:53:33 +0000209
210Interfaces to create writers are dependent on the specific writer
211class being instantiated. The interfaces described below are the
212required interfaces which all writers must support once initialized.
Fred Drake3b5da761998-03-12 15:33:05 +0000213Note that while most applications can use the
214\class{AbstractFormatter} class as a formatter, the writer must
215typically be provided by the application.
Fred Drakee83b30d1996-10-08 21:53:33 +0000216
Fred Drake8f925951996-10-09 16:13:22 +0000217
Fred Drake8fe533e1998-03-27 05:27:08 +0000218\begin{methoddesc}[writer]{flush}{}
Fred Drake591bbb11996-12-31 20:51:42 +0000219Flush any buffered output or device control events.
Fred Drake8fe533e1998-03-27 05:27:08 +0000220\end{methoddesc}
Fred Drake591bbb11996-12-31 20:51:42 +0000221
Fred Drake8fe533e1998-03-27 05:27:08 +0000222\begin{methoddesc}[writer]{new_alignment}{align}
Fred Drake3b5da761998-03-12 15:33:05 +0000223Set the alignment style. The \var{align} value can be any object,
Fred Drakee83b30d1996-10-08 21:53:33 +0000224but by convention is a string or \code{None}, where \code{None}
225indicates that the writer's ``preferred'' alignment should be used.
Fred Drake3b5da761998-03-12 15:33:05 +0000226Conventional \var{align} values are \code{'left'}, \code{'center'},
Fred Drakee83b30d1996-10-08 21:53:33 +0000227\code{'right'}, and \code{'justify'}.
Fred Drake8fe533e1998-03-27 05:27:08 +0000228\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000229
Fred Drake8fe533e1998-03-27 05:27:08 +0000230\begin{methoddesc}[writer]{new_font}{font}
Fred Drake3b5da761998-03-12 15:33:05 +0000231Set the font style. The value of \var{font} will be \code{None},
Fred Drakee83b30d1996-10-08 21:53:33 +0000232indicating that the device's default font should be used, or a tuple
Fred Drake3b5da761998-03-12 15:33:05 +0000233of the form \code{(}\var{size}, \var{italic}, \var{bold},
234\var{teletype}\code{)}. Size will be a string indicating the size of
235font that should be used; specific strings and their interpretation
236must be defined by the application. The \var{italic}, \var{bold}, and
Fred Drake6c81e2a2001-10-01 17:04:10 +0000237\var{teletype} values are Boolean values specifying which of those
Fred Drake3b5da761998-03-12 15:33:05 +0000238font attributes should be used.
Fred Drake8fe533e1998-03-27 05:27:08 +0000239\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000240
Fred Drake8fe533e1998-03-27 05:27:08 +0000241\begin{methoddesc}[writer]{new_margin}{margin, level}
Fred Drake3b5da761998-03-12 15:33:05 +0000242Set the margin level to the integer \var{level} and the logical tag
243to \var{margin}. Interpretation of the logical tag is at the
Fred Drakee83b30d1996-10-08 21:53:33 +0000244writer's discretion; the only restriction on the value of the logical
245tag is that it not be a false value for non-zero values of
Fred Drake3b5da761998-03-12 15:33:05 +0000246\var{level}.
Fred Drake8fe533e1998-03-27 05:27:08 +0000247\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000248
Fred Drake8fe533e1998-03-27 05:27:08 +0000249\begin{methoddesc}[writer]{new_spacing}{spacing}
Fred Drake3b5da761998-03-12 15:33:05 +0000250Set the spacing style to \var{spacing}.
Fred Drake8fe533e1998-03-27 05:27:08 +0000251\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000252
Fred Drake8fe533e1998-03-27 05:27:08 +0000253\begin{methoddesc}[writer]{new_styles}{styles}
Fred Drake3b5da761998-03-12 15:33:05 +0000254Set additional styles. The \var{styles} value is a tuple of
255arbitrary values; the value \constant{AS_IS} should be ignored. The
256\var{styles} tuple may be interpreted either as a set or as a stack
Fred Drakee83b30d1996-10-08 21:53:33 +0000257depending on the requirements of the application and writer
258implementation.
Fred Drake8fe533e1998-03-27 05:27:08 +0000259\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000260
Fred Drake8fe533e1998-03-27 05:27:08 +0000261\begin{methoddesc}[writer]{send_line_break}{}
Fred Drakee83b30d1996-10-08 21:53:33 +0000262Break the current line.
Fred Drake8fe533e1998-03-27 05:27:08 +0000263\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000264
Fred Drake8fe533e1998-03-27 05:27:08 +0000265\begin{methoddesc}[writer]{send_paragraph}{blankline}
Fred Drake3b5da761998-03-12 15:33:05 +0000266Produce a paragraph separation of at least \var{blankline} blank
Thomas Woutersf8316632000-07-16 19:01:10 +0000267lines, or the equivalent. The \var{blankline} value will be an
Fred Drake03dd3ef1999-01-12 18:33:47 +0000268integer. Note that the implementation will receive a call to
269\method{send_line_break()} before this call if a line break is needed;
270this method should not include ending the last line of the paragraph.
271It is only responsible for vertical spacing between paragraphs.
Fred Drake8fe533e1998-03-27 05:27:08 +0000272\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000273
Fred Drake8fe533e1998-03-27 05:27:08 +0000274\begin{methoddesc}[writer]{send_hor_rule}{*args, **kw}
Fred Drakee83b30d1996-10-08 21:53:33 +0000275Display a horizontal rule on the output device. The arguments to this
276method are entirely application- and writer-specific, and should be
277interpreted with care. The method implementation may assume that a
Fred Drake3b5da761998-03-12 15:33:05 +0000278line break has already been issued via \method{send_line_break()}.
Fred Drake8fe533e1998-03-27 05:27:08 +0000279\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000280
Fred Drake8fe533e1998-03-27 05:27:08 +0000281\begin{methoddesc}[writer]{send_flowing_data}{data}
Fred Drakee83b30d1996-10-08 21:53:33 +0000282Output character data which may be word-wrapped and re-flowed as
283needed. Within any sequence of calls to this method, the writer may
284assume that spans of multiple whitespace characters have been
285collapsed to single space characters.
Fred Drake8fe533e1998-03-27 05:27:08 +0000286\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000287
Fred Drake8fe533e1998-03-27 05:27:08 +0000288\begin{methoddesc}[writer]{send_literal_data}{data}
Fred Drakee83b30d1996-10-08 21:53:33 +0000289Output character data which has already been formatted
290for display. Generally, this should be interpreted to mean that line
291breaks indicated by newline characters should be preserved and no new
292line breaks should be introduced. The data may contain embedded
293newline and tab characters, unlike data provided to the
Fred Drake3b5da761998-03-12 15:33:05 +0000294\method{send_formatted_data()} interface.
Fred Drake8fe533e1998-03-27 05:27:08 +0000295\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000296
Fred Drake8fe533e1998-03-27 05:27:08 +0000297\begin{methoddesc}[writer]{send_label_data}{data}
Fred Drake3b5da761998-03-12 15:33:05 +0000298Set \var{data} to the left of the current left margin, if possible.
299The value of \var{data} is not restricted; treatment of non-string
Fred Drakee83b30d1996-10-08 21:53:33 +0000300values is entirely application- and writer-dependent. This method
301will only be called at the beginning of a line.
Fred Drake8fe533e1998-03-27 05:27:08 +0000302\end{methoddesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000303
304
Fred Drakeb63e77c1999-02-22 14:14:48 +0000305\subsection{Writer Implementations \label{writer-impls}}
Fred Drakee83b30d1996-10-08 21:53:33 +0000306
Fred Drake8f925951996-10-09 16:13:22 +0000307Three implementations of the writer object interface are provided as
308examples by this module. Most applications will need to derive new
Fred Drake3b5da761998-03-12 15:33:05 +0000309writer classes from the \class{NullWriter} class.
Fred Drake8f925951996-10-09 16:13:22 +0000310
Fred Drake7bf5e081998-03-16 05:07:04 +0000311\begin{classdesc}{NullWriter}{}
Fred Drakee83b30d1996-10-08 21:53:33 +0000312A writer which only provides the interface definition; no actions are
313taken on any methods. This should be the base class for all writers
314which do not need to inherit any implementation methods.
Fred Drake7bf5e081998-03-16 05:07:04 +0000315\end{classdesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000316
Fred Drake7bf5e081998-03-16 05:07:04 +0000317\begin{classdesc}{AbstractWriter}{}
Fred Drakee83b30d1996-10-08 21:53:33 +0000318A writer which can be used in debugging formatters, but not much
Fred Drake5081b221998-01-15 05:49:00 +0000319else. Each method simply announces itself by printing its name and
Fred Drakee83b30d1996-10-08 21:53:33 +0000320arguments on standard output.
Fred Drake7bf5e081998-03-16 05:07:04 +0000321\end{classdesc}
Fred Drakee83b30d1996-10-08 21:53:33 +0000322
Fred Drakecce10901998-03-17 06:33:25 +0000323\begin{classdesc}{DumbWriter}{\optional{file\optional{, maxcol\code{ = 72}}}}
Fred Drakee83b30d1996-10-08 21:53:33 +0000324Simple writer class which writes output on the file object passed in
Fred Drake3b5da761998-03-12 15:33:05 +0000325as \var{file} or, if \var{file} is omitted, on standard output. The
Fred Drakee83b30d1996-10-08 21:53:33 +0000326output is simply word-wrapped to the number of columns specified by
Fred Drake3b5da761998-03-12 15:33:05 +0000327\var{maxcol}. This class is suitable for reflowing a sequence of
Fred Drakee83b30d1996-10-08 21:53:33 +0000328paragraphs.
Fred Drake7bf5e081998-03-16 05:07:04 +0000329\end{classdesc}