Documentation build and style

Status: implemented. This page describes the documentation pipeline as the repository runs it, the checks that guard it, and the rules for writing a page. The contribution workflow is in Contributing; this page holds the details that the Documentation section there points to.

What is written by hand and what is generated

Edit the org files under docs/orgmode/. Everything under docs/source/ is generated except the files that .gitignore re-includes: conf.py, _static/, _templates/, the Doxyfile*.cfg files, doxyrest-config.lua, mainpage.dox, namespaces.dox and references.bib. Do not edit a generated .rst file or add one to git.

Content

Source of truth

Produced by

Prose pages (tutorials, how-to, explanation, reference, development)

docs/orgmode/**/*.org

pixi run -e docs mkrst writes docs/source/**/*.rst

Contributing guide

CONTRIBUTING.org

development/contributing.org includes it; scripts/org_to_md.sh CONTRIBUTING.org writes CONTRIBUTING.md

Command-line reference

kFlagDocs and the parser in main_neb.cpp, the Argum::Option chains in main.cpp, gpr/cli/PotentialOptions.h, and the hand-written text in docs/cli_overrides.toml

python scripts/gen_cli_reference.py --write writes docs/cli_reference.md and docs/cli_reference_gprd.md

TOML key reference

managers/io/TomlConfigLoader.cpp, schema/params.capnp, the CLI reference and docs/cli_overrides.toml

python scripts/gen_config_reference.py --write writes docs/orgmode/reference/config_keys.org

Fortran API

fortran/gpridge.f90

python scripts/gen_fortran_reference.py writes docs/orgmode/reference/fortran_api.org

C++ API

the headers under backend/, gpr/, data_types/, structures/ and managers/

Doxygen XML, then doxyrest, into docs/source/api/

Python API

the package python/gpridge with the stub _core.pyi

sphinx-autoapi into docs/source/autoapi/

Bibliography

docs/source/references.bib

sphinxcontrib-bibtex; cite with :cite:t: or :cite:p: in an rst export block

Changelog

news fragments in docs/newsfragments/

towncrier writes CHANGELOG.md at release time

The org pages reference/cli_reference_gprn.org and reference/cli_reference_gprd.org wrap the generated Markdown files with an rst export block that includes them through myst_parser.sphinx_. reference/configuration.org does the same for docs/configuration.md. Such a wrapper page uses title:nil in its #+OPTIONS: line because the included Markdown supplies the title. Without an included title, leave title:nil out, or the first heading becomes the page title and every section appears as a separate sidebar entry.

Build the site

Run every command from the repository root. The docs pixi environment holds Emacs, Doxygen, doxyrest, Sphinx with the Shibuya theme, lychee and towncrier.

Task (pixi run -e docs ...)

What it does

mkrst

Exports every org file to RST with emacs --batch --load docs/export.el, then runs scripts/rewrite_rst_doc_links.py.

setup-doxyrest, patch-doxyrest

Fetch doxyrest at the revision pinned in pixi.toml (57430ce2f) into subprojects/doxyrest and copy the patched Sphinx extension and CSS from scripts/patches/doxyrest/.

doxybuild

In docs/source: doxygen Doxyfile_gpridge.cfg (XML only), then doxyrest -c doxyrest-config.lua.

sphinxbld

sphinx-build -n -W --keep-going -d docs/doctrees docs/source/ docs/build, after mkrst and doxybuild. Any warning, including an unresolved reference, fails the build.

fetch-doxyyoda, doxyhtml

Download the doxyYoda 0.2.2 theme and build the standalone C++ HTML tree in docs/doxygen-html/html.

install-doxyhtml

Copy that tree to docs/build/api-cpp/, after sphinxbld and doxyhtml.

docbld

The whole sequence: mkrst, doxybuild, sphinxbld, install-doxyhtml.

gen-config-reference, gen-fortran-reference

Regenerate the TOML key page and the Fortran page.

check-docs-reference

Run gen_cli_reference.py --check, gen_config_reference.py --check, gen_fortran_reference.py --check and check_doc_cli_flags.py.

lychee-check

