Documentation#

How the pages under docs/ and the gallery under examples/ are written and built. The build itself is in Installation.

Sources#

The pages under docs/ are MyST Markdown, built by Sphinx. The autosummary templates in docs/_templates/autosummary/*.rst stay reStructuredText: sphinx.ext.autosummary writes its stubs with a hardcoded .rst suffix and finds its directives by regex over raw source lines.

Figures#

Figures read in both themes. Colours come from docs/figure_style.py (SERIES, MUTED), never a fixed grey, black or white, and every legend sits outside the axes with legend_outside. Check each figure on a light and a dark background before committing.

The figures on the explanation pages are simulated at build time by docs/explanation_figures.py, so a figure cannot outlive the behaviour it shows. To add one, write a function that returns a Matplotlib figure, register it in the FIGURES mapping at the bottom, and reference the file it writes with a {figure} directive.

Examples#

To add a gallery example, add a script to its examples/ section: the numeric prefix orders it and the module docstring becomes the page. Then add a row for it to Examples and to Course or Applications, whose hidden toctrees place it in the navigation.

An example is executed by the gallery when the interpreter can import everything it imports, so what a build runs follows from the extras installed into it, and a page already carrying output executed from the source as it stands is reused rather than re-run.

Publication#

.github/workflows/docs.yml builds the published pages and GitHub Pages serves them from gh-pages. Its HTML job checks every branch with the doc extra; its Site job executes every example with the examples extra and hands the tree to scripts/publish_docs.py, which keeps one directory per version – latest for main, its own for each v*.*.* tag – beside the list the version switcher reads.