mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
The docs site's 18 mermaid blocks are now drawn as SVGs before Hugo
builds the site, by docs/render-diagrams.mjs with pele 1.13.0, and
inlined by a render hook, so no page loads Mermaid's 5.5 MB script.
- docs/render-diagrams.mjs: finds each mermaid block in docs/content,
draws it with pele in Departure Mono at 14px (a measurer from the
font's metrics), and writes <key>.svg and <key>.json (its size) to
the git-ignored docs/.build/diagrams. pele draws edge labels,
messages and notes at round(14 * 0.875) = 12px with no option, so the
measurer gives that text its 14px width and the script rewrites
font-size="12" to 14 on each small-text group (pele-edge-labels,
-notes, -boxes, -frames); a guard fails on any such group without
font-size="12", or small text outside them, and a self-check, run
whenever there's something to draw, renders an edge label, a message
and a note and fails unless pele measured them at 12 and wrote their
group with font-size="12". It also fails on a diagram without
accTitle and accDescr, or on an indented block. A newline after each
</text>, outside any text element, lets the search index see labels
as separate words; screenshots of all 18 are byte-identical with and
without it. (Newlines between a label's tspans would move centered
lines, so a label's own lines stay joined in the index.)
- Caching: a block's key is sha256(salt + "\n" + text)[:16], the salt
being sha256("pele <version>\n" + the script's text)[:16], written to
diagrams/salt. The script keeps every drawing already there, draws
only missing ones (written to .tmp and renamed), prunes files no key
names, and touches the folder. docs:diagrams has sources (the pages,
the script, package.json, the lock) and outputs (the folder), so mise
skips an unchanged run, and runs npm ci only when the lock's SHA-256
differs from docs/node_modules/.devvm-lock-sha256. An unchanged run:
0.45-0.75 s before, 0.02 s now (0.09 s forced); one diagram changed:
0.09 s. CI's check job caches ~/.npm keyed on the lock; the Docs
workflow, which publishes, keeps no cache.
- docs/package.json and package-lock.json pin pele 1.13.0
(sha512-Ie8UKY9x00MsuR3jO6AzUwzK2Z6MIV3Tf4EDdITiuk8Uaz8K7g0R082WqsqNaSU8DdgkrRvZThzhit83mi/uiw==).
- docs/layouts/_markup/render-codeblock-mermaid.html: in place of
Hextra's hook, reads the salt, computes the key from it and .Inner,
inlines the SVG from assets/diagrams (hugo.yaml mounts .build/diagrams
there), sets the wrapper's contain-intrinsic-block-size to the
diagram's height and --devvm-diagram-width to its width, and errorf's
when a drawing or the salt is missing. layouts/_partials/scripts/
mermaid.html and params.mermaid go.
- custom.css: .devvm-diagram with content-visibility: auto, and pele's
--pele-* variables from the palette (subgraphs, lifelines and notes in
the border color). A diagram wider than the text reaches into the
article's right padding (1.5rem, 3rem from 768px) as far as it needs,
then into the left padding for the rest, so it never covers the table
of contents; wider than both, it scrolls. From about 1010px no diagram
scrolls, the four wide ones included (proxy checks 751px, agent store,
VM states, SSH agent); at 900px five scroll. With the table of
contents shown, the proxy checks take 48px on the right and 31px on
the left.
- mise.toml: docs:diagrams, which docs and lint:docs depend on.
docs.yml: the next and release jobs install node and draw the
diagrams; the release job only when the tag has the script, so older
tags still build.
- scripts/bump.sh: bump_pele, named only, replaces bump_mermaid: npm
install --save-exact --ignore-scripts in docs, then mise run
docs:diagrams, whose self-check catches a pele that changed how it
draws small text. TestBumpCoversPins finds docs/package.json's
dependencies (npm:NAME); bump.txtar tests --check and the install.
The header and hextra's note say the mermaid render hook replaces
Hextra's mermaid hook, so check it still has that name.
- Every diagram gets an accTitle and accDescr, which pele makes the
SVG's title and desc (aria-labelledby, aria-describedby). Staying
safe's columns are written in reading order, as pele lays subgraphs
out from left to right. The proxy checks' description names every
branch, and a hand-placed <br> keeps "CA)" off a line of its own.
- AGENTS.md: the one Node script; no other build script is JavaScript,
and no other npm package is installed outside mise's tools.
Contributing's docs, tools and
maintaining pages describe the drawing, the caching, the margin, the
task and the bump.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
9 lines
266 B
JSON
9 lines
266 B
JSON
{
|
|
"private": true,
|
|
"description": "The docs site's build: render-diagrams.mjs draws its diagrams with pele. Installed with npm ci by mise run docs:diagrams; scripts/bump.sh pele moves the pin.",
|
|
"type": "module",
|
|
"dependencies": {
|
|
"pele": "1.13.0"
|
|
}
|
|
}
|