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) |
|
|
Contributing guide |
|
|
Command-line reference |
|
|
TOML key reference |
|
|
Fortran API |
|
|
C++ API |
the headers under |
Doxygen XML, then doxyrest, into |
Python API |
the package |
sphinx-autoapi into |
Bibliography |
|
sphinxcontrib-bibtex; cite with |
Changelog |
news fragments in |
towncrier writes |
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 ( |
What it does |
|---|---|
|
Exports every org file to RST with |
|
Fetch doxyrest at the revision pinned in |
|
In |
|
|
|
Download the doxyYoda 0.2.2 theme and build the standalone C++ HTML tree in |
|
Copy that tree to |
|
The whole sequence: |
|
Regenerate the TOML key page and the Fortran page. |
|
Run |
|
Check links in |
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.pythen 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 bareR_initialorn_imagesstays 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:nilin#+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 |
|
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 |
|
a registered flag has no |
Documented flags |
|
a |
Fortran page |
|
the committed page differs from what |
Block lint |
|
a |
Block coverage |
|
a documentation file that holds code is neither a runner source nor explained in |
Block run |
|
a block fails, an output listing differs from what its block prints, or a needed binary is missing under |
Docs tests |
|
any of the above, the installed-library run or the pytest suites fails |
Sphinx build |
|
any warning |
Links |
|
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 |
|---|---|
|
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. |
|
Run only when the environment variable is set and not empty. |
|
Run only when the Python modules import. |
|
Run only when the program is found; |
|
The standard output must match the regular expression. |
|
Run only when the meson build has the option on, for example |
|
Run only when the meson build has |
|
Skip the block when no build tree was passed, including under |
|
Run only when an installed prefix was passed with |
|
Write the block to |
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? |
|
How-to |
How do I do this task? |
|
Explanation |
Why does it work this way? |
|
Reference |
What is the exact option, symbol or format? |
|
Development |
How is the code organised and changed? |
|
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 inverbatimmarkup, or a URL for a page outside the repository.It is listed in a
toctree(the main one is indocs/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:
GaussianProcessfor the trainable surrogate and ASE calculator.GPNEBfor path searches over a list of images.GPDimerfor saddle refinement.The options
uncertainty”laplace”, =psis=True,use_delta=Trueandrff_features=NofGaussianProcessfor 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.