Skip to main content

Module doctree

Module doctree 

Source
Expand description

Typed doctree IR with docutils-equivalent node semantics (M2 wave 1).

Design (recorded in docs/superpowers/plans/2026-08-07-m2-wave-map.md): docutils-mirror generic node — node identity and attributes are data, not Rust types, so the pseudo-XML parity serializer is a direct dump and docutils transforms/writers port line-by-line. One Node struct covers every element type; kind holds the docutils tagname from kinds.

Source spans are structural: every node carries a byte-offset Span into the original source (docutils itself only keeps (source, line)). Spans are line-granular in wave 1; the wave-2 inline parser refines them.

Modules§

ids
docutils-exact id/name normalization and the document id registry.
kinds
docutils element tagnames.
messages
system_message node construction with docutils-exact shape.
pformat
Pseudo-XML emitter, byte-identical to docutils document.pformat().

Structs§

Attrs
docutils’ universal list attributes (basic_attributes + backrefs) as typed fields, plus an open, name-sorted list for everything else (refuri, enumtype, level, …). pformat merges both sets and prints all pairs in one alphabetical sequence, exactly like docutils attlist().
Doctree
One parsed document. root.kind == kinds::DOCUMENT.
Node
One doctree node. Element nodes have text == None; text leaves have kind == kinds::TEXT, Some(text), and no children or attributes.
Span
Byte-offset range into a source file. source indexes a per-doctree source table; wave 1 always uses source 0 (include arrives in wave 3).

Enums§

AttrValue
Scalar attribute value. docutils attribute dicts hold ints and strings for everything wave 1 emits; list-valued attributes live in Attrs’ typed fields instead.