epydoc.markup.epytext.Token

Package epydoc :: Package markup :: Module epytext :: Class Token |
[show private | hide private]
[frames | no frames]

## Class Token

`Token`s are an intermediate data structure used while constructing the structuring DOM tree for a formatted docstring. There are five types of `Token`:

- Paragraphs
- Literal blocks
- Doctest blocks
- Headings
- Bullets

The text contained in each `Token` is stored in the `contents` variable. The string in this variable has been normalized. For paragraphs, this means that it has been converted into a single line of text, with newline/indentation replaced by single spaces. For literal blocks and doctest blocks, this means that the appropriate amount of leading whitespace has been removed from each line.

Each `Token` has an indentation level associated with it, stored in the `indent` variable. This indentation level is used by the structuring procedure to assemble hierarchical blocks.

Method Summary
| ``__init__`(self, tag, startline, contents, indent, level)` Create a new `Token`.
`string` | ``__repr__`(self)` Return the formal representation of this `Token`.
`xml.dom.minidom.Element` | ``to_dom`(self, doc)` Return a DOM representation of this `Token`.

Instance Variable Summary
`string` | `contents`: The normalized text contained in this `Token`.
`int` or `None` | `indent`: The indentation level of this `Token` (in number of leading spaces).
`int` or `None` | `level`: The heading-level of this `Token` if it is a heading; `None`, otherwise.
`int` | `startline`: The line on which this `Token` begins.
`string` | `tag`: This `Token`'s type.

Class Variable Summary
`string` | `BULLET`: The `tag` value for bullet `Token`s.
`string` | `DTBLOCK`: The `tag` value for doctest `Token`s.
`string` | `HEADING`: The `tag` value for heading `Token`s.
`string` | `LBLOCK`: The `tag` value for literal `Token`s.
`string` | `PARA`: The `tag` value for paragraph `Token`s.

Method Details

### __init__(self, tag, startline, contents, indent, level=None) (Constructor) Create a new `Token`. Parameters: `tag` - The type of the new `Token`. (type=`string`) `startline` - The line on which the new `Token` begins. (type=`int`) `contents` - The normalized contents of the new `Token`. (type=`string`) `indent` - The indentation of the new `Token` (in number of leading spaces). A value of `None` indicates an unknown indentation. (type=`int` or `None`) `level` - The heading-level of this `Token` if it is a heading; `None`, otherwise. (type=`int` or `None`)

    ### __repr__(self) (Representation operator) Returns: the formal representation of this `Token`. `Token`s have formal representaitons of the form:
           <Token: para at line 12>
(type=`string`)

### to_dom(self, doc) Returns: a DOM representation of this `Token`. (type=`xml.dom.minidom.Element`)

Instance Variable Details

### contents The normalized text contained in this `Token`. Type: `string`

### indent The indentation level of this `Token` (in number of leading spaces). A value of `None` indicates an unknown indentation; this is used for list items and fields that begin with one-line paragraphs. Type: `int` or `None`

### level The heading-level of this `Token` if it is a heading; `None`, otherwise. Valid heading levels are 0, 1, and 2. Type: `int` or `None`

### startline The line on which this `Token` begins. This line number is only used for issuing errors. Type: `int`

### tag This `Token`'s type. Possible values are `Token.PARA` (paragraph), `Token.LBLOCK` (literal block), `Token.DTBLOCK` (doctest block), `Token.HEADINGC`, and `Token.BULLETC`. Type: `string`

Class Variable Details

    ### BULLET The `tag` value for bullet `Token`s. This `tag` value is also used for field tag `Token`s, since fields function syntactically the same as list items. Type: `string` Value:
        'bullet'

    ### DTBLOCK The `tag` value for doctest `Token`s. Type: `string` Value:
        'doctestblock'

    ### HEADING The `tag` value for heading `Token`s. Type: `string` Value:
        'heading'

    ### LBLOCK The `tag` value for literal `Token`s. Type: `string` Value:
        'literalblock'

    ### PARA The `tag` value for paragraph `Token`s. Type: `string` Value:
        'para'

Generated by Epydoc 2.1 on Sat Mar 20 17:46:13 2004 | http://epydoc.sf.net