Contributing to the docs

Writing pages for this site, and the checks they must pass.

6 min read

How to add or edit a page, and the checks every change must pass. The site lives in apps/web/: a Foldkit app built with Vite and Bun. Pages are Markdown, compiled and prerendered to static HTML at build time. The lint, format and task configs are at the repo root, generated by shoemaker from shoemaker.config.ts.

sh
just web-dev     # dev server at http://localhost:4321 with hot reload, plus the Command Center
just ts-check    # content check, oxlint, tsc, oxfmt, jscpd, knip, vitest
just web-build   # ts-check, then the static build into apps/web/dist/client/
just ts-fix      # oxlint's autofixes, then oxfmt
just web-deploy  # build and deploy to Cloudflare (CI does this on every push to main)

Code changes have checks of their own: just ci runs the Rust checks, ts-check and Ruff on the Python, and just py-check adds ty, the Python type check.

Writing pages#

  • Where: .md files under apps/web/src/content/docs/. The file path is the URL (gpu/design.md is /gpu/design/) and the folder is the sidebar group. Group names and their order are in apps/web/src/content/pages.ts; old-URL redirects in apps/web/src/site/redirects.ts.

  • Frontmatter is flat key: value lines: title and description (required), order and label (optional).

  • Vocabulary: CommonMark plus GFM tables and strikethrough. Raw HTML, footnotes, task lists and reference-style links fail the build, with the file and line.

  • Links between pages are site-absolute with a trailing slash: /simulation/scenarios/#catalog. Anchors are GitHub-style heading slugs. The build fails on a broken internal link or anchor.

  • Code blocks are highlighted at build time by Shiki; give the fence a language.

Directives#

For anything richer than Markdown, use a directive. They're declared, with their attributes, in apps/web/src/site/islandAttributes.ts, and a typo fails the build.

DirectiveWhat it renders
:::Aside{type="note" title="…"} … :::A callout: note, tip, caution or danger
:::Steps around one ordered listNumbered steps on a rail
::::Tabs with :::Tab{label="…"} childrenTabs; the selection lives in the app's Model
::::Details whose first line is a ## headingA collapsible section, closed until clicked; links to a heading inside open it. Use :::: when it holds other directives
::::Cards with :::Card{title="…"} or ::LinkCard{title="…" href="/x/"}A card grid
:::FileTree around a nested listA file tree. Each item starts with its name in inline code (bold highlights it; … alone means "more"), then a note. Folders end in /; folders with entries collapse, open unless {folders="closed"}
::TrainingChart{run="selfplay/main-1v1-s11" metrics="sps"}A line chart from a run's metrics.jsonl, snapshotted at build time
::Explainer{name="policy"}An interactive figure from src/explainers/ (the ML primer's: loop, policy, discount, advantage, gae, clip, shaping, selfPlay, measuring)
::Replay{src="/replays/x.rlvsnap" title="…"}A 3D replay of a snapshot (physlab view … --export) in the web viewer, behind a Play button. Files go in apps/web/public/replays/; the build fails on a missing one. Optional camera: 0 free, 1–8 follow a car, 9 director (default)

An emphasis that starts with a colored circle is a status badge: *🟢 done*, *🟡 partial*, *⚪ not started*, *🔴 blocked*, *🔵 idea*.

Docs that live next to code#

A few Markdown files document the code beside them: vendor/rocketsim/PATCHES.md and bakkesmod-plugin/README.md. The site has its own pages for them (RocketSim patches, BakkesMod plugin), written from those files but not generated from them, so change both when either changes.

Working on the app#

  • Layout: src/main.ts (init, update, Commands, Subscriptions), src/model.ts, src/message.ts, src/route.ts, src/view/ (layout, Markdown views, directive views), src/content/pages.ts, src/search.ts. src/site/ holds modules shared with the build plugins in plugins/.

  • Style: Foldkit idioms (a pure update, side effects only as Commands, streams as Subscriptions) and Effect everywhere else: Match instead of switch, Effect FileSystem, Path, effect/http and effect/process instead of Node built-ins, Effect.try and Effect.tryPromise instead of try/catch and async/await, Schema to decode anything from outside.

  • Styling: Tailwind utility classes in the views, and no hand-written CSS. src/styles.css is only the Tailwind import and the @theme fonts. To style Markdown inside a directive, give its AST nodes their own classes in the views (src/view/directiveLists.ts does this for Steps and FileTree).

  • Lint and format: the root oxlint.config.ts runs every oxlint category at error with shoemaker's shared rules (the @effect/tsgo type-aware rules and anti-slop among them), plus Foldkit's. The repo keeps zero warnings: every rule is error or off, and each off carries a comment saying why. oxfmt formats everything except Markdown (oxfmt.config.ts). Both cover every package.

  • Tests: vitest with @effect/vitest for Effect code and Foldkit's story helpers for update (bun run test).

  • Foldkit reference offline: a clone of the Foldkit repo in tmp/foldkit has its docs site source and every example app.

The Command Center (/command-center/) exists only on the dev server: its API is a Vite dev server plugin, and a static build leaves it out.

Deploying#

The site is deployed to Cloudflare as static files at https://rocket-ml.ethanshoe.dev, open to anyone. Every cloud resource, the site and the R2 bucket for runs/, is in one Alchemy stack, alchemy.run.ts. Once CI passes on main, .github/workflows/deploy.yml downloads the chart data from R2 (just runs-pull-charts), builds the viewer and deploys the stack. Run that workflow by hand to pick up newly pushed chart data. Alchemy compares each resource with what is deployed and only changes what differs.

One-time setup:

  1. In the Cloudflare dashboard, turn on R2 (it asks for a payment method even for the free tier).

  2. Make the personal alchemy profile and put ALCHEMY_PROFILE=personal in .env.local: bun alchemy profile edit --profile personal --add Cloudflare with an API token that can create API tokens (API Tokens Edit) or the Global API Key, and bun alchemy profile edit --profile personal --add GitHub after gh auth login with the repo scope. Then just web-deploy creates the site and the bucket, and bun run infra:github (stacks/github.ts) mints CI's Cloudflare token and writes it and the account id to the repository's secrets. CI never runs that stack, so its token can't create tokens.

  3. Under R2, create two API tokens for the bucket: Object Read only (CI) and Object Read & Write (your machine). Each shows an Access Key ID and a Secret Access Key.

  4. Store CI's pair in the repository's secrets with gh secret set: R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY. Put the read-write pair in Infisical as R2_ACCOUNT_ID, R2_ACCESS_KEY_ID and R2_SECRET_ACCESS_KEY to use just runs-push and just runs-pull. Set INFISICAL_DOMAIN, INFISICAL_PROJECT_ID, INFISICAL_CLIENT_ID and INFISICAL_CLIENT_SECRET in your machine's environment; .env.schema lists every variable.

The deployed site's ::Replay players use just rlviser-web-public, the viewer without Rocket League's assets (see RLViser replay); CI builds it before the site. A deploy refuses any other viewer build in apps/web/public/rlviser/, such as just rlviser-web's.