| |
| .. method:: formatter.push_style(*styles) |
| |
| Push any number of arbitrary style specifications. All styles are pushed onto |
| the styles stack in order. A tuple representing the entire stack, including |
| :const:`AS_IS` values, is passed to the writer's :meth:`new_styles` method. |
| |
| |
n | .. method:: formatter.pop_style([n\ ``= 1``]) |
n | .. method:: formatter.pop_style([n=1]) |
| |
| Pop the last *n* style specifications passed to :meth:`push_style`. A tuple |
| representing the revised stack, including :const:`AS_IS` values, is passed to |
| the writer's :meth:`new_styles` method. |
| |
| |
| .. method:: formatter.set_spacing(spacing) |
| |
| Set the spacing style for the writer. |
| |
| |
n | .. method:: formatter.assert_line_data([flag\ ``= 1``]) |
n | .. method:: formatter.assert_line_data([flag=1]) |
| |
n | Inform the formatter that data has been added to the current paragraph out-of- |
n | Inform the formatter that data has been added to the current paragraph |
| band. This should be used when the writer has been manipulated directly. The |
| out-of-band. This should be used when the writer has been manipulated |
| optional *flag* argument can be set to false if the writer manipulations |
| directly. The optional *flag* argument can be set to false if the writer |
| produced a hard line break at the end of the output. |
| manipulations produced a hard line break at the end of the output. |
| |
| |
| .. _formatter-impls: |
| |
| Formatter Implementations |
| ------------------------- |
| |
| Two implementations of formatter objects are provided by this module. Most |
| is a string or ``None``, where ``None`` indicates that the writer's "preferred" |
| alignment should be used. Conventional *align* values are ``'left'``, |
| ``'center'``, ``'right'``, and ``'justify'``. |
| |
| |
| .. method:: writer.new_font(font) |
| |
| Set the font style. The value of *font* will be ``None``, indicating that the |
n | device's default font should be used, or a tuple of the form ``(``*size*, |
n | device's default font should be used, or a tuple of the form ``(size, |
| *italic*, *bold*, *teletype*``)``. Size will be a string indicating the size of |
| italic, bold, teletype)``. Size will be a string indicating the size of |
| font that should be used; specific strings and their interpretation must be |
| defined by the application. The *italic*, *bold*, and *teletype* values are |
| Boolean values specifying which of those font attributes should be used. |
| |
| |
| .. method:: writer.new_margin(margin, level) |
| |
| Set the margin level to the integer *level* and the logical tag to *margin*. |
| |
| .. class:: AbstractWriter() |
| |
| A writer which can be used in debugging formatters, but not much else. Each |
| method simply announces itself by printing its name and arguments on standard |
| output. |
| |
| |
t | .. class:: DumbWriter([file[, maxcol\ ``= 72``]]) |
t | .. class:: DumbWriter([file[, maxcol=72]]) |
| |
| Simple writer class which writes output on the file object passed in as *file* |
| or, if *file* is omitted, on standard output. The output is simply word-wrapped |
| to the number of columns specified by *maxcol*. This class is suitable for |
| reflowing a sequence of paragraphs. |
| |