Skip to content

Node

Supertype of every document node.

Nodes form a tree rooted at Root, reached through Unit.root or Unit.nodes. The four intermediate supertypes -- Declaration, Param, Block, and Reference -- group the concrete kinds by what they carry, so a consumer can match on the level it cares about.

A node is a view of its unit, so reaching the same node twice may give two objects. Nodes compare and hash by unit and ID, as a NodeId does.

Fields

children @ Array[Node] [get]

The nodes whose parent is this one, in no particular order. Sort them by span for source order.

doc @ (Span | nil) [get]

The span of the comment block documenting the node, or nil where none attaches.

id @ NodeId [get]

The node's ID.

parent @ (NodeId | nil) [get]

The ID of the enclosing node, or nil for Root.

span @ (Span | nil) [get]

The span the node covers in the source, or nil for a prelude node, which has no source text.