wiki-authoring.md 9.8 KB

Wiki authoring guide

How to add a page or a series to the wiki in docs/wiki/, what a lesson page looks like, how long a page may be, and the exact steps that keep the navigation honest. This describes what the repository does today and what its tests enforce (issue #563, epic #558). If this guide and a test disagree, the test wins; fix the guide.

The pages in docs/wiki/ are published to the GitHub wiki by the publish step, so edit them here by pull request. Edits made in the wiki editor are overwritten on the next publish.

Prose rules

  • American English (defense, color, license). tests/test_american_english.py flags a conservative list of British spellings.
  • No em dashes. tests/test_lesson_guards.py checks every lesson page.
  • No real addresses, identifiers or secrets. Use documentation placeholders; scripts/identifier_check.py scans for identifiers.
  • Say what was run and what was not. Do not write "verified" for something you only read.

The page template

A lesson page is built from these parts, in this order. The OpenTofu from zero hub, docs/wiki/OpenTofu-From-Zero.md, is the model for the top of a page.

  1. A first heading and a one-paragraph introduction. Say where the page sits ("Side page to ...", "Read it after X and before Y") and end with a Next: link.
  2. The glossary pointer, as a quote line: > Unfamiliar word or acronym? The [Glossary](Glossary.md) defines it.
  3. A status banner, a quote block that starts > **Status: and says what was run and what was not, with a date inside the banner. This is the honesty line for the whole page. A page the author only read says so ("written from reading"); a page described as an unverified draft says "unverified draft". tests/test_lesson_guards.py fails a lesson without a dated banner that says what was or was not run.
  4. Prerequisites, a quote block that starts > **Prerequisites.**: what the reader needs to have, installed or read first, with links, and the time the page takes. Mark every time you did not measure as an estimate with (est.), for example "About three hours for everything (est.)". A time you timed yourself is stated without the mark.
  5. The body, in ## sections. Link a sibling lesson as a link, never as plain text.
  6. An exercise for a lesson that teaches a skill. Each exercise follows predict, do, check, undo, and the page says how to put the machine back. Mark a command you did not run with est.; the guards look for the mark when the banner says something was not run.
  7. A checkpoint (what the reader can now do) and, when the page leans on outside facts, a claims register: a table of claim, source and status, with the date each source was read.

Not every page needs every part. A short reference page may have only the first four. A page with no exercise must still carry the banner and the prerequisites.

Also, in the same pull request:

  • Add the page's new terms to the Glossary. A row goes on the letter page Glossary-<letters>.md that holds its first letter; Glossary.md is only the index.
  • Link the page from the pages that should lead to it, and name the siblings it follows and precedes.
  • Add it to docs/wiki/Reading-Order.md if it belongs on a path. That page is written by hand, not generated, and tests/test_wiki_navigation.py fails a page that is linked from neither Contents nor Reading-Order.

A series or one page

Write one page when the topic is one idea, a reader finishes it in one sitting, and it stays inside the size guideline below.

Write a series (one hub and numbered parts) when the topic is a sequence of lessons or exercises that a reader will do on different days, when one page would pass the size guideline, or when an existing page has grown past it. A series is also how a long page is split (see the split pattern below). Do not split to hide a long page: each part has to be a page a reader can start on and finish.

The size guideline

  • A page is kept under about 450 lines. This is the line each part of a split page stays under.
  • No page may be over 1,000 lines. tests/test_wiki_size_guideline.py enforces this.
  • A page is counted by its author text: the generated navigation and contents blocks are not counted.
  • Four pages were over 1,000 lines when the test was written. They are on an allowlist in the test, LONG_PAGES, with their line counts, and the allowlist only goes down. A page on it may not grow; a page that drops to 1,000 lines or fewer must be removed from it (the test fails until it is); a page that gets shorter but stays over must have its recorded count lowered. Never add a page to the allowlist: split it. The splits are tracked under issue #562.
  • The generated pages (Contents, _Sidebar, Home) are counted like any other, and all three are well under the limit, so none is excluded.

The split-page pattern

Seven long pages are being split under issue #562: the Glossary (an index and letter pages) and six lessons. The merged OpenTofu-From-Zero hub and its four parts are the model; the Build and Destroy, Plans, Rate limiting, Secrets from day one and IDS and IPS lessons follow the same hub-and-parts pattern.

  • The hub keeps the original page name and URL, so every inbound link and every search result still lands somewhere that explains the lesson. It holds the introduction, the glossary pointer, the status banner and the prerequisites, then a ## The parts section that lists every part in order with a one-line summary each, then an index that links straight to the headings (such as each exercise) inside the parts.
  • Parts are named <Stem>-Part-N-<Topic>.md, where <Stem> is the hub's file name without .md, for example OpenTofu-From-Zero-Part-2-Exercises-3-to-6-Plan-Symbols-State-Count-and-Modules.md.
  • Each part starts with its H1, then one line ("Part 2 of 4 of the hub: ...") that links back to the hub, then ## sections. The part's first heading is the only H1; the exercises inside are ###.
  • Each part stays under about 450 lines. The text moves verbatim; a split does not rewrite the lesson.
  • Links into the lesson name the part that holds the heading. A link from another page, the Glossary or the lesson itself to a heading goes to the part page, not to the hub with an anchor, because the heading no longer lives on the hub (the hub's own anchor is #the-parts).
  • One series in the manifest: the hub and the parts share a series value, the hub entry is first, and the parts follow in order (see the next section).
  • A split test per lesson, as in tests/test_opentofu_from_zero_split.py: the hub lists every part, each part links back to the hub and is under the line cap, the manifest holds them as one series with the hub first, and every anchor the hub indexes is a heading of the part it names. A record-based test in tests/test_stale_sibling_statements.py checks the text moved verbatim.

The manifest steps

The navigation manifest is the directory docs/wiki/_nav/: index.yaml holds the groups, links, readers and goals, and one <group id>.yaml per group holds that group's page entries, one line each. The header of index.yaml explains every field; this is the order of work.

  1. Write the page in docs/wiki/.
  2. Decide the group. The group ids are the groups listed in docs/wiki/_nav/index.yaml (core, foundations, defend, privacy, grc, build, tools, runs, reference and start). Most new lessons go in a track group (foundations, defend, privacy, grc or build).
  3. Add one line to that group's file, docs/wiki/_nav/<group>.yaml, for example:

    - {page: Page-File-Name-Without-md, title: "Short title", audience: "learner", subgroup: "Theme", desc: "One line: what the page is for and who it is for."}
    

page is the file name without .md; audience is one of everyone, newcomer, learner, builder, engineer, operator or security reader. The optional status copies the page's own banner and is never invented: draft for an unverified draft, est. steps for steps written from reading and not run, unbuilt for something not built or not applied. Leave it out when the banner makes none of those claims. Keep title to 80 characters and desc to 220, on one plain line without a |.

  1. For a series, give every entry of the hub and its parts the same series: "Name" value, hub first, parts in order, with the part pages following one another in the same group file. The sidebar folds the series into one line; Contents, Home and the previous and next links still list every page.
  2. Regenerate the generated files, then check them:

    python -I scripts/gen_wiki_nav.py
    python -I scripts/gen_wiki_nav.py --check
    

The first command rewrites docs/wiki/Contents.md, docs/wiki/_Sidebar.md, the page map on docs/wiki/Home.md (only the block between its generated markers) and the in-page contents block of any page over 300 lines. The second exits 0 when everything is current and exits 1 with a message when something is stale. CI runs the second command.

  1. Commit the page, its manifest line and the regenerated files together.

scripts/gen_wiki_nav.py does not write docs/wiki/Reading-Order.md or any page's body. It writes the generated blocks above, and it removes the navigation blocks from page files (the previous and next links and the breadcrumb are added at publish time, not stored).

Before you push

Run the checks that cover your change, not the whole suite (CI runs that):

python -I scripts/gen_wiki_nav.py --check
python -I scripts/identifier_check.py --root .
python -I -m pytest tests/test_wiki_size_guideline.py tests/test_wiki_navigation.py tests/test_wiki_nav_manifest.py -q
ruff check scripts tests

Add the tests for the lesson itself when you add or split one (the split test above, and a row in tests/lesson_guard_data.py for a lesson with a claims register). A failing check is fixed, never skipped or loosened.