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 Span with real
(source, line) provenance plus the byte range of its text in the
parser’s processed source (docutils itself only keeps (source, line)).
Spans are line-granular; the inline parser stamps its nodes with the
enclosing text block’s span.
Modules§
- ids
- docutils-exact id/name normalization and the document id registry.
- kinds
- docutils element tagnames.
- messages
system_messagenode 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, …).pformatmerges both sets and prints all pairs in one alphabetical sequence, exactly like docutilsattlist(). - Doctree
- One parsed document.
root.kind == kinds::DOCUMENT. - Node
- One doctree node. Element nodes have
text == None; text leaves havekind == kinds::TEXT,Some(text), and no children or attributes. - Span
- Source provenance of a node: which source it came from, the 1-based line docutils would report for it, and the byte range of its text.
Enums§
- Attr
Value - Attribute value. docutils attribute dicts hold ints and strings for
everything wave 1 emits; docutils’ five universal list attributes
(
ids,names, …) live inAttrs’ typed fields instead.
Functions§
- from_
bincode - Decode a doctree previously written by
to_bincode. Also the entry point for bytes that weren’t — a corrupted file, or a stale/foreign blob from a version-skewed cache — which can fail for the usual decode reasons and additionally once decoding would intern more thanintern’s bounded table allows (seesrc/doctree/intern.rs). - to_
bincode - Encode a doctree to its bincode wire format (config:
standard()). Infallible in practice: every field either derivesSerializeor goes through the interner’s plain string encoding, neither of which can fail.