Write, build and publish documentation¶
Use this guide when changing a documentation page, API docstring or the site configuration. Start from a checkout prepared as described in Develop and validate changes, with Hatch and Python 3.13 available. Run commands from the repository root.
Choose the page and update navigation¶
Choose the document type from the reader's task:
| Reader's need | Document type | Location |
|---|---|---|
| Learn through a guided, working example | Tutorial | docs/tutorials/ |
| Complete a specific task with existing knowledge | How-to guide | docs/how-to/ |
| Look up an interface, constraint or term | Reference | docs/reference/ |
| Understand a model, relationship or trade-off | Explanation | docs/explanation/ |
Keep each page focused on its purpose. Put contributor procedures under
docs/contributing/ and project information under docs/about/. Link to the
other document types when a reader needs more background or precise details.
For example, a how-to should link to the API reference rather than reproduce
its method descriptions.
Write in British English, preserving literal API names and command syntax. Address a reader with the knowledge appropriate to the page. Introduce unfamiliar project terms when they become relevant, and use the glossary consistently. Explain who acts, what changes and what the reader can observe. Establish the central behaviour before introducing the conditions that qualify it, and explain how those conditions affect a task or decision. Use lists or tables for independent constraints. Keep related ideas together in prose, expressing their relationships through grammar rather than semicolons. Preserve semicolons in code, literal values and quotations.
When adding or moving a page, update project.nav in zensical.toml and fix
links to its former location. Use relative Markdown links between site pages.
Keep the home page and public API index
useful as entry points, rather than duplicating their inventories elsewhere.
Maintain API documentation at its source¶
Update the relevant Python docstring when a signature, return value, exception or extension obligation needs documenting. Docstrings use Google-style sections. Mkdocstrings reads them from the checkout through Griffe. Check claims against the public contract and tests as described in the development guide. Describe the intended public API. Keep implementation defects in the project's issue records, where they can be tracked and fixed.
Reference pages select API objects with ::: directives. Use defining-module
identifiers, such as lookups.lookup.Lookup, and link to the object's existing
canonical page and fragment. Preserve those identifiers when changing visible
headings. The package-root import spelling can differ from the canonical ID, so use the API index to find the target.
Keep member selection explicit. The global configuration excludes private names and inherited members, so constructors, operators, supported protected hooks and inherited facilities may need selecting individually. Review the rendered result after changing a directive. Avoid a second directive for an object already rendered elsewhere: link to the existing anchor instead. Document supported extension interfaces without presenting internal storage classes as public API.
Use authoring features where they help¶
The site enables admonitions, collapsible details, content tabs, code annotations, footnotes and Mermaid fences. Use these to support the page's task:
- Put a condition or limitation that could derail the task in a visible admonition. Reserve collapsible details for optional material.
- Use tabs for alternatives a reader chooses between. Tabs with the same label switch together, so keep labels consistent and avoid hiding required steps.
- Use code annotations for a local detail that benefits from sitting beside the relevant line. Keep the copied code runnable.
- Give code blocks useful titles. At the end of a tutorial, put its complete listing in a collapsed block while keeping the teaching steps and output visible.
- Use a Mermaid diagram when relationships are clearer as a diagram than as prose. Retain enough surrounding text for the page to make sense without it.
Use the official Zensical authoring instructions for admonitions, content tabs and code annotations. Check syntax in the pinned local build before relying on examples from newer upstream documentation.
Preserve branding and the publication boundary¶
The accepted artwork lives in ai-works/logo/: logo.svg supplies the public
docs/assets/logo.svg, and logo-32.png supplies docs/assets/favicon.png.
The seven selected family SVGs in ai-works/logo/family/ supply
docs/assets/lookups/. Update the public copies from those sources when an
approved asset changes. Keep comparison artwork and proposal galleries out of
the site. Give each family icon an adjacent text label, and check its contrast
in both colour schemes. The README's local SVG badges live in
docs/assets/badges/. Keep their Python range aligned with the declared
and tested runtimes. The PyPI badge links to releases without claiming a version.
Keep private research, agent records and machine-specific paths outside public
page content. The site takes its content from docs/, so omitting a file from navigation
does not make it private. Review snippets and copied assets as well
as Markdown, and inspect the generated site/ directory for accidental
publication. The configuration excludes theme internals such as
mkdocs_theme.yml, and those exclusions must be preserved.
Keep the documentation tool versions together in pyproject.toml. The detached
doc environment uses Python 3.13, Tarn 1.0.0 and its required Zensical 0.0.73.
MkDocs 1.6.1 provides the Python API used by mkdocstrings 1.0.7 and
mkdocstrings-python 2.0.9. Zensical builds the site. Treat a toolchain upgrade as a
compatibility change to test with Tarn, rather than upgrading the engine alone
to match newer authoring instructions.
Run examples and check types¶
Copy changed executable examples into temporary Python files, retaining imports, setup and assertions. Run them in a runtime environment, for example:
hatch run tests.py3.15:python /tmp/lookups-doc-example.py
Create that file from the example before running the command. If a page builds an example across several blocks, run the blocks in their documented order in one script. Check the advertised output or assertions, and exercise cleanup such as listener removal. For package-discovery examples, install the example package into the interpreter that performs discovery, as instructed in Discover package contributions.
For a typed example, make annotations and imports complete, then check the temporary file with the repository's strict Pyright configuration:
hatch run typing:pyright --project pyproject.toml /tmp/lookups-doc-example.py
Resolve diagnostics rather than adding blanket suppressions. Run the library checks in the development guide when changing Python source, including docstrings. The detached documentation environment reads source for API rendering but does not install Lookups or Listeners, so a successful site build does not verify executable examples.
Build and inspect the site¶
Use the configured Hatch commands:
hatch run doc:build
hatch run doc:check
hatch run doc:serve
build writes the site to site/, while check builds in strict mode. Resolve strict
build failures before submitting. serve starts a local preview at
http://127.0.0.1:8000/ and rebuilds as files change. Extra arguments are
forwarded to Zensical, for example:
hatch run doc:serve --dev-addr 127.0.0.1:8001
Inspect the affected pages in light and dark modes, at desktop and narrow mobile
widths. Follow navigation and internal links, search for a newly added term, and
check API fragments and signatures. Exercise tabs, annotation popups and diagrams
in the browser as well as checking their generated markup.
Check code overflow, table scrolling and icon labels. Confirm that asset URLs
work under the configured /lookups/ project path.
Publish from master and verify the deployment¶
Publication uses .github/workflows/docs.yml. A push to master triggers the
workflow, and workflow_dispatch allows a manual run. Both the build and deploy
jobs require github.ref == 'refs/heads/master', so a manual run against another
branch cannot publish it.
The workflow installs Python 3.13 and Hatch 1.18.1, runs hatch run doc:check
and uploads site/ as the Pages artifact. It uses official actions pinned to
commit IDs. Keep repository contents read-only, grant pages: read
to the build job, and reserve pages: write and id-token: write for the deploy
job. Preserve the job timeouts, deployment concurrency control and
github-pages environment when maintaining the workflow.
For the first deployment, a maintainer with repository settings access must:
- In Settings → Pages → Build and deployment, select GitHub Actions as the source.
- In Settings → Environments → github-pages, restrict deployment branches
to
master. Check any required approvals before expecting an unattended run. - Push the reviewed change to
master, or open the documentation workflow in Actions, choose Run workflow, select master and start the run.
GitHub documents the Pages source setting and custom workflow and environment requirements. The environment restriction supplements the workflow's branch checks.
In Actions, verify that the run used the intended master commit and that
both build and deployment succeeded. Inspect a failed job's logs or a waiting
environment approval before retrying. Follow the deployment URL from the
github-pages environment, confirm it opens
https://axelvoitier.github.io/lookups/, and check the changed page, navigation
and assets on the hosted site.
A successful local build produces files on your machine. Publication is complete only after the hosted deployment succeeds and the intended content is visible at the site URL.