Repository navigation
Description
Goal
Give document-oriented consumers an opinionated, opt-in Typst setup. It has three parts: a house style that makes good layout the default, guards that reject bad layout and usage, and a reproducible build. Today the docs module only puts the binaries on PATH (#1993 moves them to unstable). Every consumer rebuilds templates, recipes and CI on its own, and nothing checks typstyle formatting or figure and table rules.
Everything here is opt-in and turns on with modules = [ "docs" ] or a sibling docs-guards knob. Nothing changes for non-document consumers.
Design (proposal: review before building)
1. House-style package (good layout by default)
A neutral, unbranded Typst package that the docs module ships. It is exposed through TYPST_PACKAGE_PATH as @local/devkit-docs:<ver> and versioned with devkit. Branding comes in through parameters: colours, logo and labels.
- Page and text: a
#show: document.with(meta)show rule. It must be a show rule, not a plain function call, so itssetrules actually apply. It sets page, margins, a type scale, heading numbering, and a running header and footer with a commit stamp from--input rev=. - Tables, booktabs style: a show rule on
table. It draws rules above and below the table and under the header, and no vertical rules. The header row is bold and repeats on each page, and number columns align. Plain#table(...)gets this automatically. - Figures: captions at a fixed size and width; table captions go above, other captions below. A
fig(...)helper refuses to draw without a caption. - Diagrams: fletcher (and cetz) pinned and vendored into the package path, so documents import a known version and nothing is fetched from the network at build time.
- Plots: a native-plot helper on lilaq or cetz-plot that takes its text sizes from the document's type scale and refuses to draw without axis labels. For matplotlib or other external figures, ship a style file whose font sizes match the scale, so text is readable when the figure is placed at column width.
- Components: callouts (note, warning), a revision history table, a title page, and a 16:9 slides layout.
- Fonts: bundled through
TYPST_FONT_PATHS, and builds run with--ignore-system-fonts, so output never depends on the host's fonts.
2. Guards: opt-in prek hooks plus a CI job
| Guard | Mechanism | Fails on |
|---|---|---|
| format | typstyle --check, plus a typstyle.toml (line width) |
unformatted .typ |
| compile | typst compile --root . --ignore-system-fonts on every entry document, with warnings as errors; templates compile to /dev/null |
broken docs, missing imports, warnings |
| figure captions | typst query <doc> "figure" → JSON |
any figure without a caption |
| table headers | typst query on table / table.header |
tables without a header row |
| house-style bypass | a source scan of entry documents | direct #set text(font: ...) or #set page(...) outside the package |
| package pinning | an import scan | unpinned or non-vendored @preview imports |
| figure font size | parse SVG figures (smallest font-size × the placed scale) |
text below the readability threshold. Raster charts can't be checked, so the guard requires SVG or native plots for charts. |
| built output | path check | committed generated/*.pdf |
Axis labels are enforced through the plot helper, which refuses to draw without them, because labels inside an arbitrary image can't be checked reliably.
3. Reproducible build: just recipes plus a CI pattern
just typst: compile all entry documents to a siblinggenerated/. It runs with--root .,--ignore-system-fonts, a fixedSOURCE_DATE_EPOCH,TZ=UTCand arevstamp, plus optional--depsoutput. The skip list is configurable.just typst-canonical: a build without the stamp, so outputs can be compared by hash.just typst-probe: prints the toolchain identity as JSON.- CI: compiling is the required check. It uses the
--depsdata to pick which documents a PR affects and uploads the PDFs as an artifact. PR previews pushed to a throwaway ref are optional, and are a later phase.
4. Written rules
A typst skill or doc in the scaffold that explains the conventions above, so people and agents write documents the same way.
Phasing
- Guards that need no package: format, compile, generated-PDF, package pinning. Plus the recipes and fonts.
- The house-style package: page, tables, figures, callouts, slides, and vendored fletcher/cetz.
- Content guards: captions, headers, bypass and SVG font size. Plus the plot helper and the matplotlib style.
- CI preview pipeline (optional).
Out of scope
Controlled-document machinery: document registers, reviewer rosters, issuance and releases, provenance locks. It stays consumer-owned until a second consumer needs it.
Open questions for the owner
- Fonts: which families? This is a licensing question too.
- Default paper size (A4?) and margins.
- Plot backend: lilaq vs cetz-plot.
- The figure font-size threshold: for example, at least 7 pt at final placed size.
- Is the slides layout in scope for phase 2?
Activity
gerchowl commentedon Nov 3, 2026
Addendum: a terminology register (glossary and part definitions) with a consistency check
Problem: across a document set, the same part, component or concept gets several names, and authors (agents especially) invent new names for things that already have one. Nothing catches this.
Source of truth: one machine-readable register per repo
glossary.yaml(or TOML). Typst reads YAML, TOML and JSON natively (yaml()), and people edit it easily. JSONL suits append-only logs better than a list someone curates.id, the stable key;term, the canonical spelling;definition;kind(term, part, component, acronym, role);aliases, accepted variants;forbidden, deprecated or wrong names, each with the replacement;part-numberor pattern;status(active or deprecated).Using it in documents (house-style package)
#term("id")renders the canonical term. On first use it can also expand an acronym and link to the glossary entry.#glossary()renders the appendix from the register, listing only the terms the document actually uses. Build it on the glossarium package or something equivalent.Checks
#term()ids must exist. The compile catches this, and so does atypst queryon term metadata.forbiddenvariant is rejected wherever it appears in source text, and the error names the replacement.Phasing
This fits phase 3 (content guards). The register file, the schema and the forbidden-variant hook could ship earlier, because they don't need the Typst package.
gerchowl commentedon Nov 3, 2026
Owner decisions (2026-11-03):
--ignore-system-fonts. Nothing bundled. A font-path hook stays available for branding.fix(docs): isolate the canary cache with PREK_HOME
test(docs): add Typst guard canaries
feat(docs): add Typst execution primitives
test(docs): cover opt-in hooks and Typst recipes
feat(docs): activate Typst guards and reproducible recipes
test(docs): preserve Typst skip globs across upgrades
fix(docs): retain skip globs during scaffold upgrades
fix(docs): isolate the canary cache with PREK_HOME
test(docs): add Typst guard canaries
feat(docs): add Typst execution primitives
test(docs): cover opt-in hooks and Typst recipes
feat(docs): activate Typst guards and reproducible recipes
test(docs): preserve Typst skip globs across upgrades
162 remaining items
fix(typst): resolve font shorthand and scope source placements
test(typst): cover markup boundaries and bounded SVG work
test(typst): distinguish argument code from caption markup
fix(typst): preserve markup boundaries and bound SVG traversal
test(typst): preserve qualified inline call arguments
fix(typst): retain code inside qualified inline calls
test(typst): cover scanner boundaries and runtime style bypasses
test(typst): bound CSS work across reused SVG definitions
fix(typst): preserve lexical modes and verify effective house style
test(typst): retain released package and cover custom page headers
fix(typst): keep page probes independent of headers
feat(docs): add opt-in Typst content guards (#2019)
gerchowl commentedon Nov 4, 2026
Delivered on dev for the next minor:
@local/devkit-docs: core in feat(docs): add an offline Typst house-style package #2015 (0.1.x); plots, glossary helpers and slides in feat(docs): add offline plots glossary helpers and slides #2017 (0.2.0).Open follow-ups: #2016 (devkit-docs module clash edges) and #2022 (content-guard edges).
chore: release 1.19.0 (#2033)