Caption
Qualified name: rsm.nodes.Caption
-
class rsm.nodes.Caption(title='', **kwargs)[source]
Bases: Paragraph
Methods
Attributes
-
possible_parents: ClassVar[set[Type[rsm.nodes.NodeWithChildren]]] = {<class 'rsm.nodes.Table'>, <class 'rsm.nodes.Figure'>}[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])