Building the documentation

This file describes how the kit's documentation is produced, what to edit, and what is generated. For the product docs themselves, start at index.html (searchable landing page) or the engine / Blender indexes. Kit version in prose hubs: engine v0.31.1 · Blender add-on v0.32.0 (from packages/engine/package.json + blender_addon/blender_manifest.toml at build time).


Contributor quick start

Pick the row that matches what you want to change, edit the source file, then run the command. Never hand-edit generated HTML under docs/ (except meta .md files).

I want to…Edit thisThen run
Fix prose chapter textscripts/docs/prose/content/engine/NN-….htmlnpm run docs:prose
Add a prose chapterCopy _FRAGMENT-TEMPLATE.html · register in manifest.mjs · PAGE_TOPICSnpm run docs:build
Add an engine code tracescripts/build-trace-docs.mjsTRACESnpm run docs:trace
Add a Blender code tracescripts/build-blender-docs.mjsTRACESnpm run docs:blender
Edit a subsystem diagramscripts/docs/engine-areas.mjs or build-blender-docs.mjsAREA_PAGESnpm run docs:build
Change landing search / topicsscripts/docs/topics.mjs · scripts/build-landing.mjsnpm run docs:build
Change page layout / typographydocs/_template/prose-shell.html or diagram-shell.htmlnpm run docs:build
Check links + registry before a PRnpm run docs:validate · npm run docs:check-links

Every built prose page footer shows the exact fragment path. Full build (docs:build) runs validate + link check at the end.


Three kinds of documentation

