Repository navigation
Add a JS plugin loading mechanism and decompose scripts.html - #2788
Merged
chalin merged 12 commits intoSep 2, 2026
Merged
Conversation
- Pins the rendered post-footer script region and the js/main.js bundle, under two fixture configs (theme defaults; every offline-safe loading mechanism lit), ahead of the scripts.html decomposition - Whitespace- and fingerprint-name-insensitive comparison, so only real behavior changes go red
- Splits the loading mechanisms into
scripts/{main-bundle,plantuml-deflate,code-copy,algolia,tabpane-persist}.html,
leaving scripts.html a ~20-line dispatcher; no behavior change
(scripts-golden net unchanged)
- Each sub-partial is now independently overridable, and the dispatcher is
the seam the plugin loop lands in
- Emits registered plugins from assets/js/plugins/ (theme, project, or module mounts; union-FS shadowing applies), each built individually with js.Build; options travel as params -> @params - Registry entries carry enable/defer/pageGate; pageGate generalizes the mermaid/katex .Page.Store gating so a plugin ships only on pages using its feature - Companion conventions: scripts/plugins/NAME.html renders after the plugin's script tag; assets/scss/plugins/NAME.scss ships through the SCSS pipeline, linked before it - Warns (suppressible id) when a registered plugin has no matching asset - Acceptance test: a fixture project adds a plugin with zero layout overrides
- A fixture plugin must actually execute (window flag + DOM mutation + @params delivery) in a real browser: static markup checks can bless a broken runtime - Red-proof built in: a deliberately broken plugin's error must be the collector's exact tally, so an empty tally can't false-green
4 of 6 tasks
- Emits plugin companions (partial, stylesheet) before the script tag, so a synchronous plugin script can rely on companion-provided libs and markup - Compares the main.js bundle golden byte-exactly (normalize collapsed whitespace inside JS strings, a false-green path) and lights Algolia in the featureful fixture (a changed mechanism the net did not cover; output verified byte-identical to main's rendered define) - search.md: points the Algolia override at the new scripts/algolia.html partial (the documented algolia/scripts.html path never worked: the inline define always won) - Rephrases absence assert messages in the repo's affirmative style
All fixes pinned red-first (6 new tests red on the prior loop): - Guards the registry read: a scalar params.docsy no longer breaks the build (the namespace is new; unopted sites must be untouched), a non-list plugins value warns, a bare-name entry is shorthand, and a nameless entry is skipped with a warning - Fingerprints plugin builds in every environment: distinct builds of one source (per-language options, duplicate registrations) published to the same dev path, last write winning site-wide - Warns about a missing plugin asset independently of its pageGate, so a config typo surfaces even when no page sets the flag - Adds a dispatch net for the .Page.Store-gated legacy partials (mermaid, katex) via offline marker overrides, and pins stylesheet-before-script companion order
- Extracts head.html's algolia/head define into a real partial, making search.md's documented override path work (an empty site copy was silently ignored: the inline define always won) - Wires update:scripts-goldens into update:goldens, so a full golden refresh can't silently skip the scripts net - Strips integrity attributes in the golden region comparison (content- addressed, same as fingerprint names; bundle bytes and CDN versions are pinned elsewhere) and corrects the normalize rationale - Prunes cSpell ignores to words the project dictionary lacks, and trims stray indentation from emitted plugin markup
- Coerces plugin names to strings throughout the loop: YAML auto-types `name: 2048` to an int, which broke the asset lookup and garbled the missing-asset warning (pinned red-first) - Invokes companion partials with (dict "Page" ... "Plugin" ...): entry options were unreachable from companions, and the context shape freezes at release (pinned red-first) - Replaces the fixed-path zero-output asserts, which could never fail against fingerprinted output, with published-dir inspection - Narrows the golden integrity-strip to sha256 fingerprints, so the region goldens keep pinning CDN SRI hashes
- Replaces literal em-dashes in test comments with plainer marks - Prunes test headers and comments that restated the loop contract or the adjacent code; the contract's home is the plugin loop's header - Points the golden refresh cue at the npm script
- Golden test header defers fixture and comparison detail to the lib that owns it, dropping a stale byte-identical claim and spike-era naming
- Byte-pins click-to-copy alongside main.js: the region comparison strips fingerprint names and sha256 integrity, so a content change to any locally built script could pass unpinned (reviewer-reproduced); the byte-golden set now derives from the page markup, with a stale-golden guard for configs a script is absent from - Warns on falsy scalar params.docsy.plugins values too: `plugins: false` slipped past the `with`-guard silently (pinned by a new test) - Stores region goldens in canonical form (no trailing whitespace, final newline): the comparison is whitespace-insensitive, so the stored bytes only tripped `git diff --check`
chalin
added a commit
to chalin/docsy
that referenced
this pull request
Sep 4, 2026
The four queued 0.18 lines (docsy#2780, docsy#2787, docsy#2788, docsy#2790) stay queued for a CL-touching PR of their own; the release-prep coverage ledger keeps them as todo.
chalin
added a commit
to chalin/docsy
that referenced
this pull request
Oct 7, 2026
0.17's guide listed two override paths the theme never read (Algolia was inline defines); docsy#2788 made them partials, one at a new path. The gate names the readers who followed the docs; the details row records the path move.
chalin
added a commit
to chalin/docsy
that referenced
this pull request
Oct 7, 2026
…follows The speaker-page URL no longer resolves; the Sched session page does. The cache also gains the docsy#2788 entry the changelog's Algolia line needs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_partials/scripts.htmlinto per-feature sub-partials behind a small dispatcher:algolia/headandalgolia/scriptsdefines become real partials, making the documented override paths work; Add a JS plugin loading mechanism #2789 tracks the upgrade note for the removed template namesparams.docsy.pluginsentries emit scripts fromassets/js/plugins/(union-FS shadowing applies), each built withjs.Buildand fingerprinted in every environment:params->@params;pageGategeneralizes the mermaid/katex.Page.Storegating so a plugin ships only on pages that use its featurescripts/plugins/NAME.htmlpartial (invoked with the page and the registry entry) and ascss/plugins/NAME.scssstylesheet through the SCSS pipelineparams.docsyvalue are untouched