Maintaining this documentation
This page is for people working on Carta itself.
How the site works
infra/docs-site/server.mjs is a small node:http server (markdown-it, github-slugger, highlight.js) that turns documentation/ into a site with sidebar navigation, search, a per-page outline and dark mode. Nothing is pre-built: HTML is produced per request and cached.
- Rendering: markdown-it with raw HTML disabled. Headings get GitHub-compatible ids, so
file.md#headinglinks work on GitHub and on the site. Blockquotes that start with**Note**,**Tip**,**Important**,**Warning**or**Caution**become styled callouts. External links open in a new tab; images lazy-load. - Navigation: built from
documentation/README.md. Each##is a sidebar group, each###a subgroup, and the first.mdlink in each list item is an entry. That order also drives the Previous/Next links. Pages not linked from the README appear under Other pages. - Search: a JSON index of every page, filtered in the browser by
public/app.js. - Live editing: pages are cached by file modification time and the site index is rebuilt at most every 2 seconds, so a bind-mounted
documentation/updates live. - Raw source: every page links to its Markdown (
?raw). - Packaging:
infra/Dockerfile.docscopies the server anddocumentation/intonode:22-alpine(DOCS_DIR=/docs, port 3000,/healthzhealth check). Indocker-compose.ymlit's thedocsservice. SetDOCUMENTATION_URLto its public URL to show Docs in the public nav, Documentation in the footer and Help & documentation in the app sidebar. The public pages are prerendered, so it's passed to thewebbuild as well as its runtime environment; rebuildwebafter changing it.
Adding or changing a page
- Write the Markdown in the right folder. Start it with a single
#title. - Link it from
documentation/README.mdso it appears in the sidebar. - Reference screenshots as
../assets/screenshots/<area>/<name>.png, and add the capture toscripts/doc-shots.mjs(see below). - Check links (see below).
Screenshots
scripts/doc-shots.mjs drives a running Carta stack with playwright-core and headless Chromium. It walks the UI the way a user would and saves PNGs at the paths the Markdown references, under documentation/assets/screenshots/.
- Target data: the demo corporation Maple & Pine Holdings Inc. (
maple-pine) fromscripts/demo_seed.py, signed in as[email protected], and the platform admin[email protected]for the admin console. - Deterministic browser: every context is 1440×900, light colour scheme,
America/Torontotimezone,en-CAlocale. It uses the cached Playwright Chromium build 1248 in new headless mode, which renders the PDF previews; the headless shell or Playwright's default is the fallback. - Groups run in a fixed order:
public,shell,vault,registers,governance,settings,documents,compliance,administration,admin.publicandadminuse their own pages and sign-ins; the rest share one signed-in page.settingsfills in the corporation profile, whichdocumentsneeds. - Capture helper:
shot(page, file, target)takes the viewport, the full page ("full", which lets the app's scrolling<main>grow first) or a single element (a locator). - Locating UI: by role, label and placeholder (
getByRole, and afield(scope, label)helper that also handles labels not tied to their input), not CSS classes, so shots survive styling changes. - Data it creates: vault uploads, a debt obligation, settings values, a generated document (which locks the corporation's identity) and an invite code. Everything it names is prefixed Docs. Re-seed with
--resetbefore a clean run. - Failure handling: each step is wrapped so one failure doesn't stop the run; page errors and failed shots are printed as an ISSUES list at the end, and the exit code is non-zero.
scripts/shot.mjs is the quick version: sign in (or LOGIN=0, or LOGIN=admin) and screenshot a list of paths into a folder. Paths may contain {tenant}. Useful for checking a page, not for the docs.
Running it
-
Install the script dependency once:
cd scripts && npm install. -
Start the stack:
docker compose up -d. Publish the web and database ports (for example with an override file) so the scripts can reach them. -
Seed the demo data, then restart the web container so it brings the tenant schema up to date:
python3 scripts/demo_seed.py --reset # DB_HOST / DB_PORT if the database isn't on localhost:5432 docker compose restart web -
Regenerate screenshots:
node scripts/doc-shots.mjs, or only some groups with--only=vault,documents. OverrideBASE,EMAIL,PASSWORD,TENANT,ADMIN_EMAILorADMIN_PASSWORDas needed. -
Read the ISSUES list at the end, then review the PNG diffs in git before committing.
-
Preview the docs live:
docker build -f infra/Dockerfile.docs -t corpo-docs . docker run --rm -p 3001:3000 -v "$PWD/documentation:/docs:ro" corpo-docsOr run
node infra/docs-site/server.mjsdirectly (afternpm installininfra/docs-site); it defaults to../../documentationand port 3000 (PORTto change it). -
Check links against the running site:
node infra/docs-site/check-links.mjs http://localhost:3001/(ornpm run checkininfra/docs-site). -
Commit the Markdown and screenshots together.