Expand description
docs-compiler: the composition CLI for the estate’s docs crates (docs-core extension program, SPEC.md M3/M4).
The pipeline is small and honest: scan a markdown document for the
four directive kinds, resolve each one through the crate that owns it
(include-symbol through docs-symbols, witness through
docs-witness, lean-check through an out-of-process lean plus
docs-proof, islands natively through docs-core), substitute the
resulting raw HTML, and render the page with docs-core. Any failing
directive fails the build with a typed error naming its source;
nothing degrades to a silent placeholder.
use docs_compiler::BuildContext;
// No directives: the document flows through docs-core untouched.
let html = docs_compiler::compile(
"# Title\n\nSome *prose*.\n",
&BuildContext::new("."),
)
.unwrap();
assert!(html.contains("<h1 id=\"title\">Title</h1>"));§Layer
L3 - composition. Depends on docs-core (L2) and the capability
crates (L0/L1); spawns lean as an external process (REQ-P1).
Structs§
- Build
Context - The build context: directive file paths resolve against this root.
- Chrome
- Everything the layout needs to wrap one page.
- Directive
- One resolved directive fence.
- NavGroup
- One group in the sidebar nav tree (a top-level directory).
- Page
Meta - Per-page metadata, from the page’s front-matter (
---fencedkey: valuescalars).titlefalls back to the first<h1>, then the file stem;descriptionfalls back to the first paragraph. - Scanned
- A scanned source: raw markdown segments and directive fences, in document order.
- SeoPage
- One indexable page, as the SEO emitters see it.
- Site
Config - Site-wide settings, from
site.tomlin the source root. - Site
Report - What one site compilation pass produced.
- TocEntry
- One table-of-contents entry (h2/h3 with their anchor ids).
- Tools
- Which compressors exist on this host.
Enums§
- Compiler
Error - Why a build failed. Every directive failure names its source.
- Directive
Kind - The four directive fences this compiler resolves. Island fences are not here: docs-core renders those natively.
Constants§
- VERSION
- The crate’s version, for callers that report it.
- chrome_
layout_ css - The chrome stylesheet, embedded at compile time and emitted by the
site builder as
/_assets/layout.css.
Functions§
- chrome_
page - Wrap a rendered page document with the site chrome.
docis the full<!doctype html>...<body>content</body></html>document fromseo::document; the body content is lifted into the layout (header + sidebar + main + TOC + pager) by exact-markup surgery on markup this crate itself emitted.base_pathprefixes every site-relative URL the chrome emits (empty string = served at root). - compile
- Compile one markdown document into a static HTML page.
- compile_
site - Compile every
.mdundersrc(recursive, hidden dirs skipped) into the mirrored.htmllayout underout, wrapped in the site chrome. Front-matter (title,description,slug,date) overrides the title/description/route/date fallbacks. Directive roots are each page’s own directory, matching the single-file CLI’s default. - compile_
site_ with compile_sitewith a base-path override (subpath hosting: the preview deploy under/solid-fx/previewpasses that prefix here and every chrome URL follows it).- document
- The full-document wrapper: doctype, head (charset, viewport, title,
description, canonical, Open Graph, Twitter card, JSON-LD), body.
routeis the page’s site-relative HTML path (index.html,guides/x.html). Length guidance (title <=60, description <=155) surfaces as warnings in the report, not build failures. - ext_
token - The
Content-Encodingtoken for a sidecar extension. - extract_
toc - Extract the TOC (h2/h3 with anchor ids) from a rendered body. h1 is the page title and stays out of the TOC; deeper levels rarely carry anchors worth listing.
- first_
h1 - Derive a page title from the rendered body: the first
<h1>text. - first_
paragraph - Derive a description from the rendered body: the first paragraph’s text, tags stripped, truncated at a word boundary to 155 chars.
- llms_
txt llms.txt(GEO floor): the site heading plus one curated link per page with its description.- mime_
for - MIME type by extension; unknown extensions are plain text (the browser shows them instead of downloading).
- pick_
encoding - Pick the best encoding for a request: reads the client’s
Accept-Encoding(token presence only, no q-value arithmetic - documented limitation) against the sidecars that exist forpath. Preference: dcz (dictionary-compressed) > br > zstd > gz. - resolve
- Resolve one directive fence to a raw HTML block.
- resolve_
route - Map a request path to a file under
out: empty →index.html; directories resolve to theirindex.html; an extensionless path falls back to<path>.html. Percent escapes are decoded; anything that escapesout(or games the encoding) resolves to nothing. - robots_
txt robots.txtwith the AI-crawler policy as a recorded decision.- scan
- Scan markdown for directive fences. Unrecognized fences (plain code, islands) are left as raw text for docs-core.
- sidecar_
path - The sidecar path for one encoding (
x.html→x.html.gz). - sitemap_
xml sitemap.xml: one<url>per page, sorted by route;lastmodonly when the page declares a date (deterministic builds do not lie about modification times).- split_
front_ matter - Split a leading
---front-matter block off a document: returns the parsed metadata and the remainder to compile.