docutils.transforms.parts module

Transforms related to document parts.

class SectNum(document, startnode=None)[source]

Bases: Transform

Automatically assigns numbers to the titles of document sections.

It is possible to limit the maximum section level for which the numbers are added. For those sections that are auto-numbered, the “autonum” attribute is set, informing the contents table generator that a different form of the TOC should be used.

default_priority = 710

Should be applied before Contents.

apply()[source]

Override to apply the transform to the document tree.

update_section_numbers(node, prefix=(), depth=0)[source]
class Contents(document, startnode=None)[source]

Bases: Transform

This transform generates a table of contents from the entire document tree or from a single branch. It locates “section” elements and builds them into a nested bullet list, which is placed within a “topic” created by the contents directive. A title is either explicitly specified, taken from the appropriate language module, or omitted (local table of contents). The depth may be specified. Two-way references between the table of contents and section titles are generated (requires Writer support).

This transform requires a startnode, which contains generation options and provides the location for the generated table of contents (the startnode is replaced by the table of contents “topic”).

default_priority = 720

Numerical priority of this transform, 0 through 999 (override).

apply()[source]

Override to apply the transform to the document tree.

build_contents(node, level=0)[source]
copy_and_filter(node)[source]

Return a copy of a title, with references, images, etc. removed.

class ContentsFilter(document)[source]

Bases: TreeCopyVisitor

get_entry_text()[source]
visit_citation_reference(node)[source]
visit_footnote_reference(node)[source]
visit_image(node)[source]
ignore_node_but_process_children(node)[source]
visit_problematic(node)
visit_reference(node)
visit_target(node)