Architecture
Folioh Docs has one local build pipeline. The CLI reads configuration and parses
project sources once, then emits the human site and its agent-readable mirrors.
The pipeline runs inside the folioh binary. Its implementation lives in the
Rust crates under crates/.
Runtime Flow
flowchart LR CLI["▸ CLI: build / serve"] --> Config["▣ docs.yaml"] Config --> Sources["▤ Source + Markdown"] Sources --> Parse["⚙ Parse"] Parse --> IRNode["◇ IR objects"] IRNode --> Docs["▥ folioh-docs"] Extensions["⊕ Built-in plugins"] --> Docs Template["▧ Nextra template"] --> Docs Docs --> Site["✓ HTML site + search"] Docs --> Context["✓ Markdown + llms.txt + contract"]
folioh-cliis the CLI host: it handles arguments and runs the build pipeline. Thefoliohbinary iscrates/folioh-cli/src/bin/folioh.rs, amainthat callsfolioh_cli::runand nothing else.folioh-configloadsdocs.yamland resolves project paths.- One language crate per language profile parses the configured sources into
folioh-irobjects (ModuleIR,ClassIR,FunctionIR,TypeIR);folioh-lang-python,folioh-lang-javascriptandfolioh-lang-rustare the profiles that ship today. The Python reader parses docstrings with the parsers infolioh-ir:auto, the default, detects reStructuredText, Google, NumPy and epydoc per docstring, andsource.python.docstring_stylepins Google or NumPy. folioh-docsturns the IR into MDX pages and the API reference overview, and computes routes, cross-references, coverage and thellms.txttext.folioh-mdxreads the Markdown guides and turns them into MDX, and turns MDX back into the Markdown mirrors.folioh-siteowns the site workspace, sidebar, metadata, themes, search data, link checker and Next runtime, and writes the pages, mirrors and LLM files.folioh-watchwatches sources and invalidates the retained build forfolioh serve.folioh-pluginsholds the component manifest, the authoring contract and the built-in plugins (landing, roadmap, OpenAPI).- The Nextra template ships inside the binary and is materialised once under
the user cache directory (
$XDG_CACHE_HOME/folioh/template/<version>-<hash>or the platform equivalent);FOLIOH_TEMPLATE_DIRoverrides it.
Crate boundaries
crates/* owns the engine and the CLI host: eleven crates, one per
boundary. folioh-cli carries the host as a
library and builds the folioh binary from its own src/bin/folioh.rs. The root
Cargo workspace coordinates the packages without owning an engine.
Folioh Docs internals
folioh-site splits build-environment work into smaller steps:
- copies the bundled template from the cache directory (or
FOLIOH_TEMPLATE_DIR) into.build/and removes bundled demo content. - replaces template placeholders with
docs.yamlvalues. - writes plugin components, typed data modules, and generated views.
- installs dependencies, runs Next.js, serves development mode, and copies static output.
- rewrites exported links so the static site works from
file://.
Reading the site as an agent
The same build emits the pages a person reads and the text an agent fetches, from one pass over the sources:
llms.txtat the site root indexes every published page andllms-full.txtcarries all of them as Markdown, both following the llmstxt.org spec. Thellm:section switches them off (Configuration)._folioh/markdown/<route>.mdmirrors each page, and every HTML page declares its mirror as atext/markdownalternate and lists it in the sitemap. Fetch the mirror instead of scraping the HTML._folioh/contract.jsonlists the core MDX components every template wires, with their props, the top-leveldocs.yamlkeys the binary recognises, and every route the build emitted: the authoring surface, as the binary that wrote the site sees it.
Two invariants hold for anything reading or writing a Folioh project. Folioh
parses source and never executes it, so a package needs no install, no runtime
dependency and no import stub for its reference to build. And folioh --help
is the authority on commands and flags, Configuration on
docs.yaml keys, and the component catalogue on
components; a flag or key that appears in neither folioh --help nor
Configuration does not exist.
Extension boundary
The only plugins in this release are the built-in ones. Project plugins: Not available in this release. Plugin internals stay isolated from source parsing and theme implementation details. A plugin contributes documents and components to the site while inheriting every generated surface: a contributed page also receives a Markdown mirror and appears in the configured LLM indexes.