|
| 1 | +# Rocq-Elpi reference manual |
| 2 | + |
| 3 | +This directory holds the Sphinx-based reference manual published at |
| 4 | +<https://lpcic.github.io/coq-elpi/refman/>. |
| 5 | + |
| 6 | +## Source layout |
| 7 | + |
| 8 | +Only `docs/base/` is tracked by git; everything else under `docs/` is |
| 9 | +generated and gitignored. |
| 10 | + |
| 11 | +- `docs/base/conf.py` — Sphinx configuration: registers the custom |
| 12 | + lexers/roles/directive below, sets the theme (`sphinx_rtd_theme`), etc. |
| 13 | +- `docs/base/_pygments_elpi.py` — a Pygments lexer for Elpi, and for Rocq |
| 14 | + with embedded `lp:{{ ... }}` Elpi quotations, used both for |
| 15 | + `.. code-block::`/`:e:`-style highlighting and by `_rocqtop_elpi.py` below. |
| 16 | +- `docs/base/_roles_elpi.py` — custom roles (`:builtin:`, `:stdlib:`, |
| 17 | + `:type:`, `:lib:`, ...) that link a predicate/type/macro name to its |
| 18 | + declaration in `builtin-doc/*.elpi` or `elpi/*.elpi`, resolved locally via |
| 19 | + `git log` (no network access at build time). |
| 20 | +- `docs/base/_rocqtop_elpi.py` — the `.. rocqtop::` directive: spawns a real |
| 21 | + `rocq top` process and feeds it the block's Rocq/Elpi sentences one at a |
| 22 | + time, rendering the sentence together with its *actually captured* output. |
| 23 | + This is what every tutorial/example page uses for its code samples instead |
| 24 | + of static transcripts, so a sample that no longer compiles breaks the |
| 25 | + build rather than silently going stale. |
| 26 | +- `docs/base/index.rst`, `getting-started.rst`, `apps.rst`, |
| 27 | + `tutorials/`, `reference/`, `examples/` — the manual's actual content. |
| 28 | +- `docs/base/_static/custom.css` — small CSS additions on top of the theme |
| 29 | + (ANSI colors for `.. rocqtop::` output, Elpi-specific token colors, ...). |
| 30 | + |
| 31 | +## Building |
| 32 | + |
| 33 | +``` |
| 34 | +make refman-build |
| 35 | +``` |
| 36 | + |
| 37 | +(from the repository root) does, in order: |
| 38 | + |
| 39 | +1. `dune build -p rocq-elpi @install` — builds the `.install` files |
| 40 | + `dune install` (next step) needs; without it, `dune install` fails with |
| 41 | + `<package>.install are missing` unless some earlier, unrelated full |
| 42 | + `dune build` happened to already produce them. |
| 43 | +2. `dune build builtin-doc` — `_roles_elpi.py` reads `builtin-doc/*.elpi` |
| 44 | + straight off disk, so it must exist and be up to date. |
| 45 | +3. `dune install rocq-elpi` — installs Rocq-Elpi into the current opam |
| 46 | + switch. This is required (not just building it in place) because |
| 47 | + `.. rocqtop::` spawns a real `rocq top` that loads `From elpi Require |
| 48 | + Import elpi.` the same way an end user's opam switch would. |
| 49 | +4. Copies `docs/base/` to `docs/source/` (gitignored), substituting |
| 50 | + `@@VERSION@@` in `conf.py` with `git describe --always`. |
| 51 | +5. Runs `sphinx-build -q -W -b html docs/source docs/build`. `-W` turns |
| 52 | + every warning into a hard build failure — a broken `:builtin:`/`:doc:` |
| 53 | + reference, a `.. rocqtop::` sentence that errors out, or a dangling |
| 54 | + toctree entry all fail the build rather than degrading quietly. |
| 55 | + |
| 56 | +`docs/source/` and `docs/build/` are both deleted and recreated on every |
| 57 | +run; never edit files there by hand. |
| 58 | + |
| 59 | +Requirements beyond the repository's usual opam/dune setup: `Sphinx` and |
| 60 | +`sphinx-rtd-theme` (`pip install Sphinx sphinx-rtd-theme`), installed into |
| 61 | +whichever Python `sphinx-build` resolves to on `$PATH`. |
| 62 | + |
| 63 | +To build and preview locally: |
| 64 | + |
| 65 | +``` |
| 66 | +make refman-serve # builds, then serves docs/build/ on http://localhost:8000 |
| 67 | +``` |
| 68 | + |
| 69 | +## Deployment |
| 70 | + |
| 71 | +`.github/workflows/doc.yml` runs on every push/PR to `master`. On `master` |
| 72 | +it builds **two** things and deploys them together to the `gh-pages` branch |
| 73 | +(published at <https://lpcic.github.io/coq-elpi/>): |
| 74 | + |
| 75 | +- `make doc` — the older per-tutorial pages rendered with |
| 76 | + [Alectryon](https://github.com/cpitclaudel/alectryon) from |
| 77 | + `examples/tutorial_*.v`, output to `doc/`. These keep their original, |
| 78 | + already-linked-elsewhere paths, e.g. |
| 79 | + `https://lpcic.github.io/coq-elpi/tutorial_elpi_lang.html` — every new |
| 80 | + manual tutorial page links back to its Alectryon-rendered original via a |
| 81 | + `.. seealso::` note, so these paths must not move. |
| 82 | +- `make refman-build` — this Sphinx manual, output to `docs/build/`, copied |
| 83 | + into the deployed site under `refman/`, i.e. |
| 84 | + `https://lpcic.github.io/coq-elpi/refman/`. |
| 85 | + |
| 86 | +The workflow's `combine docs for deployment` step lays both out under one |
| 87 | +`site/` directory (`doc/*` at the root, `docs/build/*` under `site/refman/`) |
| 88 | +before handing it to `JamesIves/github-pages-deploy-action`, which force-pushes |
| 89 | +`site/` as the full contents of the `gh-pages` branch. |
0 commit comments