Writing and Publishing the Docs
These docs live in the repository’s docs/ folder, next to the code they describe, as Markdown files, and publish to monogatari.io as the v2 docs with the restless-dreams command-line tool. This page holds the rules every page follows, so a page written next year reads like one written today.
Who reads them
Every page is written for one of four readers, and its section says which:
- Someone who has never made a game or a web page. They downloaded Monogatari and have a folder with an
index.html. They don’t know what a text editor, a browser console, a local server or a terminal is. Start Here is for them, and every other page links back to it for the basics. - A game developer who knows the basics and wants to do something specific or look something up. The Guides and the reference sections are for them.
- A developer extending the engine with their own actions, components or plugins. Extending Monogatari and the Engine API are for them.
- An engine maintainer who clones the repository to fix v2 or release a 2.8.x. This section is for them.
Never assume tools
IMPORTANT
"We must never assume users are able to run anything related to node, bun or npm. Some people even develop games on their phone so we must not assume capabilities."
In practice:
- The baseline reader has a browser and a way to edit text files, maybe only on a phone or tablet. No terminal, no Node, no Bun, no npm, no build step, no admin rights, maybe no desktop computer.
- Every task a game developer does gets a path that needs none of those, written first. Where something truly needs tools (the starter game’s
serve.tsandbuild-web.ts, the npm package, desktop builds with Electron or Electrobun), it goes in its own clearly labelled, optional part after the no-tools path, and says what it needs and why. Never write “runbun …” as a step a beginner must take. - Phones and tablets are real development environments. Say what an editor there must be able to do (open a folder, edit
.jsand.cssfiles); don’t name an app or service you haven’t checked does what the page says. - A served game is the supported way to run v2. Opened from the disk, v2 falls back where it can (audio plays through an
<audio>element, without its effects) and some features stop (save pictures, preloading, offline play). Every page that touches such a feature says what it needs and links the table in What works opened from a file. - Working on Monogatari is the exception: it assumes a computer with the repository’s toolchain, and says so at its top.
How the docs are organized
The folder is the navigation. Every folder has a README.md that is its landing page, and the frontmatter order sorts siblings in the sidebar. A section’s landing page takes the section’s number; pages inside a section are numbered 1, 2, 3… in reading order. Titles are Title Case (they’re the sidebar labels); headings inside a page are sentence case.
| Order | Folder | Title | For |
|---|---|---|---|
| 0 | README.md |
Welcome | everyone: what Monogatari is and where to start |
| 1 | start-here/ |
Start Here | the beginner: from a downloaded zip to a finished story |
| 2 | guides/ |
Guides | the game developer: telling the story and building the game around it |
| 3 | script-actions/ |
Script Actions | reference: every statement |
| 4 | components/ |
Components | reference: every interface element |
| 5 | configuration-options/ |
Configuration | reference: every setting and preference |
| 6 | style-and-design/ |
Style and Design | restyling a game |
| 7 | extending/ |
Extending Monogatari | writing actions, components and translations |
| 8 | engine-api/ |
Engine API | reference: the monogatari object and its events |
| 9 | help/ |
Help | errors, the FAQ, troubleshooting |
| 10 | upgrading/ |
Upgrading | moving a game from an older version |
| 11 | maintainers/ |
Working on Monogatari | engine maintainers |
docs/FORMAT.md has no title, so it’s never published; it points here. Images live in docs/assets/<section>/, and docs/styles/docs.css holds the shared page components.
A page
---
title: Writing and Publishing the Docs
order: 11
description: One plain sentence, used for search and as the page's meta description.
style: styles/docs.css
---
# Writing and Publishing the Docs
The first paragraph says what the page is for.titleis required: a file without one isn’t published.orderplaces the page among its siblings.descriptionis one plain sentence.style: styles/docs.cssonly on pages that use the shared components below. The path is relative todocs/, so it’s the same from every folder.
The site shows the title, not the first # heading, which stays for people reading the file on GitHub.
Check every claim against the code
- Never write a claim you haven’t checked. For each syntax, option, default, event, CSS class, variable, file path, command and behavior, find it in
src/,dist/,debug/,cypress/orpackage.json, and read the code that implements it, not only its comment. Earlier docs are a starting point, not a source. - Run what readers will copy. v2 has no test harness, so use a browser: copy
dist/to a scratch folder, change itsjs/script.js, serve it and play it; read the engine from the console (monogatari.state()); or write a scratch Cypress spec (Testing the Engine). - When the code and a doc disagree, the code wins. Document what v2 does today. When the code looks wrong, don’t document around it quietly: report it with the file and line.
- When you can’t verify something (a browser or platform you can’t run, a store’s rules), leave the claim out or say on the page that it hasn’t been tested.
How it reads
Write like a careful engineer explaining something to a colleague who’s new to it: plain, specific, warm without being chatty.
- Second person, present tense, active voice. “The text box shows the line.” “Add this to
js/script.js.” - Short sentences, concrete nouns. Name the file, the property, the button. One idea per paragraph.
- Define a term the first time a page uses it, or link to where it’s defined (Glossary).
- Show the result. After a step, say what the reader should see. After an option, say what changes.
- Examples are complete, with the real file names and the example’s real asset names.
- Headings say what’s under them, not “Overview” or “Introduction”.
What makes text read as machine-written
Leave these out:
- Openers and closers that say nothing: “In this guide, we’ll…”, “Let’s dive in”, “Now that you’ve…”, “In conclusion”, “Happy coding!”, “That’s it!”.
- Filler and hype: seamless(ly), robust, powerful, leverage, utilize, delve, effortless(ly), crucial, essential (as decoration), comprehensive, cutting-edge, game-changer, elevate, unleash, harness, a myriad of, plethora, navigate (except for navigation), journey, realm, tapestry, “unlock the full potential”.
- “Simply”, “just”, “easy”, “easily”, “obviously”, “of course”: they make a reader who’s stuck feel stupid.
- “Whether you’re X or Y…”, “It’s important to note that…”, “It’s worth noting…”, “Note that…” everywhere.
- Triplets for rhythm, rhetorical questions, and sentences that restate the heading.
- Em dashes. Use a comma, a colon, parentheses or two sentences. (An en dash in a range is fine: 2–4.)
- Emoji, exclamation marks outside quoted game text, and bold scattered through sentences.
- Summaries that repeat the page, “Key takeaways” boxes, and over-hedging.
- Community forums: they no longer exist, even though v2’s error dialog still links them.
What the docs site gives you
Admonitions:
> [!NOTE],> [!TIP],> [!WARNING](at the exact step where people go wrong),> [!DANGER],> [!IMPORTANT]. A few per page at most.Screenshots of the real v2 engine, captured from a scratch copy of
dist/, served or opened from the file:cp -r dist /tmp/game-shot (cd /tmp/game-shot && python3 -m http.server 8080) & restless-dreams capture "http://127.0.0.1:8080/" --wait 2500 --out /tmp/shot.png magick /tmp/shot.png -quality 90 docs/assets/<section>/<name>.webp--click,--evaland--wait-forreach a state,--selectorcrops to one element,--mobileand--darkchange the device (restless-dreams capture --helplists them). Stop the server afterwards (kill %1). Save every picture as WebP at quality 90 (ImageMagick’smagick, orcwebp -q 90): a screenshot is about a seventh of its PNG size, and every version of every picture stays in the repository’s history. Embed the image with alt text and a caption after a|:Images are public on the CDN, so put only engine UI and the project’s own sample art in them.
Mermaid (
```mermaid) for flows and life cycles: Architecture has several.Orbit maps (
```orbit) for a hierarchy the reader explores, like the engine map on this section’s landing page. Give eachtheme=materialon its fence, keep labels short (the material font is wide: at a height of 540, “Configuration” broke over two lines; 700 kept it whole), and check each withrestless-dreams orbit validate <file.md>. A map can’t link to a docs page, so link the pages from the prose around it.[TOC]on its own line, near the top of a long page.Tables for parameters, options, variables and classes; footnotes (
[^1]) for asides; icons (:icon[name]) sparingly.Code blocks always name their language:
js,ts,html,css,bash,json,text.Links are relative links to the
.mdfile ([Testing the Engine](/v2/maintainers/testing),../guides/README.md). Never/v2/…orhttps://monogatari.io/…for a docs page: the publisher adds the version prefix.
The shared components
docs/styles/docs.css styles a few components; a page opts in with style: styles/docs.css. Each wraps Markdown in an HTML block, and a blank line ends an HTML block, so keep the tags on their own lines with blank lines around the Markdown inside:
<div class="docs-steps">
1. Open `js/script.js`.
2. Change the first line of dialog.
3. Reload the page: the new line shows.
</div>| Component | Use it for |
|---|---|
<div class="docs-paths"> around a list of links |
cards for “where do you start” choices |
<div class="docs-steps"> around an ordered list |
a numbered stepper |
<div class="docs-compare"> around two blocks |
two columns, stacked on small screens |
<details class="docs-more"><summary>…</summary>…</details> |
an optional deep dive, or the answer to an exercise |
<kbd> |
a key, like Esc |
Don’t use <rd-tabs> or <rd-accordion> (the site loads no script for them), side-stripe accents, glows or hover lifts. When a page needs a component the stylesheet lacks, add it to docs/styles/docs.css for every page rather than writing a second stylesheet.
Moving a page
Published pages have addresses other sites link to (monogatari.io/v2/building-blocks/characters). When you move, rename, merge or delete a page, record the old and the new path so the old address can redirect, and search for links to the old one: in docs/, in README.md, in dist/js/script.js, and in debug/index.js, whose error dialogs link the docs. Until 2.9.0 those dialogs, and the starter game’s Help message in dist/js/script.js, linked the old documentation site, developers.monogatari.io; they link pages under https://monogatari.io/v2/ now, so a moved page needs its link changed there too.
Check and publish
Check the whole folder before you commit:
restless-dreams docs lint docs
restless-dreams orbit validate docs/maintainers/README.mddocs lint checks every page’s frontmatter, duplicate slugs, links to .md files that don’t exist and images missing from docs/assets/, prints what it found as JSON, and exits with 1 on an error. Files without a title are listed as warnings and skipped.
Publishing needs a restless-dreams token for the monogatari site. Preview first, then publish:
restless-dreams docs publish docs --feed v2 --version-group monogatari-docs --dry-run
restless-dreams docs publish docs --feed v2 --version-group monogatari-docsPublishing updates pages by their slug, so a page keeps its address and comments from one publish to the next, and uploads the images in docs/assets/ to the CDN, recording them in docs/assets-manifest.json by the hash of their content so later publishes only upload what changed; commit that file after publishing. --prune deletes published pages whose files are gone; without it they’re only listed. The site is rebuilt after the command returns: load a changed page a few minutes later to check it.