# Documentation Overview

---

# Overview

_Standards and Conventions / Documentation Overview_

> Peios is documented in seven forms (learn, man pages, command-line help, regman, evman, technical reference manuals, and specifications), each with its own reader, its own job, and its own place when two of them overlap.

Peios documentation comes in seven forms. Each one has a different reader
and answers a different question. Learn explains and help summarizes; each
of the other five forms is the authority for its own kind of fact.

| Form | Reader | Answers |
|---|---|---|
| **Learn** | Anyone getting oriented | Why does this exist, and how does it fit together? |
| **Man pages** | Users, administrators, and developers at the interface | Exactly what does this command, file, call, or function do? |
| **Command-line help** | Anyone at a prompt who needs a reminder | What does this program accept? |
| **regman** | Anyone reading or changing configuration | What does this registry key mean, and what values are valid? |
| **evman** | Anyone reading the event stream | What does this event, or this field, mean? |
| **Technical reference manuals** | Developers of one specific component | How does this component work inside? |
| **Specifications** | Anyone implementing or consuming a shared protocol or format | What must be true? |

## Learn

High-level, educational documentation. Learn is what you read when you want
to understand something: concepts, how the pieces fit, and guides that walk
through a task. Developer guides, such as how to package an application or
how to emit events, are learn, not reference.

Learn can describe an interface, but it is never the authority for one. Where
it touches a flag, a key, or an event, it links to the form that owns it.

## Man pages

Thorough technical documentation, still centered on the user. A man page is
where every flag, exit status, file, and environment variable is recorded,
including the edge cases learn leaves out. If you have forgotten something,
you read the man page.

Man pages are also the API reference: section 2 for system calls, section 3
for library functions.

Some overlap with learn is inevitable, and the set includes pages adopted
from other projects. Adopted pages are patched wherever Peios behaves
differently from upstream. Peios does not ship inaccurate documentation.

## Command-line help

The text a program prints for `--help`: one line for each command,
argument, and option, and a pointer to the man page. Help is a summary of
the man page, never a replacement for it, and the two must agree. The same
rules cover the version and error messages a program prints.

## regman

regman owns the documentation of every registry key and value: its type,
default, valid range, and what it applies to. Other forms do not document
configuration inline; they point at the regman page.

## evman

evman owns the documentation of every event and every event field. A field
with no evman definition is not part of the platform's vocabulary, and no
component is allowed to emit it.

## Technical reference manuals

Thorough systems documentation for the developers of one specific component:
its internal design, data structures, and behavior. A TRM describes one
implementation.

## Specifications

Specifications for the protocols and formats shared across Peios. A
specification states a contract that more than one party relies on.

The line between a TRM and a specification: if a second implementation, or a
consumer on the other side of the boundary, would need to know it, it belongs
in a specification. If it is true only of this implementation, it belongs in
the TRM. TRMs cite specifications rather than restating them.

## When forms overlap

Every fact has one authority:

- **Interface details** (flags, exit statuses, files, calls) belong to the man
  page. Help summarizes them and must agree with it.
- **Registry keys** belong to regman, and **events** to evman, without
  exception.
- **Shared contracts** belong to the specification, which wins over any TRM.
- **Learn** explains and links; it is never the source to quote.

---

# Publishing a Repository's Docs to Learn

_Standards and Conventions / Documentation Overview_

> Add a repository's docs/learn tree to the Learn site, and make each push that changes its documentation redeploy Learn.

Learn is built from the central `learn` repository and from a
`docs/learn/` tree in each component's repository. Follow these steps when
a repository first contributes pages, so that its documentation is
published and stays current.

## Before you start

- Lay out the repository's `docs/learn/` tree as Trail
  [merged trees](/trail/structuring-a-site/merged-trees.md) require: the same
  shelves, products, and containers as Learn, with identical metadata.
- Push the repository to GitHub.

## Add the repository to the site

1. In `learn/trail.toml`, add a `[[merge]]` table after the existing ones:

   ```toml
   [[merge]]
   repo = "https://github.com/peios/authd"
   dir = "docs/learn"
   path = "../authd/docs/learn"
   ```

   `repo` and `dir` are where Learn's deploy fetches the tree. `path` is
   the repository's checkout beside `learn/` in a workspace. Trail uses it
   when it exists, so `trail serve learn` shows local edits.

2. From the workspace root, build the combined site strictly:

   ```sh
   trail build learn --strict --out local/learn-site
   ```

   Fix any duplicate pages, mismatched containers, or broken links it
   reports.

3. Commit the change to `learn` and push it.

## Redeploy when its documentation changes

1. In the component's repository, add this file as
   `.github/workflows/update-learn.yml`:

   ```yaml
   name: Update Learn

   # Asks Learn to redeploy when this repository's documentation changes. The
   # same file goes in every repository that contributes to Learn.
   on:
       push:
           paths: ["docs/**"]

   permissions: {}

   jobs:
       dispatch:
           if: github.ref_name == github.event.repository.default_branch
           runs-on: ubuntu-latest
           steps:
               - run: gh api repos/peios/learn/dispatches -f event_type=docs-changed
                 env:
                     GH_TOKEN: ${{ secrets.LEARN_DISPATCH_TOKEN }}
   ```

   The file is the same in every repository. It runs only for pushes to
   the default branch that change `docs/`.

2. For a repository outside the `peios` organization, add a
   `LEARN_DISPATCH_TOKEN` repository secret. The `peios` organization
   provides the secret to its own repositories.

3. For a private repository, give Learn's `LEARN_READ_TOKEN` read access to
   its contents. Learn's deploy fetches the tree with that token.

## Check the result

Push a documentation change to the default branch. The repository's
**Update Learn** run succeeds, and a **Deploy to GitHub Pages** run starts
in `peios/learn`. When it finishes, the change is on learn.peios.org.
