sphinxcontrib_rust.nodes
Module for creating docutils nodes from the JSON in the layout option of the directives
Classes
|
A node in the document signatures that represents a Rust item. |
|
Types of the nodes for the Rust items in the signatures |
- class sphinxcontrib_rust.nodes.Node(type: NodeType, value: str | None = None, target: str | None = None)
A node in the document signatures that represents a Rust item.
The node is a dataclass that encapsulates the details of a Rust token and how to format it in the signature. The type of the node indicates which docutils element type is used for docutils node of the output. The value is the text to display in the node. It is required for all node types except
SPACE,NEWLINEandRETURNS. Thetargetis only used forLINKnodes to generate a link to the target.- classmethod create_signature(name: str, nodes: list[Node]) tuple[bool, list[Node]]
Create a Rust item signature under the
signodefrom the givennodesThe method will also add the generated nodes as children of the given
signodeproperly accounting for any multiline signatures. In case of multiline signatures, the permalink is added to the first line.- Args:
- name:
The name of the item whose signature is to be generated.
- nodes:
The list of nodes with the layout of the signature.
- Returns:
A tuple, whose first element indicates whether the signature is multiline or not and the second element is the list of nodes to add as a children for the signature.
- property text: str
Get the text for the node
- to_docutils_node() Node
Convert a node to the appropriate docutils node.
- Returns:
The docutils node for self, with any children node added.
- Raises:
- ValueError:
If called with a node of type
NodeType.NEWLINE. The newline does not have corresponding docutils node and instead must be handled by using theaddnodes.desc_signature_line.