Check links in README.md, CHANGELOG.md, CONTRIBUTING.md, CODE_OF_CONDUCT.md, docs/orgmode/**/*.org and docs/*.md with .lychee.toml.

The code-block runner uses the python environment, not docs: pixi run -e python docs-examples runs scripts/run_doc_examples.py --strict after building the Python package. It needs a meson build tree with gprn, gprd and libgpridge in builddir/, or the directory named by GPRIDGE_BUILD_DIR. scripts/ci_docs_tests.sh runs everything that tests the examples in one go: the lint, the coverage check, meson test --suite docs, the C, Fortran and Rust pages against a scratch meson install, and the pytest suites for the Python blocks and the docstring examples. The examples use Lennard-Jones, Morse, the rgpot test surfaces and EMT, never GFN2, xtb or a UMA model.

pixi run -e docs mkrst
pixi run -e docs doxybuild
pixi run -e docs sphinxbld

The org to RST export

docs/export.el loads ox-rst from a fixed upstream commit and checks its SHA-256. The first export downloads the file into docs/.ox-rst/, so it needs network access. The export sets these options for every page:

  • A link [[file:../howto/gpneb.org][text]] becomes a link to the page’s HTML name. rewrite_rst_doc_links.py then turns each such link into a Sphinx :doc: role, and fails the export when a relative link names a page that has no RST source.

  • Sub- and superscripts need braces, x_{i}. A bare R_initial or n_images stays as written.

  • The author, date and e-mail lines are off for every page, so the login name of whoever ran the export never appears below a title. Keep author:nil in #+OPTIONS: as well.

The C++ and Python references

Doxygen reads the source directories listed in Doxyfile_gpridge.cfg (backend, gpr, data_types, structures, managers) and the namespace summaries in namespaces.dox. It excludes subprojects, tests, python and benchmarks, the detail namespaces and the \*_for_testing hooks, and does not extract private members (EXTRACT_PRIVATE = NO). Start the Doxygen comment of a public class with @brief. The standalone doxyYoda tree also includes the Fortran module and mainpage.dox.

sphinx-autoapi reads python/gpridge. The compiled extension is not built in the docs environment, so its signatures come from _core.pyi. Docstrings use the numpy style, which napoleon converts.

Sphinx settings

docs/source/conf.py reads the version from the project() line of meson.build, so a version bump needs no edit there. It sets nitpicky checking through the -n flag of the task, the Shibuya theme, an edit link to the develop branch under /docs/orgmode/, a sitemap from sphinx-sitemap that leaves out api/* and autoapi/*, and a GPRIDGE_DOCS_ANALYTICS variable that loads an analytics script only when a build sets it.

Checks

Check

Command

Fails when

TOML key reference

python scripts/gen_config_reference.py --check

a key that the loader reads is not documented, the allow-list and the parsed keys differ, a schema default differs from its flag default without an override, or the committed page is stale

CLI reference

python scripts/gen_cli_reference.py --check

a registered flag has no kFlagDocs row, a stated default disagrees with the source, an override names a missing flag, or the committed pages are stale; with a build tree it also compares --help output

Documented flags

python scripts/check_doc_cli_flags.py

a gprn or gprd command in a shell block of an org page, README.org, CONTRIBUTING.md or a docs/*.md page uses a flag that the generated reference of that driver does not list; --self-test tests the parser

Fortran page

python scripts/gen_fortran_reference.py --check

the committed page differs from what fortran/gpridge.f90 produces

Block lint

python3 scripts/run_doc_examples.py --lint

a python, bash, sh, c, cpp or fortran block is neither run nor marked :eval no with a reason

Block coverage

python3 scripts/run_doc_examples.py --coverage

a documentation file that holds code is neither a runner source nor explained in EXCLUDED

Block run

pixi run -e python docs-examples

a block fails, an output listing differs from what its block prints, or a needed binary is missing under --strict

Docs tests

pixi run -e python docs-tests

any of the above, the installed-library run or the pytest suites fails

Sphinx build

pixi run -e docs sphinxbld

any warning

Links

pixi run -e docs lychee-check

a link in the scanned files is dead

The workflow .github/workflows/docbuilder.yml runs the checks in four jobs: docs_checks (the three generators in check mode, the flag check and the lint), examples (meson build of gprn and gprd, the Python build, then docs-examples), build (the site build) and lychee. The deploy job publishes docs/build from main when the repository is public and the variable DOCS_DEPLOY is true.

To deploy a tagged release’s documentation once the repository is public, select main in the Build GPRidge docs workflow and choose Run workflow. The reference checks, executable examples and site build must succeed. Both manual runs and pushes to main use the same deployment setting.

.lychee.toml accepts status 200, 204, 206 and 429. It skips localhost, the site’s own address gpridge.rgoswami.me (the pages resolve only after a deploy), changelog issue and tag links, a private reproduction repository and publishers that refuse automated requests (doi.org, pubs.acs.org and onlinelibrary.wiley.com).

The code-block runner also runs under the build systems. Meson registers one test per page named docs_example_<page> and docs_example_lint in the docs suite (a build with -Dwith_tests=true and -Duse_readcon=true on Linux). A meson test runs the blocks of a page up to the first python block, because the blocks of a page share one working directory and a later block can read a file that the Python block wrote; a page that starts with a python block has no meson test. python/tests/test_docs_examples.py runs every page end to end, Python and shell blocks in one session, under pytest.

Code blocks in pages

The runner scripts/run_doc_examples.py executes each page under docs/orgmode in a scratch directory. python blocks share one interpreter. bash and sh blocks share one shell, started with set -euo pipefail, and see the repository root in GPRIDGE_ROOT. c, cpp and fortran blocks are complete programs, compiled against the build tree’s libgpridge. Show the output of a block in a #+begin_example block next to it, and keep a block’s code free of a prompt character.

A block that must not run carries a reason in its header. The header arguments are:

Header

Effect

:eval no :why REASON

Do not run the block. The reason is required and the lint checks it. Use it for fragments, output listings and steps that need hardware or a download.

:needs-env NAME

Run only when the environment variable is set and not empty.

:requires mod1,mod2

Run only when the Python modules import.

:needs-bin NAME

Run only when the program is found; gprn and gprd resolve to the build tree.

:expect REGEX

The standard output must match the regular expression.

:needs-option NAME

Run only when the meson build has the option on, for example use_capnp.

:needs-hdf5

Run only when the meson build has use_hdf5 on.

:needs-build

Skip the block when no build tree was passed, including under --strict.

:needs-install

Run only when an installed prefix was passed with --prefix, as in the installed-library step of scripts/ci_docs_tests.sh. R_LIBS_USER then names an R library in the scratch directory.

:file NAME

Write the block to NAME in the scratch directory so a later block can read it.

A #+DOC_OUTPUT: line directly before a #+begin_example block states what the nearest preceding runnable block prints, and the runner checks it. Every line of the listing must appear, in order, in the output. A number agrees to the precision it prints. Write a value that depends on the machine or the build as <s> (a real number), <n> (an integer), <positive integer>, <version> or <reason>. A line with only ... stands for any lines.

For example, a block of bash that installs software ends with the header :eval no :why installs packages.

Page types

Write one kind of page at a time. The reader’s question decides the kind, and the kind decides the directory.

Page type

Reader question

Where it lives

Tutorial

Can I finish one useful workflow?

tutorials/

How-to

How do I do this task?

howto/, and the getting-started/ pages

Explanation

Why does it work this way?

explanation/; the mathematics in explanation/theory/ and the formal-model notes in explanation/verification/

Reference

What is the exact option, symbol or format?

reference/, the generated C++ and Python API

Development

How is the code organised and changed?

development/, development/design/ and development/developer/

Rules by type:

  • A tutorial is linear and runs from start to finish. It leaves out design rationale, option catalogues and performance history, and links to the explanation, how-to or reference page instead.

  • A how-to page starts with the task, then the prerequisites and the smallest working command or code block. It may include an option table when the task needs those options.

  • An explanation page names the model or invariant first and then its consequences. It is not a recipe.

  • A reference page is complete and terse. Use the generated reference for signatures and flags. Write a reference page by hand only for a contract that the generated output cannot express, such as a file format or a cross-language interface.

  • A design page under development/design/ is developer reference. It starts with a status line, which is one of implemented, partially implemented, design intent or obsolete, and every file, symbol and test it names exists.

Every page, whatever its type, follows these conventions:

  • It starts with #+TITLE: and #+OPTIONS: toc:nil todo:nil num:nil author:nil.

  • Math is written in \( \) and \[ \], not in dollar signs.

  • A link to another page is [[file:../howto/gpneb.org][text]], relative to the current file. A link to code in the repository is a path in verbatim markup, or a URL for a page outside the repository.

  • It is listed in a toctree (the main one is in docs/orgmode/index.org, and an index page lists its children).

  • State the status honestly: say what is implemented, what is a design, and what has not been measured. Give a unit for every number and a source for every measurement, or state the claim without the number.

Plain prose is the style. Do not use promotional adjectives or intensifiers, rhetorical questions or exclamation marks. A how-to or reference page does not use “we” or “our”.

Naming for chemists and ASE users

Tutorials and how-to pages use the ASE-facing names:

  • GaussianProcess for the trainable surrogate and ASE calculator.

  • GPNEB for path searches over a list of images.

  • GPDimer for saddle refinement.

  • The options uncertainty”laplace”, =psis=True, use_delta=True and rff_features=N of GaussianProcess for the PSIS, Laplace-slice, Delta and RFF chain.

Use low-level names such as GaussianProcessRegression, Observation and AtomsConfiguration only in reference pages and in tutorials that teach the compatibility layer.