How the docs are built#
The site is a Sphinx 9 project in docs/source/, with the PyData theme 0.23
and MyST 5.1. Pages come from three places: pages written by hand, data files
written by generators from the code, and pages the local extensions render from
those data files.
What is written, what is generated#
Part of the site |
Source of truth |
Written by |
|---|---|---|
User guide, Theory, About, Contribute |
|
a person |
Parameter reference ( |
the Pydantic models under |
|
Python API and command line ( |
|
|
Catalogs of solvers, figures and data sources |
the registries of the code |
|
Validation page and “Checked by” boxes |
|
|
TOML changes since the last release |
the field snapshot of each release under |
|
Register of changes ( |
|
|
Layer matrix |
|
|
JSON Schema of the configuration |
|
|
The data files go to docs/source/_data/ at the builder-inited event of the
build. Git ignores them, and it ignores the generated pages under
reference/parameters/, reference/python/ and reference/cli/.
HMP_SKIP_DOC_DATA=1 reuses the data of the previous build when you only edit
written pages. The layer matrix fragment is committed: a build rewrites it, and
CI fails if the committed copy is stale
(HMP_SKIP_CONTRACT_TABLES_GEN=1 skips that step).
A key or a table that the loader moves, such as modflow6 to solver.modflow6, appears under
Renamed on the changes page, with the note that it still loads. The loader and the page read the
same rows, the [[migration]] rows of hydromodpy/schema/changes.toml, so they cannot disagree.
A new move is one row there. The keys of the moved table keep their names, so the page compares
them from one release to the next, and a change of default, profile or unit shows under Changed.
A key that only a pre-release wrote shows under Renamed or Removed with the note that 2.0.0
refuses it. The page reads that list from
hydromodpy/config/prerelease_forms.txt.
The page reference/changes-register lists every row of the register, one table per kind, with
no prose written by hand. It is the place to look up why a number moved, what an edition holds
and which key a version moved.
A new release adds its snapshot: run python -m tools.docs.snapshot vX.Y.Z on the tag, and
commit the file fields-X.Y.Z.json.
The local extensions#
They live in docs/source/_ext/ and are listed in conf.py.
Extension |
What it does |
|---|---|
|
The field registry, the role that cites a TOML key, the |
|
The annotated TOML view of each section. |
|
The Python API and command-line pages, rendered with autodoc and napoleon. |
|
The solver, figure and data source catalogs. |
|
The tables of the register of changes, one directive for each kind of row. |
|
The validation page and the “Checked by” boxes. |
|
The text rendering of one parameter card. |
|
The |
|
The site chrome the theme does not give: scripts and styles loaded only on the pages that use them, and previous and next links that stay inside a door. Its stylesheet is |
Build and check#
Build the site with the strict target, the one CI runs. A warning is an error.
make -C docs html-strict
Without make, the same build is:
python -m sphinx -j auto -W --keep-going -b html docs/source docs/build/html
Then run the two checkers CI runs after the build.
python -m tools.docs.check_page $(git ls-files 'docs/source/*.md')
python -m tools.docs.check_site docs/build/html
check_page reads a page without building the site, which makes it the fast
loop while you write. It needs docs/source/_data/registry.json, so build once
first. For each page, .md or .rst, it checks that:
every key cited with the TOML role, every
hmp-paramsline and everyhmp-resolvedkey exists in the field registry;every document link, card link and relative link points to a page;
every TOML block parses, and a block that writes a section of the file loads with the real loader once merged onto the first step of example 04;
the page has no French and no em dash.
A TOML block that shows a mistake on purpose, or a file the loader does not
read, starts with # not checked: <reason> and is skipped.
check_site reads the built HTML. Sphinx does not see what the extensions
write as raw HTML, so it looks for a link inside a link, an internal link to a
missing page or anchor, and markup shown as text (double backticks, bold
markers, a role that was not resolved).
Diagrams#
A page draws a diagram with .. graphviz:: and plain dot, which sphinx.ext.graphviz
renders with the dot command of Graphviz. Keep a diagram only when it shows an order or a
flow that the text does not give.
Preview#
make -C docs livehtml
serves the site with sphinx-autobuild and reloads on save.
What CI does with it#
docs.yml runs the strict build, check_page, check_site, and a last step
that fails when a tracked file under docs/source changed during the build.
docs-deploy-pages.yml builds one version and publishes it to its own folder
of docs.hydromodpy.fr; the other versions stay. See
Reading a failing check.