Repository navigation
feat(docs): add offline plots glossary helpers and slides - #2017
Merged
Merged
Conversation
15 of 23 tasks
gerchowl
force-pushed
the
feature/1994-typst-content
branch
from
November 4, 2026 01:34
036564f to
d197d29
Compare
gerchowl
added a commit
that referenced
this pull request
Nov 4, 2026
## Description Add docs-only content checks for missing figure captions, missing table headers, direct page/font overrides, and SVG lettering below 7 pt at its placed size. The shared hook supports skip globs and end-of-line suppression with source diagnostics. ## Type of Change - [x] `feat` -- New feature - [x] `fix` -- Bug fix - [x] `docs` -- Documentation only - [ ] `chore` -- Maintenance task - [ ] `refactor` -- Code restructuring - [x] `test` -- Adding or updating tests - [ ] `ci` -- CI/CD pipeline changes - [ ] `build` -- Build system or dependency changes - [ ] `revert` -- Reverts a previous commit - [ ] `style` -- Code style changes ### Modifiers - [ ] Breaking change (`!`) ## Changes Made - Add `typst-content` through the shared docs hook definition and portable asset; keep non-docs hook configuration unchanged. - Query compiled content once per entry in one shared ephemeral mirror, with source diagnostics and at most two compiler workers. Preserve native image values and validate a clean original compile before falling back from instrumentation failures or warnings. - Resolve literal and variable image paths relative to their containing source and retain generated assets. Honor table suppression without derived-table duplicates, detect multiline function/closure template overrides, and scope duplicate-label/fallback suppression to individual calls in dependency/document order. - Preserve markup and caption prose around inline expressions so grid/column measurements stay instrumented, while retaining multiline and imported closure checks. - Attribute logos only to direct document-template parameters and measure each logo/body placement independently; dictionary keys cannot supply logo attribution. Instrument only compiler-reported dependency sources with indexed scanning, linear edit assembly, and cached dependency-edge tokenization. - Measure SVG fit, nested SVG/symbol viewports, inherited font units, height-only sizing, visible text and used definitions. Resolve CSS font shorthand from Matplotlib 3.6–3.9 and the 3.10 font-size form with the normal cascade and `!important`; warn on unresolved sizes and bounded use expansion. Accept Matplotlib DOCTYPEs while blocking entities/external references; warn per placement for Typst scale transforms. - Ship package 0.2.1 with guard-only layout measurements for percentages, automatic sizing, grids, columns and figure bodies. Archive the exact shipped 0.2.0 source and retain historical imports and hashes. - Document fallback sizing, unresolved-size warnings, SVG limitations and suppression. Add a dedicated sandboxed compiler contract and a reproducible medium-document benchmark. - Track code and markup with one structural tokenizer, including multiline else chains, smart quotes, URLs, escaped hashes and qualified builtin calls. Reuse its modes, delimiters and comments for instrumentation. - Record effective paper, margins and font in guard-only package contexts at page starts and headings. Report runtime bypasses by page; document the entry-level runtime suppression marker. - Warn on incomplete CSS blocks and cap selector/node work at 1,000,000, including repeated reference visits. ## Changelog Entry ### Added - **Opt-in Typst content guards** ([#1994](#1994)) - Check figure captions, table headers, house-style overrides and SVG text below 7 pt at its placed size, with skip globs and source-line suppression. - Retain prior house-style imports and add 0.2.1 guard-only layout measurements without changing normal PDF output. ## Testing - [ ] Full local suite (`just test`); delegated to CI as required by the task brief. - [x] Targeted tests pass locally. - [x] Manual testing performed. ### Manual Testing Details - RED tests were committed before implementation. Scanner regressions, seven runtime alias cases, repeated-reference CSS work and replaced-header cases each failed before their fixes (pytest exit 1). - Targeted scanner, compiler contracts, guards, package integrity and docs scaffolding: 278 passed, exit 0. Final runtime and normal-output equality regressions after moving page probes into the background: 11 passed, exit 0. - Final `nix build .#checks.x86_64-linux.typst-content .#checks.x86_64-linux.typst-house-style --no-link --max-jobs 1 --cores 2 -L`: exit 0. Includes 115 content compiler contracts, 165 house-style tests, the remaining native/layout contracts and 21 killed style mutants. - Six content mutants killed: markup content inheriting code mode, logo closing-line suppression, reference-depth cap, inline-call adjacency, context introducer and direct template-logo attribution. Every mutant exits 1 on an explicit assertion or missing expected exception; the mutation harness exits 0. - Normal 0.2.1 PDFs are byte-identical to released 0.2.0; its archived package digest matches the unchanged release lock. Historical imports remain resolvable. - Prior review benchmark: `uv run python packages/vig-utils/tests/benchmark_typst_content.py --entries 1 --figures-per-entry 4000 --unrelated-files 0` measured 60.567s before and 21.052s after, both exit 0. This round adds a source-tokenization count regression and caps CSS cascade work at 1,000,000 selector/node evaluations, including repeated references. - All 18 checks passed on pushed head `1490cf833f09e1d94c4902354f980f609b5eb759`. [CI including Test Summary](https://github.com/vig-os/devkit/actions/runs/41766273353), [Home Matrix](https://github.com/vig-os/devkit/actions/runs/41766273344), and [CodeQL](https://github.com/vig-os/devkit/actions/runs/41766273252) completed successfully. Current local pytest commands (each exit 0): ```sh uv run --with pytest-xdist pytest packages/vig-utils/tests/test_typst_content_unit.py packages/vig-utils/tests/typst_content_contract.py packages/vig-utils/tests/test_typst_guard.py packages/vig-utils/tests/test_typst_packages.py tests/test_typst_docs.py -n 4 --basetemp=$HOME/.cache/devkit-pytest/1994f-r6-rebased -q uv run --with pytest-xdist pytest packages/vig-utils/tests/typst_content_contract.py -k 'runtime or normal_output_unchanged' -n 4 --basetemp=$HOME/.cache/devkit-pytest/1994f-r6-header-green -q ``` ## Checklist - [x] My code follows the project's style guidelines - [x] I have performed a self-review of my code - [x] I have commented hard-to-understand areas - [x] I have updated the documentation accordingly - [x] I have updated both CHANGELOGs and the generated changelog copy - [x] My changes generate no new warnings or errors in normal builds - [x] I have added tests that prove the feature works - [x] New and relevant existing unit tests pass locally - [x] Any dependent changes have been merged and published ## Additional Notes Relative and automatic sizing without package metadata uses the documented page-width fallback. Unresolved sizing/font shorthand, unsupported SVG styling, scale transforms and SVG use expansion limits emit named warnings. SVG traversal is capped at 32 reference levels and 32,768 visited nodes, including repeated reference contents. Unsupported uppercase font properties, declaration comments and spaced importance markers warn explicitly. Images from bytes have no inspectable source path and are documented as skipped. Raster images and lettering converted to outlines cannot be measured. Rebased onto #2017; retain the released 0.2.0 source and hash while shipping guard instrumentation in 0.2.1. The retained 0.2.0 package is an unchanged archive of previously reviewed source from #2017. Shared defusedxml is retained so dynamically activated docs hooks and recipes always use the same hardened parser without a second Python environment; the dependency tradeoff is documented in both CHANGELOGs. Refs: #1994
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.
Description
Add
@local/devkit-docs:0.2.0with offline native plots, consumer-loaded glossary rendering, and a 16:9 presentation layout. Preserve byte-identical 0.1.0 and 0.1.1 imports and their content hashes.Glossaries load explicitly with
#show: glossary-setup.with(yaml("/glossary.yaml")). This works with large registers, plain compilation, editor previews, hooks, and recipes without transporting YAML through compiler arguments. Acronyms expand at their first body occurrence; outline and figure-outline copies use short forms. For PDF bookmarks,glossary-toolsbinds canonical term text before layout while retaining contextual expansion. The legacy setup API remains supported; bookmark-safe headings use the documented boundtermhelper.Type of Change
feat-- New featurefix-- Bug fixdocs-- Documentationtest-- Testsbuild-- Offline package registry and sandbox checkModifiers
!)Changes Made
short-titleortitle, extracted read-only with an explicit work stack, without recursive traversal, reconstruction or source-element layout. Hidden content is omitted, term items retain their term and description, paired single/double smart quotes remain readable, and cells, nonzero horizontal spacing and math attachments separate text leaves. Render plain text at 9 pt on one fixed line, truncate measured grapheme prefixes with a logical-end ellipsis, align to the text direction, and reserve a 2 mm counter gap. Bound extraction to 400 graphemes and a one-million-item for-loop traversal budget; handle apostrophes after letters/digits, separate cases and vertical spacing, and document same-type nested double-quote limits. Skip footnotes and placed content; document plain-text and unknown-atom behavior.Changelog Entry
Added
Testing
409b608a94a10509ce28396ffdd71e1a9b24f1f5, including Test Summary, Project Tests, Project Flake Gates and both Home Matrix platforms.Commands:
Manual Testing Details
pdftotext -bboxverifies plain prefixes, ellipses, page margins, a single line and at least 2 mm counter clearance.pdftohtml -xmlverifies 9 pt footer text without inherited title styling. The traversal test places 15,000 hidden children before visible text, exercising more than 10,000 work items independently of the output cap. Combining-grapheme boundary tests cover 399, 400 and 401 clusters. Three apostrophe examples compare exact extraction with native Typst slide-body rendering; digit-following apostrophes separately assert the footer's explicit right-quote rule. Existing exact extraction and PDF tests retain deep nesting, source precedence, empty math, hidden content, term items, grouped cells, matrix/attachment separators, RTL and styling checks. Registry tests retain immutable 0.1.0/0.1.1 bytes and refresh only the unreleased 0.2.0 digest.Checklist
Additional Notes
Content guards remain the separate phase-3 PR. This fix round stays on the same branch and PR, rebased onto current
dev; 0.2.0 does not collide with the published 0.1.1 package. No merge or workflow dispatch requested.Refs: #1994