Item#

Qualified name: rsm.nodes.Item

class rsm.nodes.Item(title='', **kwargs)[source]#

Bases: BaseParagraph

Methods

Attributes

possible_parents

Allowed types of parent Nodes.

nodeid

Node id - always exists (unlike label), automatically assigned, unique within the tree.

label

Unique identifier.

classes

CSS classes for this node.

handrail_depth

The number of ancestors of this node that have a handrail.

number

Node number.

nonum

Whether this node should be automatically given a number.

reftext_template

Reftext template, or "" to use classreftext.

start_point

The start point of the corresponding concrete syntax tree node.

end_point

The end point of the corresponding concrete syntax tree node.

possible_parents: ClassVar[set[type[NodeWithChildren]]] = {<class 'rsm.nodes.Contents'>, <class 'rsm.nodes.Enumerate'>, <class 'rsm.nodes.Itemize'>}[source]#

Allowed types of parent Nodes.

When setting the parent of a Node, this attribute is checked to see whether the intended parent has an admissible type.

Examples

This is a class variable

>>> nodes.Item.possible_parents == {nodes.Itemize, nodes.Enumerate, nodes.Contents}
True

This variable is checked when setting the parent directly.

>>> it = nodes.Item()
>>> it.parent = nodes.Paragraph()
Traceback (most recent call last):
rsm.nodes.RSMNodeError: Node of type <class 'rsm.nodes.Item'> cannot have parent of type <class 'rsm.nodes.Paragraph'>

This is also used when setting the parent in some other indirect way, for example when calling append() on the desired parent.

>>> nodes.Paragraph().append(it)
Traceback (most recent call last):
rsm.nodes.RSMNodeError: Node of type <class 'rsm.nodes.Item'> cannot have parent of type <class 'rsm.nodes.Paragraph'>

Allowed parents proceed without raising.

>>> nodes.Itemize().append(it)
Itemize(parent=None, [Item])