Repository navigation
docs(site): generate an API tier for @memhtml/contracts from its TSDoc - #158
Conversation
Wire typedoc + typedoc-plugin-markdown + starlight-typedoc in apps/docs and publish one page per contracts module (edges, errors, paths, slug, types) under /api/, with a new packages/contracts/README.md as the tier's index. The generated directory is a build output and is gitignored. Two doc comments inside parseEntity's return-type literal let the plugin render it as a fenced block instead of escaped prose, which is what the authored-page MDX-brace probe requires of every page under src/content/docs.
|
Local gate on this branch at Browser gates with |
There was a problem hiding this comment.
🟡 Changes recommended
The parseEntity doc comment currently contradicts the actual behavior (and tests), which will publish misleading API docs.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds an API documentation tier to the docs site by generating Starlight pages from the TSDoc of @memhtml/contracts (one page per module plus an index), and wiring it into the docs build and sidebar so it’s available under /api/.
Changes:
- Add TypeDoc + markdown tooling (
typedoc,typedoc-plugin-markdown,starlight-typedoc) toapps/docsand lockfile. - Configure
apps/docsto generate/api/docs from the five@memhtml/contractsmodule entry points duringastro check/astro build, and add an “API” sidebar group. - Add a
packages/contracts/README.mdto serve as the API index and adjustparseEntity’s return type doc comments to improve generated output.
File summaries
| File | Description |
|---|---|
| pnpm-lock.yaml | Locks new docs-generation dependencies (TypeDoc + Starlight integration) for apps/docs. |
| packages/contracts/src/types.ts | Adds TSDoc inside parseEntity’s return type to improve the generated API markdown. |
| packages/contracts/README.md | New package README used as the /api/ index content when merging into TypeDoc output. |
| apps/docs/package.json | Adds devDependencies needed to generate the API tier. |
| apps/docs/astro.config.ts | Configures starlight-typedoc generation and adds an “API” sidebar group. |
| .gitignore | Ignores generated API markdown output under apps/docs/src/content/docs/api/. |
Review details
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
- Files reviewed: 4/6 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @@ -116,7 +116,14 @@ export const ENTITY_SEPARATOR = ":" | |||
| /** Split an entity reference into its type and name. Absent separator ⇒ `None` type. */ | |||
There was a problem hiding this comment.
Agreed, and the sentence was pre-existing rather than added here, but this PR is what publishes it. Fixed in 6a37809: the summary now says the function splits at the first separator and returns undefined when there is no separator or when either side of it is empty, which is what types.test.ts asserts. The generated /api/types/ page carries the new sentence (rebuilt locally, docs tier 146/146).
Copilot review on #158: the summary sentence contradicted the implementation and packages/contracts/tests/types.test.ts, and the API tier publishes it.
Third slice of the generated reference, after contracts (#158) and traces (#164): one more starlightTypeDoc instance writing api/eval/ from the package's single import path, a package README that opens the generated page and maps each exported symbol to its module, a row in the tier index, and a sidebar group. Measured on the branch: typedoc CLI exit 0 with one warning (AccessSpec referenced by CorpusSpec.access but not exported from index.ts, recorded in the config comment and left to the source), brace probe 0 hits over api/, astro build exit 0, a11y 33/33 and Lighthouse 5 URLs x 3 runs green with /api/eval/ temporarily in the gate lists and then restored, mise run check 64/64.
What
The docs site gains an API tier generated from the TSDoc on
@memhtml/contracts: one page per module (edges,errors,paths,slug,types) plus an index built from a newpackages/contracts/README.md, at/api/. This is the first slice of TSDoc publication; contracts is the smallest package (imports onlyeffect) and the one the rest of the workspace agrees on, so it goes first. Widening to the other packages is one package per follow-up.Stack, all in
apps/docsdevDependencies:typedoc@^0.28.20+typedoc-plugin-markdown@^4.13.0+starlight-typedoc@^0.23.1. TypeDoc runs on apps/docs's own TypeScript 6.0.3 (the repo root pins 7.0.2, which no TypeDoc release peers on yet) againstpackages/contracts/tsconfig.json. Every published version is past the 3-day soak (2026-07-05, 2026-08-25, 2026-08-12).Shape
src/content/docs/api/on everyastro check/astro build; the directory is gitignored (the TSDoc is the source, the Markdown is a build output). cspell (useGitignore) and dprint both skip it, measured.outputFileStrategy: "modules",useCodeBlocks,parametersFormat: "list",excludeExternals,disableSources, README merged as the index. Each choice is explained in the config comment; the two that matter most:parseEntity's return type literal inpackages/contracts/src/types.ts: the plugin renders an object-literal type as escaped\{ … \}prose unless the literal's members are documented, andapps/docs/tests/figures.test.tsholds every.mdundersrc/content/docsto "no brace outside code". With both, all six pages carry zero braces outside code spans and fences. The comment edit is documentation only; the annotation is unchanged in meaning (biome reflowed it).disableSources: true: the sevenSchema.TaggedErrorclasses inherit a constructor whose source TypeDoc records as a path intonode_modules, and no link template produces a real URL for it.excludeExternalsdoes not drop inherited members andexcludeNotDocumentedskips inherited members by design (verified with--excludeNotDocumentedKinds Constructor). The line numbers are the loss; the module is never in doubt because each page is one module.{ autogenerate: { directory: "api" } }group after Reference. The plugin'stypeDocSidebarGroupbuilds one group per module and fills each from a per-member directory, so under the modules strategy every group renders empty (measured on build 2).#heading: Starlight renders the frontmatter title as the h1, andstatic-crawl.test.tsrequires exactly one.Proof
Local, on this branch, logs in the maintenance workspace:
/api/types/TEMPORARILY added toAUDITED_PAGESandlighthouserc.json(reverted before commit, so no test/gate file changes here):test:a11y33/33 (axe + layout stability),test:budget5 URLs x 3 runs, no assertion failures against the existing thresholds (performance ≥0.9, a11y ≥0.95, best-practices ≥0.95, SEO 1, ≤120 kB).mise run checkon the branch: see the last commit's CI, and the local run recorded in the PR comment below.Not in this PR (for the maintainer)
/api/types/should joinAUDITED_PAGESpermanently as a fifth template (generated Markdown with long code blocks and parameter lists). It passes today; adding it changessrc/gates.tsandlighthouserc.json, which this PR deliberately does not touch.sourcesto paths underbasePath, or@hideconstructoron the error classes once the Reference tier's doc-comment cleaner strips modifier tags (today it would print the tag on/reference/contracts/).