sphinxcontrib_rust.nodes

Module for creating docutils nodes from the JSON in the layout option of the directives

Classes

Node(type[, value, target])

A node in the document signatures that represents a Rust item.

NodeType(*values)

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, NEWLINE and RETURNS. The target is only used for LINK nodes 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 signode from the given nodes

The method will also add the generated nodes as children of the given signode properly 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 the addnodes.desc_signature_line.

class sphinxcontrib_rust.nodes.NodeType(*values)

Types of the nodes for the Rust items in the signatures

classmethod from_str(value: str) NodeType

Get the node type enum from the string value