Maintaining this site¶
This page explains how the documentation site is built and how to change the settings that are most likely to need adjusting.
How it works¶
The site is a MkDocs + Material
build, generated directly from the literate .lagda.md sources — there is no
separate copy of the documentation. The decision record is
ADR-007; the moving parts are:
mkdocs.yml(repo root) — the site configuration: theme, colours toggle, plugins, Markdown extensions, navigation behaviour. Most settings live here.scripts/python/mkdocs_gen_library.py— runs during every build and mounts the library: for eachsrc/**/*.lagda.mdit writes a site page at a clean URL (src/Setoid/Algebras/Basic.lagda.md→/Setoid/Algebras/Basic/), and it generatesSUMMARY.md, the file that becomes the whole navigation.agda --html— when the highlighted build is requested, Agda renders each module's code blocks to classed, hyperlinked HTML.mkdocs_gen_library.pyembeds that; if it is absent, code blocks fall back to plain monospace.scripts/python/mkdocs_hooks.py— rewrites repo-relative prose links (src/…,docs/adr/…,CONTRIBUTING.md) into site URLs, and prints the per-page build log.docs/_links.md— a library of reference-style links ([Setoid.Algebras.Basic][],[ADR-008][]) appended to every page so cross-references resolve. Its module and ADR sections are generated byscripts/python/gen_links.py; re-run that (make gen-links) after adding a module or an ADR. CI runs it with--checkand rejects any drift, so the file cannot fall behind the tree.- The theme (see The theme below):
docs/stylesheets/tokens.css,theme.cssandagda.css, the self-hosted fonts indocs/assets/fonts/, and the templates inoverrides/.docs/stylesheets/site.cssholds this site's own components (the landing page, the constellation, the controls on Agda's code, the tooltips). docs/assets/js/agda-copy.js— adds a copy button to the highlighted<pre class="Agda">blocks (Material's own copy button only covers its.highlightblocks, which theagda --htmloutput is not).docs/assets/js/agda-toggle.js— the header's "Show more Agda" control (#431). Module sources wrap their leading OPTIONS/module/import scaffolding in<!-- … -->comments;mkdocs_gen_library.pyre-surfaces those blocks taggedhidden-source, and this control shows or re-hides them all at once, with the choice persisted inlocalStoragelike the palette toggle.docs/assets/js/stats-count.js: the landing page's figures count up from zero the first time the stat strip scrolls into view (see Corpus stats).
Hiding a module's import scaffolding¶
Every module's leading scaffolding block — the OPTIONS pragma, the module … where header, the imports, and the private variable declarations — is wrapped in an HTML comment in the .lagda.md source:
<!--
```agda
{-# OPTIONS --without-K --exact-split --safe #-}
module Setoid.Homomorphisms.Noether where
open import Level using ( Level )
-- … the rest of the imports …
```
-->
Agda still type-checks the block (fenced agda code inside an HTML comment is still code), GitHub's Markdown renderer collapses it, and on the site it becomes a toggleable hidden-source block, revealed either by the header's "Show more Agda" control (all blocks, persisted) or by the small ▸ hidden code (n lines) note that agda-toggle.js places in front of each hidden block (that block only). When the scaffolding shares its fence with real definitions, split the fence and wrap only the scaffolding part. New modules should follow the same convention.
The wrapper must be an HTML comment rather than any indenting construct: Agda requires its code at column 0, so a block can never be indented into a ??? note admonition or a Markdown-nested <details> — indenting the fence breaks type-checking. The comment wrapper adds no indentation, which is exactly why issue #431 settled on this mechanism.
Two kinds of module are deliberate exceptions:
- Pedagogical modules whose scaffolding is the subject of the surrounding prose stay fully unwrapped:
Overture.Basic(which explains theOPTIONSpragma, modules, and imports) andExamples.Demos.HSP(the TYPES 2021 paper, which discusses its imports in the text). - Barrel modules stay unwrapped too: a barrel's annotated
open import … publiclist is the page's content, and hiding its only block would leave a blank page that reads as unfinished.
As a tripwire against accidentally wrapping a barrel, the build logs a ⚠ <Module>: every code block on this page is hidden line for any page that would render code-free. Three prose-first pages hide their lone OPTIONS/module block by design and are exempt from that check: Overture.Preface, Examples.Demos.GeneralOperationsAndRelations, and Setoid.Complexity.Basic (PROSE_ONLY_MODULES in mkdocs_gen_library.py).
Build commands¶
Run these inside nix develop (the MkDocs toolchain is pinned in flake.nix):
| Command | What it does |
|---|---|
make site |
Fast build to ./site. Code blocks are plain (no Agda pass). |
make serve |
Fast live preview at http://127.0.0.1:8000. |
make site-full |
make html + make agda-md + make site — the published site, with token highlighting + the /classic/ site. This is what CI builds. |
make serve-full |
The full preview (highlighting + /classic/), live-reloading. |
make html |
Just the classic clickable-HTML site (Everything.html index) into ./html. |
make agda-md |
Just the highlighted-Markdown pass into .agda-html/md. |
Seeing the real thing locally
make serve is fast but renders plain code blocks (and /classic/ 404s),
because the agda --html passes are skipped. Use make serve-full to
preview exactly what gets deployed.
Recovering a stuck Pages deployment¶
Publishing is a two-repository chain: the Docs workflow here builds ./site and pushes it to the gh-pages branch of universalalgebra/agda-algebras, and GitHub's auto-generated pages-build-deployment workflow in that repository publishes the branch to the live site. The last hop occasionally fails with a transient Deployment failed, try again later, and a failed run can wedge in queued when re-run. Recovery steps, in escalating order:
- Check for a platform incident at githubstatus.com; this error is almost always GitHub-side, and waiting often suffices.
- Re-run the failed
pages-build-deploymentrun from the Actions tab ofuniversalalgebra/agda-algebras. - Re-run the Docs workflow here (Actions → Docs → Run workflow). Note this re-triggers publication only when the rebuilt site differs from what is already on
gh-pages— the publish action skips the push when nothing changed, so an unchanged same-day rebuild is a no-op. -
Force a fresh deployment with an empty commit, which always re-triggers the publisher:
git clone --branch gh-pages --depth 1 git@github.com:universalalgebra/agda-algebras.git ua-pages cd ua-pages git commit --allow-empty -m "retrigger Pages deployment" git push
Merging any content change to master also re-pushes gh-pages and re-triggers publication as a side effect. When checking what is actually live, remember the Pages CDN caches responses for up to ten minutes and your browser caches the HTML and CSS on top of that — hard-refresh, or probe a file headers-only with curl -sI https://agda-algebras.universalalgebra.org/assets/js/agda-copy.js.
The site's own CSS/JS are content-hashed so that a returning visitor never renders fresh HTML against a stale-cached stylesheet or script (the assets carry a multi-hour max-age, far longer than the HTML's ten minutes). on_config in scripts/python/mkdocs_hooks.py appends an eight-character hash of each extra_css / extra_javascript file to its URL (site.css?h=…); a changed asset therefore gets a fresh URL, which the short-lived HTML picks up within minutes (#429). The copied file keeps its plain name (only the reference carries the query), so the headers-only probe above is unaffected.
Resist the temptation to add a deployment workflow to the gh-pages branch itself: that branch is disposable build output which the publish action overwrites, and keeping such a file alive would require keep_files: true, which never deletes anything and so leaks renamed or removed pages onto the live site forever.
Changing the settings¶
The theme¶
The site wears Constellation, the design of williamdemeo.org, which was derived from this site's earlier palette and display face and refined there (#621, ADR-007 Decision 8). Its parts are files of their own, so that a sibling site (the agda-lattices site) can copy them unchanged and stay one design with this one:
| File | What it holds |
|---|---|
docs/stylesheets/tokens.css |
every color, size and space, light and dark |
docs/stylesheets/theme.css |
Material's variables and chrome, in tokens |
docs/stylesheets/agda.css |
Agda's token classes, in tokens |
docs/assets/fonts/ |
the faces, their licenses, and fonts.css |
overrides/404.html |
the 404 page, set as an unfilled Agda goal |
overrides/partials/source.html |
the repository chip, without its api.github.com fetch |
docs/stylesheets/site.css is this site's own components, on the same tokens;
it is the one stylesheet a sibling site writes for itself. The stylesheets load
in the order mkdocs.yml lists them: faces, tokens, theme, Agda, site.
Three rules hold the design together, and each is checked rather than trusted:
- Every color is a token. No stylesheet names a raw color except
tokens.css(and the constellation's night sky insite.css, which is dark in both schemes by design). To change a color, change its token. - Every text color clears WCAG AA in both schemes, on the surface it sits
on:
make contrast-auditmeasures every text element of every built page.tokens.csslists the ratio of each Agda hue on the code-block surface. - Nothing is fetched from another origin:
make offline-check(in CI) reads every built page and stylesheet, andmake offline-auditloads every page in a browser and reads its network log.
The site is dark first: mkdocs.yml lists the slate palette first, with
no media: key, so a first visit is dark whatever the operating system
prefers, and the toggle's choice is remembered.
The code-block palette¶
Agda's token classes take their colors from six hues in tokens.css
(--c-blue, --c-green, --c-rose, --c-violet, --c-amber, and the
accent pair), mapped in agda.css:
| Agda class | Color |
|---|---|
Keyword |
the coral, --c-accent-hover |
Function, Postulate, Macro |
the indigo accent, --c-accent |
Datatype, Record, Primitive, PrimitiveType |
--c-blue |
InductiveConstructor |
--c-green |
Field |
--c-rose |
Module |
--c-violet |
Number, String, CoinductiveConstructor |
--c-amber |
Comment, Pragma |
--c-fg-faint |
Symbol |
--c-fg-muted |
Bound, Generalizable, everything else |
the text color |
The same mapping colors the inline names in prose (`Algebra`{.AgdaRecord}),
the hover tooltips, the 404 page, and the /classic/ pages, whose Agda.css is
replaced by the light tokens and these rules (mkdocs_gen_library.py). Each
class sets a custom property, --agda-ink, which one rule turns into the
color, so a token keeps its color when it is also a link. Colors only: code is
never bold or italic, because only JuliaMono's regular face ships.
Fonts¶
Every face is self-hosted under docs/assets/fonts/, with
theme.font: false in mkdocs.yml, which stops Material's Google Fonts link:
- text: Inter 400, 600 and 400 italic;
- headings: Space Grotesk 600;
- code: JuliaMono, split three ways by Unicode block (text, symbols, mathematical alphanumerics), so a page pays only for the notation it shows. It is the one common monospace face that carries 𝑨, 𝓤 and 𝒦, and it is also the last face in the text stack, so a symbol in prose renders in it too.
The files are generated, not hand-placed: make fonts runs
scripts/python/theme/build_fonts.py, which downloads the sources (pinned by
SHA-256), subsets them by Unicode block, and writes the WOFF2 files, their OFL
licenses and fonts.css; make fonts-check reports whether the committed files
still match. Subset by block, never by a list of characters: a list from
agda-input.el misses ℓ, Π and the subscript digits, which Agda's input method
inherits from Emacs. make font-audit asks a browser which face drew every
character on every page, and fails on any system font. The block lists are
williamdemeo.org's plus the blocks this site's pages turned out to use (the
script's comments name each and the page that needed it); a new character
outside them shows up there first. Emoji are left to the system's emoji face,
and one gap is known and allowed: the fullwidth braces (U+FF5B, U+FF5D) of the standard
library's singleton notation, which no face here carries, on /classic/ and in
the frozen Legacy/ tree (KNOWN_GAPS in scripts/js/audit_fonts.mjs).
The audits¶
make design-audit runs the three browser audits over ./site as it stands
(build it with make site-full first). They need node 22 and a Chromium (set
CHROME=/path/to/chrome if none is found), so they are local targets: run them
before a pull request that touches the theme. AUDIT_PAGES restricts a run to
pages whose path starts with one of its words:
make contrast-audit AUDIT_PAGES="index.html Setoid/Algebras constellation"
The logo and favicon¶
Both point at docs/assets/lambda.png via theme.logo and theme.favicon in
mkdocs.yml. Drop a replacement PNG at that path (a transparent background
reads on the page-colored header in both schemes).
Navigation¶
The nav is generated, not hand-written. The library tree comes from the module
hierarchy automatically. The fixed top-level entries (Home, the Project
section) are defined in scripts/python/mkdocs_gen_library.py in the
SUMMARY.md assembly near the bottom; add or reorder lines there. The last
entry of The Library links the sibling library, agda-lattices, from
extra.agda_lattices in mkdocs.yml; the footer (copyright in mkdocs.yml)
and the landing page's card ([agda-lattices] in docs/_links.md) link it
too, and the three move together.
The top-level sections are tabs (navigation.tabs), although williamdemeo.org
has none: the module tree is deep, the tabs keep the sidebar one level
shallower, and the landing page hides its sidebar, so on a desktop the tabs are
its only navigation. Below 1220 px Material folds the tabs into the drawer.
The landing page¶
docs/index.md is plain Markdown plus a few HTML blocks whose styling lives in
site.css (section 1):
- the hero (
.ualib-hero) — title, tagline, the formula, the buttons; - the stat strip (
.ualib-stats), whose four figures are counted from the tree and must never be edited by hand (see Corpus stats); - the Featured results gallery (
.ualib-figures) — each card is one<a class="ualib-figure">; swap a monogram for a photo by replacing the<span class="ualib-portrait">GB</span>with<span class="ualib-portrait"><img src="/assets/portraits/birkhoff.jpg" alt="…"></span>; - the coverage matrix (
table.ualib-matrix) — a plain HTML table; add a row for a new structure, or a<td class="yes">✓</td>for a new axiom.
Adding a prose page¶
Drop a Markdown file under docs/ and add a line to the SUMMARY.md assembly in
mkdocs_gen_library.py so it appears in the nav. Repo-relative links in the
prose (src/…, docs/…) are rewritten to site URLs automatically by the hook.
Reference links¶
To make [Some Name][] resolve everywhere, add a definition to the External
links section of docs/_links.md. For a module or an ADR you need not touch
the file by hand — make gen-links regenerates those sections from src/ and
docs/adr/.
These references are the site's recurring failure mode: an undefined [label][]
does not error, it renders as literal text and sails past mkdocs build
--strict. Two pure-Python guards, bundled as make check-links and run in CI
(the Docs cross-links job), close that gap:
gen_links.py --checkfails ifdocs/_links.mdhas drifted from thesrc/anddocs/adr/trees — so a new module or ADR cannot ship without its link definition;check_links.pyscans the rendered corpus and fails if any reference-style link is undefined — catching typos and non-module targets the generator cannot know about. It skips the frozensrc/Legacy/prose (rebrand tracked separately), generatedGITHUB_PROJECT.md, and code spans.
Run make check-links before pushing docs changes; make check-links-test
exercises the scanner's own unit tests.
Corpus stats¶
The landing page's four figures are facts about this repository, so none of them
is typed by hand. scripts/python/corpus_stats.py counts them and writes them
into the <!-- ualib:stat:NAME -->…<!-- /ualib:stat:NAME --> marker pairs in
docs/index.md:
modulesandloc, the literate modules undersrc/outside the frozenLegacy/tree and the lines of Agda inside their code fences;checked, the share of those modules whoseOPTIONSpragma carries--safe, which is what "100% machine-checked" asserts;agdaandstdlib, read frommkdocs.yml'sextra:site variables and reconciled against the two pins that bind them: thedepend:line ofagda-algebras.agda-lib, whose stdlib version Agda enforces exactly, and the version-floor guards inflake.nix. The stdlib half is therefore exact; the Agda half is by series, becauseflake.nixdeliberately guards2.9.*and nothing in the repository states a patch level. A move from Agda 2.9.0 to 2.9.1 is thus visible in the dev shell's banner on entry, and a move of the flake'sagdainput to another commit only inflake.nix, but no check in this repository fails on either.
Three commands, one gate:
make corpus-statsrewrites the figures indocs/index.md;make corpus-stats-checkfails, with a diff, when a committed figure has drifted from the tree. CI runs it as the Landing-page stats job, so the pull request that moves a number is the one that refreshes the page;make corpus-stats-testexercises the tool's own unit tests.
The MkDocs hook substitutes the same values into the rendered page at build time, but that is a convenience, not the mechanism: it rewrites only the built HTML, so before the gate existed the committed values, which are the ones GitHub renders, sat six weeks behind the tree and were quoted elsewhere as current.
On the page, docs/assets/js/stats-count.js counts each numeric figure up
from zero, eased over 0.9 s, the first time the strip scrolls into view, and
lands on the value the page already holds; the toolchain's version is not a
quantity and stays still. The script only ever animates toward the counted
value, so with JavaScript off, under reduced motion, or in a browser with no
IntersectionObserver, the page shows the figures unchanged. It subscribes
to Material's document$, so it runs again after an instant navigation back
to the landing page.
corpus_stats.py --json prints the figures as one record for anything outside
this repository that wants to cite them.
Where things live¶
mkdocs.yml site config (theme, plugins, nav behaviour)
docs/
index.md the landing page
site-guide.md this page
_links.md shared reference-link library (generated + external)
stylesheets/tokens.css the theme: colors, type, spacing
stylesheets/theme.css the theme: Material's variables and chrome
stylesheets/agda.css the theme: Agda's token classes
stylesheets/site.css this site's own components
assets/fonts/ the self-hosted faces and fonts.css (make fonts)
overrides/ the 404 page and the repository chip
scripts/js/ the browser audits (make design-audit)
assets/ logo, favicon, portraits, vendored JS
adr/ architecture decision records
scripts/python/
mkdocs_gen_library.py mounts src/ as pages + builds the nav
mkdocs_hooks.py link rewriting + per-page build log
gen_links.py regenerates the module + ADR sections of _links.md
check_links.py fails CI on any undefined reference-style link
corpus_stats.py counts the landing page's figures; refreshes and gates them
theme/build_fonts.py builds the self-hosted fonts (make fonts)
theme/check_offline.py fails CI on any request to another origin
.github/workflows/docs.yml build (make site-full) + deploy to gh-pages