# Keeping the docs true

> This site documents one commit of the framework, FRAMEWORK_REF, and is checked against it: how to tell when a framework change made a page untrue, fix the page, move the commit, and run the same checks the site's CI runs.

Source: https://omardev29.github.io/rmp-docs/framework/contributing/docs.html

This site is its own repository, [omardev29/rmp-docs](https://github.com/omardev29/rmp-docs), and it documents one commit of the framework: the one written in its file `FRAMEWORK_REF`. Every page is checked against that commit, so the site cannot drift from the code by accident. It can only be behind it, and moving it forward is part of the work that changed the code.

## What the site checks

A page is an HTML fragment under `content/`, and the rules for writing one are in [AUTHORING.md](https://github.com/omardev29/rmp-docs/blob/main/AUTHORING.md). The first of them outranks the rest: a page may not say anything that is not true of the framework at `FRAMEWORK_REF`. Whatever a machine can check about that, the build checks:

- every `rmp` command a page shows exists and takes the argument it is given, read from `rmp help --json`;
- every name written in code — `rmp::`, an `RMP_` macro, a raylib function — is one the headers declare, and every path is a file of the framework or of a new game;
- every C and C++ block compiles against the framework's headers, and every `.toml` block goes through its `configure.py`;
- every sentence pinned to the source still holds, and every message quoted is one the framework prints;
- no count the framework can change is typed: the number of targets, examples or headers comes from the framework when the site is built.

A sentence about how the framework works inside is pinned to the code that makes it true, with `data-fw-grep` on its element, a file and a regular expression that has to match there:

```text
<p data-fw-grep="tools/rmp.py::GLOBAL_COMMANDS = \("new", "install", "update"\)">Three
commands act on the framework the rmp you typed belongs to …</p>
```

The day that line changes, the check fails and says which sentence to read again. A regular expression that spans from the function's head to the line meant, rather than matching the line alone, also fails when the line moves to another function.

## Running the checks

Clone the site next to the framework: it looks for the framework in `../raylib_multiplatform`, or wherever the environment variable RMP_FRAMEWORK or the option `--framework` says. The compile checks read the framework's compile commands, so configure them once:

```shell
git clone https://github.com/omardev29/rmp-docs ~/rmp-docs
(cd ~/raylib_multiplatform && python3 tools/configure.py && cmake --preset lint)
cd ~/rmp-docs
python3 tools/build.py check
python3 tools/build.py check --tier compile
python3 -m unittest discover -s tests
```

The first is every gate, in under a minute; `python3 tools/build.py gates` lists them with what each one says. The second adds every C and C++ block compiled against the framework, a block shown as a mistake run through the tool that has to refuse it, and every block held to the framework's style rules. The third is the site's own tests. `--tier project` also makes each tutorial's game with `rmp new` and builds and boots it after every page, which is what the site's CI runs, and takes minutes. `python3 tools/build.py serve` builds the site and serves it on `localhost:8040` to look at.

The framework checkout should be at `FRAMEWORK_REF`; the build says so when it is not, and when the framework has uncommitted changes.

## When a framework change makes a page untrue

The framework's `docs` job checks this site's `main` against every push and every pull request, with every block compiled. When the change breaks a page, the job says which page and why, as a warning: the framework is not held up by its documentation. A release tag is: on a tag, that job fails, and nothing is released while the site does not pass.

So a change to the public API, a command, an option or a message is followed by the pages it makes untrue, as part of the same piece of work:

1. Merge the framework's pull request. The site documents commits that are on the framework's `main`: its own CI fetches `FRAMEWORK_REF` from GitHub.
2. On a branch of the site, fix every page the warning named, and any page that says something the change made untrue that no check could see. Search the site for the name you changed.
3. Move `FRAMEWORK_REF` to the framework's commit, with the framework checked out at it:
   ```shell
   git -C ../raylib_multiplatform fetch origin
   git -C ../raylib_multiplatform switch --detach origin/main
   git -C ../raylib_multiplatform rev-parse HEAD > FRAMEWORK_REF
   ```
4. Run the checks above until they pass, and look at the pages you changed with `serve`.
5. Open the site's pull request. Its CI builds the framework's examples at that commit, runs every check with `--tier project`, looks at the built site in a browser, and on `main` deploys it.

The template of the framework's pull request has a box for this: the docs updated, and `FRAMEWORK_REF` moved, when a page changes.

## How far behind the site is

Every day, a workflow of the site checks its `main` against the framework's `main`, not against `FRAMEWORK_REF`, with every block compiled and every tutorial built. When that fails it opens one issue on the site's repository, *The docs do not pass against the framework's main*, comments on it every day it still fails, and closes it when they pass again. An open one means the next bump of `FRAMEWORK_REF` has pages to fix, and the issue's run says which.

Back to [Contributing](https://omardev29.github.io/rmp-docs/framework/contributing/index.html).
