Module generated_doc
Expand description
The GeneratedDoc contract, and the pragma splice that enforces it.
A generated page is a hand-written page with a hole in it. The hole is delimited by two HTML comments —
<!-- Begin auto-generated <label> -->
<!-- End auto-generated <label> -->— and this module is the only code that touches what lies between them.
Everything outside is the author’s: introduction, caveats, cross-links. The
four requirements of docs/design/11-documentation-plan.md §17.6 are all
enforced here rather than left to each generator:
- idempotent — the splice is a pure function of (framing, rendered content), so writing twice writes the same bytes;
- deterministic — nothing in this module reads a clock, an environment variable or a hash map, and the only absolute path it forms is the one used to open a file, never one it emits;
- fail-closed — a missing page, a missing pragma, a doubled pragma and a
generator that returns
Errall stop the run in every mode; - framing-preserving — the expected bytes are built by copying the
framing from disk, so
--mode checkcannot fail on prose and--mode writecannot destroy it.
Enums§
- Framing
- How a generator’s output relates to the file that holds it.
- Mode
- What
generate-alldoes to the pages. - Outcome
- What one generator did.
Traits§
- Generated
Doc - One generated documentation region.
Functions§
- begin_
pragma 🔒 - The opening pragma for
label. - drift 🔒
- Builds the
Error::Driftthat--mode checkfails with, naming the first line on which the page and the generator disagree. - end_
pragma 🔒 - The closing pragma for
label. - guard_
no_ 🔒pragma - Rejects rendered content that carries a pragma of its own.
- normalise_
final_ 🔒newline - Ends a page with exactly one newline.
- pragma_
error 🔒 - Builds an
Error::Pragmafor this page. - repo_
root - The repository root.
- run_one
- Runs one generator under
mode. - site_
links_ 🔒page_ relative - Renders one generator’s output, with this site’s own absolute URLs made page-relative.
- sole_
line 🔒 - Locates
marker, requiring it to appear exactly once and alone on its line. - splice 🔒
- Builds the bytes the page should hold: its own framing, with
contentbetween the pragmas. - whole_
file 🔒 - Builds the bytes a
Framing::WholeFileoutput should hold.