Skip to content
compodocx
Skip to article content

Guide 03

Usage

cngxjs (opens in new tab) Updated Guide 03 of 13

A few patterns we lean on. Every flag has a JSON-config equivalent.

Build once for CI

bash
npx compodocx -p tsconfig.doc.json

Writes to ./documentation/<versionLabel>/ by default. The label is read from the nearest package.json. Pass --no-multiVersion for a flat output.

Watch during authoring

bash
npx compodocx -p tsconfig.doc.json --watch --serve

The dev server reuses the same routing and theming as production. What you see locally matches what ships.

Multi-version with a custom label

bash
npx compodocx -p tsconfig.doc.json --versionLabel v1.4.0

Writes ./documentation/v1.4.0/ and updates ./documentation/versions.json. The manifest is append-only, deduplicated by label, and semver-sorted descending. The version-switcher in the navbar reads it at runtime, no extra wiring.

Wire into npm scripts (opens in new tab)

json package.json
"docs": "compodocx -p tsconfig.doc.json",
"docs:watch": "compodocx -p tsconfig.doc.json --watch --serve",
"docs:json": "compodocx -p tsconfig.doc.json --exportFormat json -d snapshots/",
"docs:llm": "compodocx -p tsconfig.doc.json --exportFormat llm-md"

API diff between snapshots

bash
npx compodocx -p tsconfig.doc.json --exportFormat json -d snapshots/next/
npx compodocx diff snapshots/prev/<label>/api.json snapshots/next/<label>/api.json

Exits 0 on no public-API change, 1 on additive changes, 2 on breaking changes (or fatal errors). Pipe the JSON output to your bot of choice for PR comments.

LLM context for code review

bash
npx compodocx -p tsconfig.doc.json --exportFormat llm-md

Without -d, writes to stdout. Pipe straight into llm, claude, or any tool that reads markdown. With -d, writes <output>/llm-context.md.