Skip to content

feat: share the theme build flow in @wazoo/wiki/theme - #412

Merged
EthanThatOneKid merged 1 commit into
mainfrom
409-share-theme-build-flow
Oct 14, 2026
Merged

EthanThatOneKid merged 1 commit into
mainfrom
409-share-theme-build-flow

Conversation

@EthanThatOneKid

Copy link
Copy Markdown
Collaborator

What

The @wazoo/wiki/theme entrypoint now exports a whole-site driver for a custom theme, buildThemedSite, so a theme no longer reimplements the page loop. This is the engine half of #409; the wiki-templates wikipedia theme consumes it in the follow-on change (blocked on publishing this).

Before this, docs/build.ts (791 lines) and templates/wikipedia/build.ts (797 lines) differed by ~113 lines — the page loop, the token table, the infobox/categories/backlinks/TOC builders, and the metadata-panel emission were duplicated.

What moved

  • src/wiki/site/theme_build.ts (new) owns page walking, the page shell (TOC, infobox, backlinks, categories, metadata panels), %wiki.*% substitution, output writing, and asset copying.
  • The theme supplies only what actually differs between themes: layout files, assets, title_suffix, tokens (extra or overriding %wiki.*% values), and metadata (views, selected_view, note, highlight).
  • docs/build.ts drops from 791 to 93 lines and is now policy only: the two layouts, the - Wiki title suffix, and the two tokens that need a GitHub remote (edit link, redirect URL).
  • escapeHtml, safeJson, and substitute are exported so a theme can compose its own token values; the shell slot list is documented.

Decisions recorded once, in the shared contract

  • The xml metadata view is excluded by default. The reason (RDF/XML output is deferred while input is supported) is stated in the module doc, so themes stop rediscovering it. metadata.views re-enables it.
  • metadata.highlight returns HTML (escape the text yourself when the grammar highlights nothing); the default escapes the whole body. This is what lets the docs theme escape and the wikipedia theme highlight with Prism through one code path.
  • A token neither the engine nor the theme fills is left verbatim, so residue is checkable. The engine's built-in renderLayout still fills only three slots; buildThemedSite fills the full shell of nineteen. Both are documented as such.

Verification

Output-neutral by construction, and proven:

  • Built the docs site on pristine main into a baseline tree, then again after the refactor: 114 files, every SHA256 identical (Built 111 pages).
  • After the docs edits in this PR, re-built and diffed against the refactor-neutral tree: the only changed files are the two reference pages this PR edits. No structural drift.
  • deno check src/wiki tests docs/build.ts → exit 0
  • deno run -A src/wiki/cli.ts -c docs/wiki.yml fmt --check | lint --strict | check --strict | render --check → all exit 0
  • deno task fmt:check / deno task lint / deno task check → exit 0
  • deno task test → 569 passed, 1 ignored, 5 failed. The 5 are tests/verify_cli_test.ts (retired-Python-CLI-on-PATH and cutover-version cases); they fail identically on pristine main in this environment. The count is 569 rather than the previous 568 because this PR adds one test.
  • New test buildThemedSite owns the flow while the theme owns the vocabulary covers a minimal theme: custom layout, title_suffix, a tokens table, a highlight override, a redirect_layout, index filtering, asset copying, the xml-view default, and the verbatim-unfilled-token rule.

What I could not verify

  • The wiki-templates wikipedia theme's build against this surface. It pins the published package, so it cannot consume buildThemedSite until this is released; that refactor and its output comparison are the follow-on change (T5b), per AGENTS.md ("Bump pinned versions only after publishing").

docs/build.ts and the wikipedia template each carried a copy of the page loop, the token table, and the shell builders. buildThemedSite moves that flow into @wazoo/wiki/theme so a theme supplies only its layouts, tokens, and highlighter (#409).

docs/build.ts drops from 791 to 93 lines of policy. The docs site output is byte-identical: 114 files, every SHA256 unchanged.
@EthanThatOneKid
EthanThatOneKid merged commit ad4b2cf into main Oct 14, 2026
14 checks passed
@EthanThatOneKid
EthanThatOneKid deleted the 409-share-theme-build-flow branch October 14, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant