module documentation
Collection of helper functions and classes related to the creation and processing of docutils
nodes.
Class | code |
Like a inline[class='literal'], but more elegant. |
Class | obj |
A reference to a documentable object. |
Class | wbr |
Word break opportunity. |
Function | build |
Simplified from docutils Contents transform. |
Function | get |
Get the 0-based line number for a docutils `nodes.title_reference`. |
Function | new |
Create a new nodes.document using the provided settings or cached default settings. |
Function | set |
Set the attributes of a Node and return the modified node. This is required to manually construct a docutils document that is consistent. |
Function | text |
Create an inline node with the given text and class. |
Type Variable |
|
Undocumented |
Function | _set |
Set the nodes.Node.parent attribute of the nodes to the defined parent. |
Constant | _DEFAULT |
Undocumented |
def build_table_of_content(node:
nodes.Element
, depth: int
, level: int
= 0) -> nodes.Element | None
:
(source)
¶
Simplified from docutils Contents transform.
All section nodes MUST have set attribute 'ids' to a list of strings.
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.document | nodes.document |
def set_node_attributes(node:
TNode
, document: nodes.document | None
= None, lineno: int | None
= None, children: Iterable[ nodes.Node] | None
= None) -> TNode
:
(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:TNode | A node to edit. |
document:nodes.document | None | The nodes.Node.document attribute. |
lineno:int | None | The nodes.Node.line attribute. |
children:Iterable[ | The nodes.Element.children attribute. Special care is taken to appropriately set the nodes.Node.parent attribute on the child nodes. |
Returns | |
TNode | Undocumented |
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[ | An iterator containing the modified nodes. |