test(docs): run the documented examples in CI - #112
Merged
Conversation
The 2026-08-29 docs review found two bugs by hand: `{{ activation_health(0.82) }}`,
which the macro's signature rejects, and a dashboard example that had quietly
lost the `filters:` block it existed to demonstrate. Prose is invisible to CI,
so neither could have been caught. Both classes are now checked.
A survey of the 25 YAML blocks under docs-site/docs found 5 whole dashboard
specs, 18 fragments and 2 blocks that are not glyf config at all. That ratio
rules out marking blocks by hand in either direction, so blocks are routed by
shape: a block whose top-level keys are dashboard keys loads through
glyf.dashboard.loader, a fragment is spliced into a minimal host spec first,
and a block shaped like a section item is spliced one level deeper so its macro
is really evaluated rather than parsed and ignored.
Routing by shape has a hole worth naming: a block that stops looking like a
dashboard stops being checked, and a misspelled top-level key is exactly the
drift worth catching. So a fourth check requires every YAML block to be a
dashboard, a section item, on the short list of pages holding other YAML, or
explicitly marked to skip.
Macro expressions resolve against the real macros, never pooled across pages: a
page presenting a shipped example file resolves against that example project's
macros.py, and any other page against the macros.py it documents itself. The
guide teaches a simpler `activation_health` than the example ships, and pooling
them checked each page against the wrong one.
Neither original bug would have been caught by parsing alone -- the TypeError
needs the macros evaluated, and a block that has lost a section is not a parse
error at all -- so pages presenting a file "as shipped" are compared against
that file. Both are identical today.
docs-site/README.md documents the checks and the opt-out marker, which nothing
uses; the intent is that a broken block gets fixed rather than marked.
`guides/dashboard-macros.md` documented `activation_health(ctx, chart=,
field=)` while `examples/product_analytics/dashboards/macros.py` ships
`activation_health(ctx, *, chart=, field=, threshold=80.0)`, and the
example page's YAML passes `threshold=80`. Nothing was broken for
readers who copied the guide, but the teaching example had drifted from
the code it teaches, and a reader moving between the two pages met two
different signatures for one macro.
Align the documented signature and use `threshold` in the comparison it
exists for. The keyword-only marker matters beyond tidiness: with it,
`{{ activation_health(0.82) }}` -- the call the 2026-08-29 review found
in the wild -- is a TypeError the docs guard now catches.
This was referenced Aug 30, 2026
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.
The 2026-08-29 docs review (glyf#104) found two bugs by hand:
examples/product-analytics.mddocumented{{ activation_health(0.82) }}, which the macro's signature rejects, and its YAML had lost thefilters:block the page existed to demonstrate. Nothing catches that class — the docs are prose to CI. This makes the documented examples executable.Part of the public-launch epic.
What the docs actually contain
I surveyed the 25 YAML blocks under
docs-site/docsbefore designing the check:toolbar:,filters:,sections:,summary:, …)component:)glyf.yml)Marking blocks by hand loses either way round: opt-in abandons 19 blocks, opt-out annotates 20. So blocks are routed by shape and nothing in the docs is annotated. A block whose top-level keys are dashboard keys is loaded through
glyf.dashboard.loader; a fragment is spliced into a minimal host spec first; an item-shaped block is spliced one level deeper, which matters because a lonecomponent:at top level is ignored by the loader — that block was passing without its macro ever being evaluated.The four checks
dashboards/macros.py, any other page against themacros.pyit documents itself.guides/dashboard-macros.mdteaches a deliberately simpleractivation_healththanexamples/product_analyticsships, and pooling them checks each page against the wrong macro.product-analytics.mdandfinance-metrics.mdpresent a block as shipped; both are byte-identical toproduct.ymlandfinance.ymltoday. This is the only check that catches an omission — a parse check cannot see a block that is no longer there, which is precisely how thefilters:bug survived.Mutation-checked
Each mutation was introduced, confirmed red, and reverted:
chart_theme:misspelledui.badge(nope=1, …)filters:blocktoolbar.visibilityset to a value the loader rejects<!-- glyf-docs: skip -->Notes
tests/already runs undermake test, so this is inmake ciwith no wiring. Suite is 189 passed, up from 126 — the new tests are parametrised per block, so a failure names the page and line.docs-site/README.mddocuments the checks and the opt-out marker. Nothing uses the marker; the intent is that a broken block gets fixed rather than annotated.One inconsistency this surfaced but does not fail on, left for a follow-up decision:
guides/dashboard-macros.md:197teachesactivation_health(ctx, chart=…, field=…), whileexamples/product_analytics/dashboards/macros.py:9shipsactivation_health(ctx, *, chart=…, field=…, threshold=80.0). Nothing is broken for users — the example page's YAML passesthreshold=80and the shipped macro accepts it — but the teaching example has drifted from the code it teaches.