Repository navigation
Plugins: convert markmap, tabpane-persist, and click-to-copy; reshape the registry - #2791
Merged
chalin merged 77 commits intoSep 5, 2026
Merged
Conversation
Plugin names address assets and partials by path: a ../-bearing name could target any assets-tree JS or any partial. Restrict names to ^[A-Za-z0-9_-]+$ and warn (warnidf) on violation, before the first theme-shipped plugin lands. Red-first: the traversal fixture failed before the allowlist, passes after.
- Moves markmap to assets/js/plugins/: options via @params instead of a template-wrapped bundle member; zero bytes shipped when disabled (main.js sheds the template-emptied stub) - Vendors markmap-autoloader through resources.GetRemote + fingerprint, served same-origin with SRI and deferred, replacing the no-SRI CDN tag; a companion partial (scripts/plugins/markmap.html) emits it - Aliases legacy params.markmap.enable onto a default registry entry for one deprecation cycle, with a warnidf deprecation notice - Migrates the version-pin canary to the companion partial, keeping the bare-read contract; drops markmap from the offline-safe goldens config (the vendor fetch needs network), covered by markmap-plugin.test.mjs
- Moves the script from static/js (raw, unconditional, on every page) to assets/js/plugins/, registered as a theme-default entry with a hasTabs pageGate set by the tabpane shortcode: fingerprinted with SRI, shipped only on pages using tabs - Retargets the npm-pack contract entry and the no-jquery static-JS scan (its only non-vendored member moved) to the plugins dir - Adds gating and union-FS shadowing tests
- Proves the registry serves plain imperative scripts: the copy-button script moves into assets/js/plugins/ as a theme-default entry, legacy gates (prism_syntax_highlighting, disable_click2copy_chroma) keeping their semantics - Reduces the code-copy partial to its prism branch, renamed scripts/prism.html to match - Golden diff documents the only behavior change: same deferred tag, emitted from the plugin loop under js/plugins/, now built with js.Build
- Implementation page: name allowlist rule, the theme-default/legacy-alias entries, and a security-constraints section (no safe* casts on Plugin.options; options ship world-readable; pin/vendor third-party code, pageGate remote-capable plugins) - Quality page: point the shadowing pin and the per-conversion nets at their now-landed tests
Routes the four queued lines (docsy#2780 scheduled link-cache workflow, docsy#2787 scripts.html uncache, docsy#2788 plugin mechanism, docsy#2790 project-docs re-home) plus this PR's own conversions line, per the 0.18 coverage ledger.
Theme-default plugins (click-to-copy) now publish under js/plugins/ on every build, so blanket no-plugin-output assertions went red for the right reason; narrow them to the fixture-declared plugin.
chalin
marked this pull request as ready for review
September 3, 2026 09:37
The three per-conversion test files go live on main only at merge, so their blob/main links 404 in this PR's CI link check; seeds them with the manual 206-with-expiry pattern. The changelog's PR links were verified live.
The site's legacy params.markmap.enable now draws the deprecation warning, turning the no-deprecations net red; migrate the site config to the registry entry (first dogfood of the mechanism).
The loop's trailing trim markers glued adjacent tags (script/link run-ons in rendered pages). Emits an explicit newline after each element, and guards the shape in the golden net: one script/link start per region line. Red-first: the guard failed on the glued defaults golden before the fix.
A site redeclaring a theme-default plugin (to reorder it or pass options) silently lost the fields it never set: tabpane-persist shipped ungated on every page, click-to-copy lost defer. Site entries now inherit their default's pageGate/defer unless explicitly set; the legacy prism/disable gates control auto-registration only, with a warning when a site-declared click-to-copy rides alongside prism. Also treats a quoted "false" enable as false. Red-first: four fixtures failed before the merge logic.
Enabled markmap shipped its plugin and vendored autoloader on every page, same as the pre-plugin CDN tag. A markmap render hook (mermaid pattern) sets a hasMarkmap Store flag and the default entry gates on it, so markmap code ships only on pages with markmap blocks; an explicit registry entry can clear the gate. Emitted markup keeps the .language-markmap shape the plugin script transforms (browser probe re-verified). Red-first: the no-markmap home page carried markmap scripts before the gate.
params.markmap.version lands in the GetRemote URL; a value like 0.18.12/package.json vendored an arbitrary registry file as JS (warn-only before). Refuse versions with URL-path characters before fetching, keeping the suppressible warning for floating-but-sane pins. Also documents the markmap defer hazard in the companion (a deferred plugin script would run after the autoloader and clobber its exports). Red-first: the injected version built successfully before the guard.
- Design page: describes the post-conversion mechanisms (plugins tier, vendored autoloader, gate placement); the loop is no longer 'planned' - User guide: markmap enable via the registry, legacy param marked deprecated, honest load story (build-time vendor + SRI; runtime libs still CDN), page-gating and no-defer notes - Changelog: override-point moves listed under Breaking with old-to-new paths; conversions line no longer overclaims 'instead of from a CDN' - Implementation page: scalar params.docsy line reflects theme defaults; supply-chain constraint names the residual markmap CDN exposure - 0.18 blog draft: jQuery override list points at the moved markmap path
Trims a review-thread reference from the allowlist test comment, raises the no-jquery plugin-scan floor to the three shipped plugins, and normalizes em-dash asides in branch-added prose and comments.
- The legacy params.markmap.enable alias registers markmap ungated, keeping exact pre-0.18 site-wide behavior: custom render hooks and raw markmap HTML never set the hasMarkmap flag; the registry entry stays page-gated - Warns (warnf) when a name is registered more than once: duplicate built-ins are not runtime-idempotent - The prism/click-to-copy conflict warning moves to emission, so disabled entries no longer draw it - Plugin-name presence, not truthiness, decides (name: 0 is a name) Red-first: four fixtures failed before the changes.
The tabpane shortcode set hasTabs before evaluating persist="disabled", so opted-out pages still shipped the persistence plugin. Red-first: the opt-out fixture carried the script before the move.
The package-root CDN URL resolves to a dynamically minified variant whose bytes can drift between builds; dist/index.js is the immutable published entry the package itself declares.
Narrows the zero-bytes claim to disabled integrations (click-to-copy is site-wide by default), extends the Breaking item with the stale-override failure modes, the page-gate flag contract for shortcode/render-hook overrides, and the build-time CDN access markmap now needs, and corrects code-copy.html's fate (replaced, not renamed). Test header stops claiming SRI for the autoloader's runtime fetches.
Print layouts render descendants' content into one page, but page-gated scripts key on Store flags each child set during its own render, read from the print page's Store: gated scripts never reached /_print/ output. A print/page-flags partial merges descendant flags onto the print page before scripts.html. Also covers the dispatcher's Mermaid/KaTeX Store gates, whose print gap predates this branch. Red-first: the print fixture carried neither tabpane-persist nor markmap before the merge.
…nters Upgrade actions (override moves, the page-gate flag contract, the security.http allowance) move from the changelog into the post, per the content-placement rule; the Breaking and New entries shrink to one-clause records with links. Adds the print-output fix line.
- Dash fixes in the changelog Plugins entry, the markmap default bullet, and test headers - Test and template comments trimmed to purpose lines and pointers; stale @requires names fixed - Truth fixes: the warnf exception to the warnidf-suppressibility claim, persist=disabled in the shortcodes guide, legacy markmap's site-wide loading qualified in the user guide - Descriptions on the script-loading pages cover the new scope; the diagrams-page description complements its title - Print mechanism homed on the design page; quality page lists the companion nets
A minimal user-facing home for the params.docsy.plugins contract (the changelog presents plugins as a user feature): file convention, registry declaration, and pointers. Full authoring docs are Phase 2 (docsy#2789), noted in-page.
The description edit landed without the website-workspace golden refresh, failing test:md-output.
- Ignores defer on the markmap entry with a warning: a deferred plugin
script runs after the deferred autoloader and clobbers its exports
- Companions emit once per name: duplicate registrations doubled the
vendored autoloader tag
- print/page-flags traverses the print section's subtree with no_print
pruning, mirroring print/render.html: the site-wide scan leaked flags
from pruned subtrees and scanned every page per print page
- enable strings compare case-insensitively ("False" disables)
- Two assert messages rephrased positively
Red-first: defer, duplicate-vendor, and no_print fixtures failed before
the fixes.
…eme plugin off Plugins load once: none of the theme plugins support a second instance, and no consumer need for one exists. The duplicate warning says so and points at one entry's options; docs and the always-fingerprint test stop describing duplicate registration as a supported shape (per-language sites justify the rule on their own). The user guide gains the enable: false recipe for theme plugins, pinned by a test.
…onversions-2026-0903 # Conflicts: # docsy.dev/content/en/project/about/changelog.md # docsy.dev/link-cache.jsonc
…rseded legacy param - The effective registry keeps the first registration of a name and drops later ones with the warning, so the message and the behavior agree (a second markmap script overwrote the autoloader hooks and bricked rendering); the always-fingerprint test moves onto its real vehicle, a two-language site - params.markmap.enable beside a registry markmap entry warns that the entry supersedes it and is page-gated: the silent behavior change sat on the exact copied-the-guide-kept-the-param migration path - Docs: load story corrected (build-time fetch like Mermaid and KaTeX, same-origin serve like KaTeX; the pinned-versions intro no longer lists the autoloader as a browser CDN load); the pageGate '' exception for self-emitted markmap/tab markup documented in the guide and the post; jQuery override list scoped to pre-0.18 copies; implementation contract records the defer override, companion-once, and superseded-alias rules; click-to-copy off-switch cross-linked; issue link dropped from the guide - Print net asserts the Mermaid dispatch the changelog claims Red-first: dup-once (generic and markmap) and superseded-alias fixtures failed before the changes.
"Look and Feel" (colors, fonts, code highlighting) was the wrong door for a script-loading mechanism, and the feature will grow. The section moves to docs/content/plugins/ with its own description; the copy-button, tabpane, post, changelog, and deprecation-warning links follow it, and the link cache seeds the page's own production URLs until the deploy.
…s recorded Review r33 (blank-slate + two-phase). The plugins page led with the custom script recipe and buried Docsy's own plugins in prose: it now opens with a table of them (default, where each loads, how to turn it off, where its docs are), then the two-step custom-script recipe in the three config syntaxes, then the advanced note on page flags in included content, which the copy-button, tabpane, and MarkMap sections link instead of restating. The MarkMap guide splits the `pageGate: ''` and `height` examples and owns the offline-build remedy; the post keeps the release delta and links. The design page records the gating decisions this PR settled (theme defaults gate on render-hook flags only; the markmap hook's default-render shape; section print as a known limitation), the implementation page the autoloader vendoring specifics and the version-string guard, the quality page the guards the loop net now pins.
Review r34 (two-phase). The plugins page's flag section restated MarkMap's authoring paths, which the MarkMap guide owns; it links them. The implementation contract said any non-false scalar warns, while the loop accepts the string "false" (any case): the contract says so and a test pins it (red without the string branch). The security constraint said third-party libraries are vendored while naming the autoloader's CDN-loaded runtime; it now separates pinning, build-time vendoring, and the loader rule. Prose: the plugins lead and the diagrams intro restated their descriptions; the design page told the conversion three times; two dense paragraphs (loop net, MarkMap version) become lists; a self-evident reassurance leaves the post; two comments restated their code.
…eep their why Review r35 (prose). Two of my earlier edits had landed wrong: "With MarkMap enabled" replaced the PlantUML section's lead, not MarkMap's; and the custom-script config tabs, nested in a list item, were collapsed by Prettier into invalid TOML and YAML (the ignore range doesn't hold there). Both fixed, the tabs moved out of the list. One home per fact: the flag-context mechanics live on the plugins page, the design page keeps the decision and links; the module-trust note moves from a rejected-alternative bullet to the security constraints; the post's print case folds into the MarkMap markup case (the guide names printed sections among the paths). The plugins page's description and lead no longer promise every JavaScript feature. Template and test comments that restated the code, the contract, or the warning text now carry only their why and a link.
… 0.18 The conversion had gated tabpane-persist on a `hasTabs` flag the tabpane shortcode set, so pages without tabs would ship no persistence script. Review r30 showed the flaw: a shortcode runs in the context of the page whose file contains it, so a tabpane in content pulled in through .RenderShortcodes flagged the included page and the including page lost persistence, silently. The theme default was ungated on 2026-09-04; the setter stayed as a documented site-side opt-in. It goes too: the theme doesn't read it, and the shape of `pageGate` itself is now a queued question, so landing an opt-in against today's contract is a second design. Net for tab persistence: 0.17 emitted the script tag on every page, and so does 0.18. What changes is the file's home (assets/js/plugins/), the tag (fingerprinted, SRI), and the build (js.Build, so the script's accidental globals are IIFE-scoped). tabpane.html is untouched by this PR.
The two registry-shape warnings narrated consequence and remedy in template strings, and said the theme plugins were "off", a word that reads as disabled when the registry simply no longer exists. Each now states the rule and the offending value and links the implementation page's Shape guards section, which owns what happens (no theme plugin loads; the deprecated parameters have no effect) and what to do. Same shape as the pinned-version warnings.
…iolation The plugin loop hard-coded the entry fields, their defaults, and the name rule, and the implementation notes carried a second copy as prose; the two drifted in review after review. The schema now lives once, in theme/data/docsy/schema/params/docsy.yaml: the loop reads it for defaults, the field allowlist, and the name rule, and the implementation notes include the file verbatim (a docsy.dev shortcode over an assets mount; readfile reads the real filesystem, not mounts). The theme's explicit module mounts had left data/ unmounted; it is mounted now. Every schema violation warns under one id, docsy-config, with one link, so a site silences the class with one ignoreLogs entry and the docs stop enumerating cases: Shape guards is three sentences and the user guide's warnings section is gone. docsy-plugin-missing stays apart: a conforming config whose asset is absent is a different fault. Found on the way: a site-set weight arrives as uint64 while the schema's default is an int, and Hugo's sort compared the mix as strings, reversing the order; weight is cast to int at normalization, and the order test caught it. Two tests pin the new contract: one id for four violations; every schema default reaches the entry (red when the loop ignores one).
The README mount already shows the pattern: mount the file under content/, read it with the theme's readfile shortcode. The purpose-built docsy-schema shortcode (HTML and Markdown variants) and its assets mount go.
Review r38. The schema's header narrated who reads it, how violations warn, and what the loop coerces, facts the loop's comment, the design page, and the implementation page own; it is one purpose line now, and the per-field comments stay as the fields' one description (the implementation page includes the file rather than restating them). "Every schema violation" overclaimed, since types are declared and coerced, not enforced: the loop, the design page, the tests, and the implementation page say "every configuration warning the loop emits carries docsy-config". The warning strings end the sentence before the pointer instead of a semicolon; the design bullet keeps its rationale and drops the mechanics; two test names say what their fixtures do.
readfile resolves against the project's union filesystem, so the theme's data/ mount is readable at /data/... with no site-side mount at all. The content mount goes: it published the schema as a page resource, and whether the schema gets a public URL is a decision to take on its own (path, versioning), not a side effect of how the docs include it.
The loop folded a quoted "false" (any case) into false for enable, defer, and a scalar entry: three case-folded string compares of a shape Hugo itself never uses. Hugo reads its own config booleans typed, and where a value can arrive as a string (shortcode args, env overrides of top-level params) its idiom is `in (slice true "true" 1)`, not a case fold. The registry is a nested map under a reserved key, not an env-override channel, so it reads typed: `false` is spelled `false`, a quoted "false" is a truthy string, and the coercions that remain each name their reason (boolean pageGate as "no gate"; weight cast to one integer kind for sort).
Probed on the owner's challenge to the typed read: HUGO_PARAMS_* can reach a nested registry key, but arrives as a string for a theme-declared key (the project holds no value to type it against), and cannot spell a hyphen at all: HUGO_PARAMS_DOCSY_PLUGINS_CLICK_TO_COPY_ENABLE lands on a stray params.docsy.plugins.click.to.copy key. Two of the theme's three plugins are thus unreachable, so Hugo's `in (slice false "false" 0)` idiom would fix markmap and leave click-to-copy silently on. The registry keeps its typed read; the implementation page states the limitation and the remedy (layer a config file); a test pins both halves (the hyphenated name untouched, the stray key reported by the missing-asset guard).
…mented A deeper look at Hugo's env parser (config/allconfig/load.go applyOsEnvOverrides) overturns the previous commit: the delimiter is the character after HUGO, so `HUGOxPARAMSxDOCSYxPLUGINSxCLICK-TO-COPYxENABLE` reaches a hyphenated entry with the hyphen literal. Environment overrides are therefore a real channel for every registry entry, and every value on it is a string for theme-declared keys (the override applies before the theme's config merges). That is the stringly channel Hugo's own `in (slice false "false" 0)` idiom exists for: enable, defer, and the scalar entry use it and its complement; any other spelling keeps the default. The implementation page states the encoding; the env test asserts a hyphenated plugin turned off and another deferred by override.
…e and pointers (r39) The click-to-copy and markmap shims and prism.html read their legacy params with bare truthiness, so an env override like HUGOxPARAMSxPRISM_SYNTAX_HIGHLIGHTING=false (a string) loaded Prism and dropped the copy button. All four reads now use `in (slice true "true" 1)`, pinned by two red-first env tests; the fixture shim follows. Docs: the impl page's boolean sentence claimed unrecognized spellings keep the default, but `enable` is off only for the false triple, so `enable: "False"` turns a default-off plugin on; state both field rules. Impl lead no longer routes diagnostics to the guide (the warnings link here); the guide's contract pointer names env overrides and the docsy-config warnings. Diagrams description no longer attaches "as code blocks" to KaTeX; markmap-version sentence de-duplicated; guide drops the pre-0.18 history clause; two test comments that restated their tests cut.
…n page for cross-cutting Hugo config The implementation page held the registry's config spec, warnings, file contract, and author security rules, while routing readers to a guide that had none of it. The audience test (site operator or plugin author vs. loop maintainer) sends most of it to the guide: - Plugins page: § Configuration reference (schema include, layering, spellings, § Warnings); under Add a custom script, § Plugin files (the file table) and § Security (F2/F3 and the pinning rules, which are for authors of companion partials, not loop maintainers). - New docs/content/configuration.md for what isn't plugin-specific: theme defaults and Hugo's merge, key spelling, environment variables (the delimiter and string-value facts), configuration warnings and ignoreLogs. The boolean-spelling rule stays scoped to the registry until the theme's other reads follow the idiom. - Implementation page keeps the maintainer residue: loop mechanics, shim ABI, build pipeline, and the security constraints Docsy's own plugins add on top of the guide's rules. The loop's warnings now link the guide's reference; the design page, implementation index, and diagrams page (the autoloader's runtime CDN loads carry no SRI) follow. Link cache seeds the new page's own URLs.
Hyphens pass through any env delimiter; only an underscore inside a key name needs a non-`_` delimiter (an earlier note said `HUGO_` "cannot spell a hyphen", a mis-read of a probe that had swapped the hyphen for underscores). The warnings section no longer advises silencing a class after one warning: fix first, then `ignoreLogs` the printed id; the Plugins page stops calling `docsy-config` the id of every registry warning (`docsy-plugin-missing` is one). Merge wording names Hugo's default deep-merge strategy; Boolean values get their own section; description leads with the page's payoff.
The implementation page's Loop mechanics section transcribed the template's own comments; it is now a pointer, and the page's description no longer calls a build-time loop a runtime contract. Build-and-emission keeps only its delta over the guide's file contract; the MarkMap CDN exposure, shim-deletion policy, and env-strings rationale each keep one home (diagrams, implementation, Configuration), with pointers elsewhere. Truth-ups: `sort` compares a mixed int/uint pair unsigned, not "as strings" (the weight cast stays, its reason corrected in the template comment); the null-registry warning names no remedy; a pre-0.18 `scripts.html` copy fails because scripts moved, not because of the decomposition. Guide: reference bullets stop restating the rendered schema; the warnings lead names its scope and what each guard drops vs ignores; SRI stated once. Configuration: `_merge: shallow` consequence; the delimiter example no longer leans on Prism's string acceptance. Descriptions lose their internal colon (the Markdown listing renders `Title: description`). Design names the surveyed theme. Comment and header pointers follow the move; the schema header is one line since it renders in the guide.
…(r43) - A `height` interpolated into the `<style>` text could close the rule and open its own; the rule is now a constant and the CSSOM drops a non-length, so the 300px default survives a bad value (also covers r30's `height: 400`) - Guide § Security gains the plugin-script rule (options are values, not markup); the diagrams page names the type - Docs no longer claim a missing asset "warns whatever its gate": a disabled entry is skipped before the lookup (pinned by a new test); the shim contract says merge over the entry received
- tabpane-persist.js: six section banners and six step narrations go; one why stays (activation order) - plugins.html: the string-tolerant boolean note moves to the normalization header, ahead of its first use; `weight: -1` arrives as int64, not int - Tests: js-runtime's probe banners no longer describe the tests under them (one cut, one rescoped to both conversion waves), the variant inventory that had started to rot is cut; no-jquery, markmap, and plugins headers say what the code does
…s (r45) - Table loses its "Turn it off" column: three copies of the rule the sentence below states once, plus a `persist=disabled` aside the shortcode page owns - Script path stated once (§ Plugin files, step 1 keeps its copy); the schema comment isn't paraphrased above its own rendering; `pageGate: false` leaves the docs (`''` is the one spelling, the loop still tolerates `false`) - Description pitches, no longer lists sections; lowercase-keys note moves to the author's section; remote-code rule says how a flag is set - Neighbors link instead of restating: impl § Shape guards, design merge parenthetical, the post's two mechanics restatements; lookandfeel's body-end hook routes script files to plugins; § Warnings homes "deprecated aliases included"
…arkmap (r47) - A site's `markmap: false` replaced the theme map; with the plugin on, the companion died on `.version` with Go's type error instead of its own "version is unset" guidance - Red-first test; the version-pin canary accepts the guarded assignment, the read stays bare and default-free
…to its guide (r46)
- Diagrams names the markmap render hook as the override point (its only current-state home was the post); lookandfeel's deprecation note gets its build-warning parity; Plugins § Warnings splits ignore from drop - Design drops its description's section inventory and says "site-wide" once; impl leaves fingerprinting to the guide's SRI fact - Two-colon sentences reshaped (Plugins step 2, the loop's normalization comment); two what-comments cut where the code or name is the home; tabpane test header loses its historical aside
4 of 6 tasks
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.
params.docsy.plugins;legacy params aliased for a deprecation cycle, so 0.18 breaks no site(the aliases were dropped before release: 0.18 refusesparams.markmap, see the 0.18.0 post)params.docsyschema shipped as theme data_partials/scripts/plugins.html;theme/data/docsy/schema/params/docsy.yamlis the one home for entry shape and defaults (the loop reads it, the guide renders it); per-plugin*_docsy-shim.htmlpartials hold legacy-param behavior and go with the deprecation cycle; why a map, and the rejected alternatives: design page § Registry shape