module documentation

Collection of helper functions and classes related to the creation and processing of docutils nodes.

Class obj_reference A reference to a documentable object.
Class wbr Word break opportunity.
Function build_table_of_content Simplified from docutils Contents transform.
Function get_lineno Get the 0-based line number for a docutils `nodes.title_reference`.
Function new_document Create a new nodes.document using the provided settings or cached default settings.
Function set_node_attributes Set the attributes of a Node and return the modified node. This is required to manually construct a docutils document that is consistent.
Function _set_nodes_parent Set the nodes.Node.parent attribute of the nodes to the defined parent.
Constant _DEFAULT_DOCUTILS_SETTINGS Undocumented
def build_table_of_content(node: nodes.Node, depth: int, level: int = 0) -> nodes.Node | None: (source)

Simplified from docutils Contents transform.

All section nodes MUST have set attribute 'ids' to a list of strings.

def get_lineno(node: nodes.Node) -> int: (source)

Get the 0-based line number for a docutils `nodes.title_reference`.

Walk up the tree hierarchy until we find an element with a line number, then counts the number of newlines until the reference element is found.

def new_document(source_path: str, settings: optparse.Values | None = None) -> nodes.document: (source)

Create a new nodes.document using the provided settings or cached default settings.

Returns
nodes.documentnodes.document
def set_node_attributes(node: nodes.Node, document: nodes.document | None = None, lineno: int | None = None, children: Iterable[nodes.Node] | None = None) -> nodes.Node: (source)

Set the attributes of a Node and return the modified node. This is required to manually construct a docutils document that is consistent.

Parameters
node:nodes.NodeA node to edit.
document:nodes.document | NoneThe nodes.Node.document attribute.
lineno:int | NoneThe nodes.Node.line attribute.
children:Iterable[nodes.Node] | NoneThe nodes.Element.children attribute. Special care is taken to appropriately set the nodes.Node.parent attribute on the child nodes.
Returns
nodes.NodeUndocumented
def _set_nodes_parent(nodes: Iterable[nodes.Node], parent: nodes.Element) -> Iterator[nodes.Node]: (source)

Set the nodes.Node.parent attribute of the nodes to the defined parent.

Returns
Iterator[nodes.Node]An iterator containing the modified nodes.
_DEFAULT_DOCUTILS_SETTINGS: optparse.Values | None = (source)

Undocumented

Value
None