KindLocationHow it is maintained
Interactive HTMLdocs/engine/*.html, docs/blender/*.html, docs/index.htmlGenerated — diagrams and traces from build scripts + data
Prose chaptersscripts/docs/prose/content/docs/engine/, docs/launcher/Hand-authored HTML fragments — assembled by build-prose-docs.mjs
Meta markdowndocs/*.md (style guide, test plan, LLM contracts, …)Hand-authored — stays .md; not indexed on the landing page
This guidescripts/docs/prose/content/meta/BUILDING-DOCS.htmldocs/BUILDING-DOCS.htmlHTML fragment — same prose build as chapters

The interactive pages are clickable node graphs and step-by-step code traces that pull live source from packages/engine/ and blender_addon/. Prose chapters are longer-form narrative (architecture, workflow, feature traces in prose) as styled HTML — edit the fragment files directly, not markdown.

Meta markdown (STYLE_GUIDE.md, LLM_*.md, …) is for contributors and tooling; it is listed on the landing footer but not converted to prose HTML. This guide (BUILDING-DOCS.html) is indexed in search under the Contributors topic.


Source map — what to edit for everything

Rule of thumb: never hand-edit generated HTML under docs/ except the short blender/00-INDEX.md redirect stub and hand-edited meta .md files. Edit the source column, then npm run docs:build.

What you seeGenerated outputEdit this (source)Built by
Landing page — search, topic hub, synonyms docs/index.html scripts/build-landing.mjs (page UI + SYNONYMS) · scripts/docs/topics.mjs (topics, start-here, PAGE_TOPICS) build-landing.mjs
Engine subsystem diagrams — topic maps (physics, load, input, …) docs/engine/index.html, load-pipeline.html, physics.html, … scripts/docs/engine-areas.mjsENGINE_AREA_PAGES build-trace-docs.mjs
Engine code traces — step walkthroughs + live TS docs/engine/trace-*.html scripts/build-trace-docs.mjsTRACES · symbols read from packages/engine/, apps/ build-trace-docs.mjs
Blender subsystem diagrams docs/blender/index.html, data-model.html, export.html scripts/build-blender-docs.mjsAREA_PAGES build-blender-docs.mjs
Blender code traces — step walkthroughs + live Python docs/blender/trace-*.html scripts/build-blender-docs.mjsTRACES · symbols read from blender_addon/ build-blender-docs.mjs
Prose chapters — architecture, physics, workflow, … docs/engine/0*.html, docs/blender/00-INDEX.html, docs/launcher/*.html scripts/docs/prose/content/ (engine, blender, launcher, meta) · registry: scripts/docs/prose/manifest.mjs build-prose-docs.mjs
This guide docs/BUILDING-DOCS.html scripts/docs/prose/content/meta/BUILDING-DOCS.html build-prose-docs.mjs
Diagram viewer — pan/zoom canvas, toolbar, trace code panel injected into every docs/engine/*.html and docs/blender/*.html diagram/trace page docs/_template/diagram-shell.html · assembly: scripts/docs/shared.mjs (EmitDiagramPage, nav, ExtractSymbol / ExtractPySymbol) build-trace-docs.mjs · build-blender-docs.mjs
Prose page layout — typography, toolbar, mermaid wrapped around every prose chapter + this guide docs/_template/prose-shell.html build-prose-docs.mjs
Engine index hub (prose) docs/engine/00-INDEX.html scripts/docs/prose/content/engine/00-INDEX.html build-prose-docs.mjs
Blender index hub (prose) docs/blender/00-INDEX.html scripts/docs/prose/content/blender/00-INDEX.html build-prose-docs.mjs
Blender index redirect (stub) docs/blender/00-INDEX.md same path — short redirect to 00-INDEX.html none
Kit version placeholder prose hubs (engine v0.31.1 · Blender add-on v0.32.0) scripts/docs/kit-version.mjs · applied in build-prose-docs.mjs build-prose-docs.mjs
Contributor meta docs — style guide, LLM contracts docs/*.md (e.g. STYLE_GUIDE.md, LLM_KERNEL.md) same paths — hand-edited · list: KEPT_META_MD in scripts/docs/prose-config.mjs none · bjs-mcp reads some via tools/bjs-mcp/src/paths.ts

Orchestrator: scripts/build-docs.mjs runs trace → blender → prose → landing → validate → link check. package.json scripts: docs:build, docs:trace, docs:blender, docs:prose, docs:validate, docs:check-links.


Build commands

All commands run from the repository root.

CommandWhat it rebuilds
npm run docs:buildEverything — engine, Blender, prose, landing page, then validate + link check
npm run docs:tracedocs/engine/ subsystem diagrams + traces only
npm run docs:blenderdocs/blender/ subsystem diagrams + traces only
npm run docs:proseProse + BUILDING-DOCS.html only
npm run docs:validateRegistry checks — fragments exist, prev/next chain, PAGE_TOPICS coverage (no HTML regen)
npm run docs:check-linksVerify internal hrefs in prose fragments + contributor .md (no HTML regen)

docs:build is the one to use after any doc change. It runs, in order:

  1. scripts/build-trace-docs.mjs → engine diagrams + traces
  2. scripts/build-blender-docs.mjs → Blender diagrams + traces
  3. scripts/build-prose-docs.mjs → prose chapters
  4. scripts/build-landing.mjsdocs/index.html (includes BUILDING-DOCS.html in search)
  5. scripts/docs/validate-docs.mjs → fragment registry + topic coverage
  6. scripts/check-doc-links.mjs → internal link validation

The Babylon Launcher can also trigger a build via POST /api/docs/build (see launcher docs).


Architecture

flowchart LR
  subgraph sources ["Edit these"]
    direction TB
    shell["diagram-shell.html"]
    proseShell["prose-shell.html"]
    shared["shared.mjs"]
    engineAreas["engine-areas.mjs"]
    engineTraces["engine TRACES"]
    blenderAreas["blender AREA_PAGES"]
    blenderTraces["blender TRACES"]
    proseContent["prose/content/"]
    proseManifest["prose/manifest.mjs"]
    topics["topics.mjs"]
  end

  subgraph build ["Build scripts"]
    direction TB
    buildTrace["build-trace-docs"]
    buildBlender["build-blender-docs"]
    buildProse["build-prose-docs"]
    buildLanding["build-landing"]
  end

  subgraph generated ["Generated — do not hand-edit"]
    direction TB
    engineHtml["docs/engine/*.html"]
    blenderHtml["docs/blender/*.html"]
    launcherHtml["docs/launcher/*.html"]
    metaHtml["docs/BUILDING-DOCS.html"]
    indexHtml["docs/index.html"]
  end

  subgraph code ["Read at build time"]
    direction TB
    engineSrc["packages/engine/"]
    blenderSrc["blender_addon/"]
  end

  shell --> buildTrace
  shared --> buildTrace
  shared --> buildBlender
  engineAreas --> buildTrace
  engineTraces --> buildTrace
  engineSrc --> buildTrace
  blenderAreas --> buildBlender
  blenderTraces --> buildBlender
  blenderSrc --> buildBlender
  proseShell --> buildProse
  proseContent --> buildProse
  proseManifest --> buildProse
  buildTrace --> engineHtml
  buildBlender --> blenderHtml
  buildProse --> engineHtml
  buildProse --> launcherHtml
  buildProse --> metaHtml
  engineAreas --> buildLanding
  engineTraces --> buildLanding
  blenderAreas --> buildLanding
  blenderTraces --> buildLanding
  topics --> buildLanding
  buildTrace --> buildLanding
  buildBlender --> buildLanding
  buildProse --> buildLanding
  buildLanding --> indexHtml

Prose chapters (HTML fragments)

Narrative docs (architecture, physics, workflow, launcher guide, …) are HTML body fragments edited directly:

scripts/docs/prose/content/engine/01-ARCHITECTURE.html (etc.)

scripts/build-prose-docs.mjs wraps each fragment in docs/_template/prose-shell.html (toolbar, prev/next nav, typography) and writes docs/engine/01-ARCHITECTURE.html (etc.). Register new chapters in scripts/docs/prose/manifest.mjs (PROSE_CHAPTERS) and scripts/docs/topics.mjs (PAGE_TOPICS).

Fragment files contain only the <article> inner HTML (<h1>, <p>, <table>, <pre>, …). Use <pre class="mermaid"> for diagrams (mermaid.js loads from CDN when present). Link to other chapters with .html paths; contributor meta docs stay .md (STYLE_GUIDE.md, LLM_KERNEL.md, …).

Starter template: copy scripts/docs/prose/content/_FRAGMENT-TEMPLATE.html when adding a chapter.

Prose CSS classes (defined in prose-shell.html)

ClassUse for
doc-links“See also” line linking subsystem diagrams + traces + reference chapters
trace-featureBordered card wrapping one feature in 10-FEATURE-TRACES.html
trace-summary · trace-interactivePlain-language intro + link to interactive trace inside a card
trace-flowOrdered step list inside a feature card
step-stage · step-what · step-codePhase label · plain explanation · code pointer per step
trace-legendFive-phase legend at the top of chapter 10

Reference chapters: 13 — Feature List (inventory) · 14 — API Guide (behavior author API).


Interactive HTML: the shared shell

Every diagram and trace page is assembled from one template:

docs/_template/diagram-shell.html

The shell contains the viewer UI (pan/zoom canvas, node panel, toolbar, import/export of diagram JSON). Build scripts inject:

To change viewer behaviour or styling for all diagram pages, edit the shell once and run npm run docs:build.

Assembly lives in scripts/docs/shared.mjsEmitDiagramPage().


Subsystem diagrams vs code traces

User-facing name: subsystem diagram. Internally the data still lives in ENGINE_AREA_PAGES / AREA_PAGES (historical “area” jargon — not Blender AREA lights). The landing index tags them kind: "diagram" and displays the badge subsystem. On diagram and trace pages, the bottom nav shows breadcrumb links plus a full Traces row listing every code trace on that side (current page highlighted).

Subsystem diagrams

High-level subsystem maps: boxes and arrows, hand-authored content, no source extraction.

SideData fileOutput
Enginescripts/docs/engine-areas.mjsENGINE_AREA_PAGESdocs/engine/index.html, load-pipeline.html, physics.html, …
Blenderscripts/build-blender-docs.mjsAREA_PAGESdocs/blender/index.html, data-model.html, export.html

Each page entry has:

Blender area pages use helpers N() and E() from shared.mjs for nodes and edges. Engine area pages use plain JSON objects (same shape).

Code traces

Step-by-step walkthroughs along a feature path. Each step is either:

SideDefinitionSource roots
EngineTRACES in scripts/build-trace-docs.mjspackages/engine/, apps/ (for examples)
BlenderTRACES in scripts/build-blender-docs.mjsblender_addon/

Output files are named trace-<id>.html (e.g. trace-physics.html).

Trace pages use a wider code panel (CODE_PANEL_PATCH_* in shared.mjs). Clicking a step shows the extracted source and file:line.


Automatic diagram ↔ trace linking

Subsystem diagrams and code traces stay paired at build time — no hand-maintained link lists in the bottom nav or on every node. The single source of truth is PAGE_TOPICS in scripts/docs/topics.mjs (the same map that powers the landing-page topic hub).

How topics choose related pages

Each subsystem diagram and trace page is tagged with one or more topic ids (physics, rendering, export, …). Meta topics start and contributor are ignored when pairing.

Helpers in topics.mjs: TracesForDiagram(href), DiagramsForTrace(href), FilterNavByHrefs().

Bottom nav (page-level)

Page kindBehaviour
Subsystem diagramBreadcrumb trail (Docs → Engine/Blender guide → Diagrams → current page). Traces row lists all traces on that side.
Code traceSame breadcrumb + full Traces row (current trace highlighted).
Prose chapterToolbar + prev/next in prose-shell.html; footer shows the source fragment path.

Nav HTML is built in scripts/docs/shared.mjs (BuildDiagramBottomNav) and wired in build-trace-docs.mjs / build-blender-docs.mjs.

Node metadata (click a box)

When a subsystem diagram is emitted, scripts/docs/diagram-links.mjs adds Trace rows to each node's meta panel unless the node already has a Trace key (manual entries are preserved).

A trace is attached to a node when:

  1. It is topic-related to the parent diagram page, and
  2. Any of the following match a step in that trace:
    • Symbol — step symbol equals the node label, or appears in sub
    • File path — a step file contains a token from the node's File, Files, or Module meta value (split on ·, commas, spaces)
    • traceIds — optional node field, e.g. "traceIds": ["physics", "constraint"], forces those traces when heuristics are not enough

On overview diagrams, only symbol matches (and explicit traceIds) are used — file-path matching is disabled so the map does not link every box to every trace.

On code-trace pages, each step node gets Diagram meta rows for every topic-related subsystem diagram (same-side). Cross-side links (e.g. ../engine/input.html from a Blender node) remain manual in the source data. In the viewer, Trace and Diagram meta values render as clickable links (diagram-shell.htmlrenderMeta).

Adding a new trace or diagram

  1. Add the page to PAGE_TOPICS with the right topic id(s).
  2. Give diagram nodes a label / sub / File meta that overlaps the trace's step symbols or paths — or set traceIds on the node.
  3. Run npm run docs:build. Nav and node panels update automatically.

To opt a node out of auto traces, add any Trace meta row yourself (even a single manual target); auto-linking skips that node entirely.


Symbol extraction (anti-rot)

Before writing trace HTML, the build reads the real source and embeds it in each step:

If a symbol is missing or renamed, the build prints MISSING: …, sets exit code 1, and does not write trace pages for that packet. This keeps docs from silently showing stale code.

After changing a traced function's name or file, update the TRACES array and re-run the appropriate docs:* command.


Landing page, topic hub, and search

docs/index.html is fully generated by scripts/build-landing.mjs.

It indexes every subsystem diagram, code trace, prose chapter, and this guide, so search stays in sync with the graphs and narrative docs. Features:

Adding a page to a topic

  1. Add or update the page's href in PAGE_TOPICS in scripts/docs/topics.mjs (one or more topic ids).
  2. If the page should appear in Start here, add its href to that topic's startHere array (order matters).
  3. Run npm run docs:build.

New prose chapters require an entry in PROSE_CHAPTERS (manifest.mjs) and topic assignment in PAGE_TOPICS. Contributor markdown under docs/ is listed in KEPT_META_MD (scripts/docs/prose-config.mjs) and linked from the landing footer — not prose HTML.

To improve search for a new concept, add synonyms in SYNONYMS or ensure the page's desc / note fields use words people will search for.


File reference

Quick index of build scripts and templates (see Source map above for edit-vs-output pairing).

PathRole
scripts/docs/prose-config.mjsKEPT_META_MD — contributor markdown not converted to HTML
scripts/docs/validate-docs.mjsFragment registry, prev/next chain, PAGE_TOPICS coverage
scripts/check-doc-links.mjsInternal href validation in prose fragments + meta markdown
scripts/docs/prose/content/_FRAGMENT-TEMPLATE.htmlCopy-paste starter for new prose chapters (not in manifest)
scripts/build-docs.mjsOrchestrator — engine, Blender, prose, landing, validate, links
scripts/build-prose-docs.mjsProse chapter assembly; exports BuildProseDocs
scripts/build-trace-docs.mjsEngine area + trace pages; exports TRACES, BuildEngineDocs
scripts/build-blender-docs.mjsBlender area + trace pages; exports AREA_PAGES, TRACES, BuildBlenderDocs
scripts/build-landing.mjsSearchable docs/index.html; exports BuildLandingPage
scripts/docs/prose/manifest.mjsProse chapter registry (output paths, prev/next nav)
scripts/docs/prose/content/Hand-edited HTML body fragments for prose chapters
scripts/docs/topics.mjsTopic hub categories, start-here links, page → topic map, diagram ↔ trace pairing
scripts/docs/diagram-links.mjsAuto Trace / Diagram meta rows on diagram nodes at build time
scripts/docs/shared.mjsDiagram shell read, page emit, nav HTML, symbol extraction
scripts/docs/engine-areas.mjsEngine area diagram data only
docs/_template/diagram-shell.htmlShared interactive viewer (CSS + JS)
docs/_template/prose-shell.htmlShared prose chapter layout (CSS + toolbar)

Common tasks

Regenerate after a code change

If you only changed implementation and trace symbols are unchanged:

npm run docs:build

Add an engine code trace

  1. Append an object to TRACES in scripts/build-trace-docs.mjs (id, title, intro, steps).
  2. Use { file: "packages/engine/…", symbol: "FunctionName", note: "…" } for live extraction.
  3. Run npm run docs:trace (or docs:build) and fix any MISSING errors.
  4. Optionally add a prose section in scripts/docs/prose/content/engine/10-FEATURE-TRACES.html.

The new page appears in the bottom Traces row on every diagram/trace page on that side. The landing page indexes it automatically. Matching diagram nodes gain Trace meta rows when their label/file overlaps trace steps (see node metadata below).

Add a Blender code trace

Same as above, but edit TRACES in scripts/build-blender-docs.mjs and use blender_addon/… paths. Run npm run docs:blender.

Add or edit a subsystem diagram

Adjust x/y for layout. Re-run docs:build. Nav labels come from navLabel (engine) or page.title (Blender).

Add a prose chapter

  1. Copy scripts/docs/prose/content/_FRAGMENT-TEMPLATE.html to engine/NN-MY-TOPIC.html.
  2. Append an entry to PROSE_CHAPTERS in scripts/docs/prose/manifest.mjs (wire prev / next into the chain).
  3. Add href → topics in scripts/docs/topics.mjs; link from 00-INDEX.html.
  4. Run npm run docs:validate then npm run docs:build.

Change diagram viewer UI

Edit docs/_template/diagram-shell.html, then npm run docs:build.


New feature documentation checklist

When shipping a user-facing subsystem or major feature, work through this list (small PRs per bullet are fine):

  1. Subsystem diagram — add or extend nodes in ENGINE_AREA_PAGES and/or AREA_PAGES (Blender side when authoring matters).
  2. Code trace(s) — append to TRACES in build-trace-docs.mjs and/or build-blender-docs.mjs; fix any MISSING: symbols.
  3. Prose — chapter section or new fragment under scripts/docs/prose/content/; register in manifest.mjs; add a row to 10-FEATURE-TRACES.html when it is a Blender → runtime chain.
  4. Cross-links — prose doc-links line pointing at the subsystem diagram + primary trace(s).
  5. TopicsPAGE_TOPICS and optional startHere in topics.mjs (also drives automatic diagram ↔ trace nav and node links).
  6. Search — synonyms in SYNONYMS (build-landing.mjs) and descriptive desc / note text on diagram nodes and trace steps.
  7. Reference — add rows to 13-FEATURE-LIST.html when shipping user-facing capability; extend 14-API-GUIDE.html when behavior authors get new APIs.
  8. Validatenpm run docs:validate then npm run docs:build (runs link check too).

What not to edit

These files are overwritten on every build:

Edit the sources instead: diagram/trace data in scripts/, prose fragments in scripts/docs/prose/content/. Generated HTML includes a footer pointing at the source fragment.


Viewing locally

Open docs/index.html in a browser (file:// or via a static server). The playground and launcher can serve /docs after a build. Diagram pages are self-contained single HTML files — no bundler required.


Related docs