Expand description
Render-hook dispatch: walk the IR, ask registered handlers to render their labelled annotations / verbatim blocks, and surface the results to the format-specific serializer.
This module is format-independent: it builds a RenderPlan of
(label, rendered string, optional diagnostic) triples in document
order. The serializer for each format (HTML first, others later) is
responsible for splicing the rendered strings into its output and
routing the diagnostics onto the host’s diagnostic channel.
Bounded extensibility: a label whose namespace is not registered is left untouched — the default rendering applies.
§Status (#616)
Render dispatch now walks the IR (ir::nodes::Document), not the
lex-core AST. This brings the “centralize hard logic in the IR”
principle from crates/lex-babel/src/lib.rs:60-64 back to a single
center: the same IR feeds both the event-stream serializer and the
render-hook dispatch.
§Behavioural note: NodeRef.kind for attached annotations
The wire spec §2.1 says LabelCtx.node.kind is the host AST kind
the label is attached to. The IR flattens attached annotations into
sibling DocNodes (see ir::from_lex::extract_attached_annotations),
so the original attachment kind is not recoverable from the IR
alone. Handlers receiving an attached annotation see the kind of
its IR container (the session, list-item, definition, or outer
annotation it sits inside) rather than the kind of the element it
was attached to in the source.
Doc-scope annotations — those that live in
Document::document_annotations — continue to surface as
kind="document".
Restoring source-attachment precision needs an IR-side change (a
per-Annotation attached_to: Option<HostNodeKind> tag set by
from_lex); that belongs to the IR symmetry work-stream
(#614 / Sub A territory), not the render-dispatch migration.
Structs§
- Render
Plan - Outcome of the render-dispatch walk: a list of per-node render results in document order, plus any document-root diagnostics (panic, namespace disabled).
- Rendered
Node - One render result for a labelled node, captured during the IR walk so the format-specific serializer can splice it into the final output.
Functions§
- dispatch_
render - Walk
documentand dispatchon_renderfor every labelled annotation / verbatim whose schema declares the format inhooks.render. Returns the plan; the caller (HTML serializer) is responsible for splicing.