Skip to content

Mermaid: convert to a registry plugin; add plugin options - #2823

Merged
chalin merged 20 commits into
docsy:mainfrom
chalin:chalin-m24-mermaid-refresh-2026-0920
Sep 21, 2026
Merged

chalin merged 20 commits into
docsy:mainfrom
chalin:chalin-m24-mermaid-refresh-2026-0920

Conversation

@chalin

@chalin chalin commented Sep 20, 2026 •

Copy link
Copy Markdown
Collaborator
  • Contributes to Add a JS plugin loading mechanism #2789
  • Scope:
    • Mermaid onto the plugin registry: a deferred entry with an explicit start, a companion for the pin check and the config block, a shim for the gate, _defer and the settings
    • Plugin options: a reserved, plugin-owned string field; Mermaid takes the mermaid.initialize() object as JSON
    • params.mermaid and params.markmap refused, any key (breaking)
    • Consumer parity verified on opentelemetry.io: no rendered change outside the script region vs main; none in the browser vs 0.17.0, light and dark
    • Docs per content placement: UG current behavior, post migration, project pages rationale
  • Out of scope:
    • Mermaid 12 adoption and its dark mapping: Upgrade to Mermaid 12 #2825
    • Mermaid 9 compatibility: dropped, run() is 10+
    • Ungated loading and the section-print gap: pre-existing, reconsidered at 0.18's tail
    • Vendoring, code splitting, and the loop delivering options to scripts: deferred
  • Where to start: theme/data/docsy/schema/params/docsy.yaml, then the three Mermaid plugin files under theme/layouts/_partials/scripts/plugins/ and theme/assets/js/plugins/mermaid.js; tests/visual/mermaid-runtime.test.mjs proves the transport end to end; design page § Registry shape holds the options rationale
  • Consumer-visible changes, all in the post: the two namespaces fail the build; pins below Mermaid 10 no longer render; the inline module became a deferred same-origin entry (CSP)
  • History: the first four commits are the analysis spike's, cherry-picked
  • Previews:

- Replaces the dispatcher's hard-wired `scripts/mermaid.html` with the three plugin files: a deferred entry that imports Mermaid dynamically and starts it explicitly, a companion carrying the pin check and a JSON config block, a shim gating on the render hook's flag and aliasing the deprecated `params.mermaid.version` (MarkMap's pattern)
- Explicit `run()` at or after `load`: a dynamic import can settle past Mermaid's load-bound auto-start, so auto-start is timing-fragile for a deferred entry (startup-contract evidence)
- Theme-change observer installs before any await so a toggle during a pending render is not missed
- Pin moves to the registry entry; the `mermaid-floating-version` id is unchanged since the loop warns under it
- Nets: pin canary follows the read; the dispatch net drops mermaid (katex stays); a `mermaid-plugin` fixture covers gate, pins, deprecation, print gap, and a stale dispatcher override
- Network-tier probe with the real companion: per-language params reach Mermaid re-cased (viewBox differs), a hook-emitted fence renders, and the entry is the only script (no inline module, no cross-origin tag)
- Holds `load` behind a pending image so the CDN import settles first: proves the explicit start still waits, and that a theme toggle mid-render reloads
- Red-proofed: both timing probes fail against an entry without the wait and the observer
- Adds a "Mermaid version" subsection (the target of the deprecation warning's link) and the plugins table row
- Trims Mermaid from the params.PACKAGE.version list, now KaTeX and Redoc only
- Entry selects the typed config block (`script#docsy-mermaid[type=...]`): Goldmark hands a `## Docsy Mermaid` heading the same id, which hijacked the config (r1.1)
- Entry falls back to `init()` so Mermaid 9 pins keep rendering; `run()` is v10+ (r1.2)
- Shim trims the legacy pin and aliases it on flagged pages only, where 0.17 read it: a stale pin on a diagram-free site stays inert (r1.3, r1.4); range pins stay rejected, documented in the UG note
- Runtime net syncs on network idle with the held image pending, so a slow chunk can't false-clean the load-wait probe; healthy pages count diagrams, not SVGs (Mermaid renders errors as SVGs too); 9.x and heading-collision cases added (r1.5, r1.6)
- Fixture net: companion-absence regex matched nothing the stub emits; labels per the tests standard; spelling assertions cut (r1.7-r1.9)
- Quality inventory lists the two suites; link cache seeds their not-yet-live URLs (r1.10)
…ases

- Drops the Mermaid 9 init() fallback: 0.18 supports the pinned 11.x (changelog § Official support); pins below 10 now render nothing, with the failure logged
- Makes the runtime net's `en` language the hostile consumer otel.io isn't: a whitespace-padded legacy pin that must win, trimmed, alongside the existing per-language setting, heading-id collision and body-end fence
- Replaces the 9.x case with the experimental 12.x one: renders under Mermaid's new defaults and dark differs from light, nothing tuned
- Strips the SVG's per-render id before comparing light and dark styles, in both nets: Mermaid scopes its styles under it, so the old comparison could never fail
- States the support policy in one home, changelog § Official support (script dependencies at their pinned versions), and has the UG's Mermaid version section route there: pins below 10 don't render, 12 pins are experimental
- Adds the Mermaid items to the 0.18 changelog entry and post (pin's move, override path, CSP consequence of the inline module's departure)
- Updates the design, implementation, quality and maintainer pages for Mermaid as a plugin: shim-read gate, companion's CDN check, the nets' hostile consumer and 12.x case
@chalin
chalin requested a review from a team September 20, 2026 10:54
@chalin chalin added this to the 0.18.0 milestone Sep 20, 2026
@netlify

netlify Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for docsydocs ready!

Name Link
🔨 Latest commit e7a8ecf
🔍 Latest deploy log https://app.netlify.com/projects/docsydocs/deploys/6ab10e3791c0cf00082d3afc
😎 Deploy Preview https://deploy-preview-2823--docsydocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

- Drops the pre-0.18 migration note: history and upgrade guidance are the post's (its plugins item already carries them); the deprecated param keeps one current-behavior line, as the MarkMap section does
- Links Mermaid 12's release notes instead of restating its defaults
- Moves the turn-off sentence up to where the section explains automatic enabling, so the subsection is about the version only
…vior

- Same placement rule as the Mermaid section: history and upgrade guidance are the post's, the guide describes Docsy as it is
- The post's MarkMap item, which delegated legacy behavior to the note, now states it
- Drops the support sentence (the changelog's § Official support owns it) and the effective-pin troubleshooting line
- Moves the below-10 and Mermaid 12 statements to the post: they are about versions at this release, not evergreen behavior; the changelog's experimental bullet points there
- Fails the build on `params.mermaid.version`, on any page, naming the registry field to set: a pin is a value the site moves once, while the alias needed a precedence rule the guide then had to explain
- Drops the alias machinery with it: trim, flagged-page scoping, the `docsy-mermaid-legacy` warning; the offline net's two legacy cases now assert the refusal (red-first against the alias shim), and the runtime net's hostile consumer loses the padded pin, which had nothing left to prove
- Records the rule at the implementation page § Shims; changelog lists the removal as breaking, the post says what to do
- Applies the same rule as Mermaid's to `params.markmap.version`, so 0.18 treats legacy version pins uniformly: a build error names the registry field; the `enable` alias stays, being behavioral
- Offline net: the two legacy-pin cases assert the refusal (red-first against the alias shim); the legacy spellings leave the version-syntax cases, which now cover the entry alone
- Post merges the two pins into one upgrade item; UG loses the effective-pin troubleshooting line
- Widens the entry's try to cover the config parse, the import and initialize, so a blocked CDN or a bad setting logs instead of rejecting unhandled (r1.3)
- Guards the js-runtime dark check against running without its light capture (r1.14)
- Trims shim and test comments to purpose plus pointer; the rationale lives on the project pages (r1.11, r1.15, r1.16)
- Docs per content placement: changelog in past tense and what-changed only, the post's other-pins item split by pin class, the UG names the registry path its override lives under, project pages lose restated how and history (r1.1, r1.2, r1.5, r1.8, r1.17-23)
…tring

- Reserves `options` in the entry schema as an opaque, plugin-owned field: the loop neither validates nor transforms it and passes it to the shim and companion unchanged, so a plugin chooses its own shape
- Mermaid's `options` is the `mermaid.initialize()` object as a JSON string, decoded by the shim (build error for a map, malformed JSON, or a non-object); Hugo lowercases map keys at every depth with no opt-out, and the old defaults-walk re-casing could not recover a fifth of Mermaid 12's schema
- Refuses the retired `params.mermaid` and `params.markmap` namespaces outright (any key, any page), replacing the per-key refusals and MarkMap's `enable` alias, so every migrated package has one home
- Drops the runtime re-casing (`norm`) and with it the array/null mangling (r1.10); the runtime net's per-language geometry check now proves the options transport end to end
- Nets: red-first cases for the options contract and the namespace refusals; the loop test that pinned `options` as retired now pins it as reserved
- Design page's registry section states the rule and the rejected alternatives; implementation § Shims covers refusal and decoding; quality page lists the new cases
- Plugins guide: `options` in the configuration reference and a "Plugin settings" section for authors (why a JSON string for case-sensitive libraries)
- UG: "Mermaid settings" replaces the `params.mermaid` example with the entry's `options` string in the three config formats; post and changelog carry the namespace removal and the migration by key
…n pause

- Mermaid's shim decodes `options` first and dispatches on the result: Unmarshal already rejects maps and lists, maps empty and null to nil, and reports parse positions, so the type ladder goes and every non-string value now fails the build (r2.1, red-first)
- Implementation § Security states the vendoring exception Mermaid is (CDN import at runtime by design; SRI covers Docsy's entry), and § Shims separates namespace refusal from options decoding (r2.4, r2.17)
- Post: CSP action gets its own condition, the re-casing claim names what the old map actually lost, the Mermaid 12 item carries the Safari floor (r2.5-7); changelog back to past-tense what-changed and its support intro says pinned versions (r2.18, A4)
- Plugins guide reconciles "unchanged" with the shim's decode; UG and design overview lose restated rationale; quality page splits its two Mermaid bullets into coverage, boundary, safeguards (r2.3, r2.11, r2.14-15)
- Entry, shim and companion comments trimmed to what the code can't say (r2.9-10)
… net trims

- Points Renovate's custom manager at the pin's new home; a pins-test canary now ties every pin row to its manager string, red before the fix (r3.1, r3.10)
- Schema documents `options` as a string whose format and validation are the plugin's; the design page names the loop guard or decode as the follow-on when a second plugin takes options (β)
- Shim error leads with what the value must be and carries the decoder's reason without the template chain; the companion fails on options that reach it undecoded instead of falling back to defaults, so a from-scratch shim override can't silently drop a site's settings (r3.2, r3.3, red-first)
- Reload observer acts on a changed `data-bs-theme` only, not a same-value write (r3.8)
- Nets: MarkMap refusals table-driven on the four distinguishing inputs; options rows deduplicated; the no-fetch case runs the real companion under a remote deny list; an environment-override case for options; shared visual helpers hoisted; waits target the asserted DOM state, which `networkidle0` had been masking (r3.11-12, 14-20)
- Docs: UG failure rule and TOML literal string, post rows for `params.mermaid.enable` and the split override, quality coverage (r3.4-7, r3.22)
@chalin chalin mentioned this pull request Sep 21, 2026
3 tasks
… rationale

- Shim sets `options` to nothing on every path but a decoded object, so the companion's undecoded guard fires only for a shim override that skipped the decode; a real-companion case under a remote deny list pins the error count (r4.1, red-first); the decoder's reason loses Hugo's pseudo-filename prefix too
- Config block carries a `data-docsy-plugin` attribute instead of a fixed id, which a heading could duplicate (r4.3); the reload observer compares rendered darkness, so attribute churn that doesn't change the theme no longer reloads (r4.2)
- Design page gains the start-timing rationale that lived only in entry comments, and lists the rejected `options` alternatives one per item; the entry's header becomes purpose plus link (r4.7, r4.18)
- Docs converge on one home per fact: the lowercase-keys rationale (design), the shim's job list (implementation), the Mermaid nets (quality, safeguards under red-proof rationale); UG names the dark-mode override and the hidden markup after turn-off; post tense and examples corrected; changelog cites docsy#2825; maintainer notes cover the Renovate canary (r4.4-6, 8-15, 17-22, 24, 26)
- Comment trims and header rewraps (r4.23, r4.30)
@chalin chalin changed the title Mermaid: convert to a registry plugin Mermaid: convert to a registry plugin; add plugin options Sep 21, 2026
- Breaking bullet names the inline module's replacement by a deferred same-origin entry, the one fact behind the post's CSP item
- For maintainers: the pin's move with its Renovate row, the pins-to-Renovate canary, the two Mermaid nets
- Experimental line reduced to the declaration; the reference states that language-specific params apply to entries
@chalin
chalin merged commit 7c51194 into docsy:main Sep 21, 2026
14 checks passed
@chalin
chalin deleted the chalin-m24-mermaid-refresh-2026-0920 branch September 21, 2026 14:32
chalin added a commit to chalin/docsy that referenced this pull request Sep 21, 2026
…c; terser guards row

- docsy#2823's new script-version-pins check read `renovate.json5` by name and matched the JSON5 quote shape; it now reads `renovate.jsonc` and accepts either quote style around the JSONata keys (red on a stale mermaid path)
- The guards routing table row goes back to a route: inputs and comment details live in the audit's header and the Dependency updates bullet
chalin added a commit that referenced this pull request Sep 24, 2026
- **Scope**:
  - `renovate.json5` → `renovate.jsonc`: `configMigration` rewrites JSON5 without its comments, JSONC keeps them (renovatebot/renovate#38646); the script-version-pins test (#2823) reads the new file
  - actions looked up as GitHub Releases, each bump its own SHA-named PR outside the patch/minor groups; shape from chalin/link-cache#14, rationale in the [maintainer notes](https://deploy-preview-2821--docsydocs.netlify.app/project/about/maintainer-notes/#dependency-updates)
  - every action pin comment names its full release version (each SHA peeled to its Release tag); the supply-chain audit guards the shape
  - audit run-step deny-list also refuses `npm init NAME` and `npm create` (both run `npm exec create-NAME`); bare `npm init -y` stays
  - maintainer notes carry the rationale, the Releases requirement for new actions and the guards table; stale comments trued there, in the publish/smoke workflows and in the audit test
- **Out of scope**:
  - docsy-example: follow-up PR, same shape
  - enabling the Renovate app on the `docsy` org: owner step after both configs land
  - `.nvmrc` toolchain pinning, the config-validator one-liner in the maintainer notes, the Dependabot security-updates admin check: tracked separately
  - dependency bumps of any kind (the pending link-cache 0.5.0 included)
- **Verified** with renovate 44.82.5:
  - strict validator green
  - local dry run overrides every action lookup to `github-releases`, age-holds the one pending action update, and shows the groups holding only npm/nvm/pin deps
  - each pin's SHA peeled to its Release tag via the API (shared-workflows' is an annotated tag)
- **Preview**: https://deploy-preview-2821--docsydocs.netlify.app/project/about/maintainer-notes/#dependency-updates
chalin added a commit to chalin/opentelemetry.io that referenced this pull request Oct 7, 2026
…ease)

Pins the theme at docsy `main` (`7c511948`, the merged Mermaid plugin,
docsy/docsy#2823), ahead of the 0.18.0 tag. Re-points the submodule at
`docsy/docsy.git`, the theme's new home since the move out of the
`google` org.
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