Skip to content

docs(site): generate an API tier for @memhtml/contracts from its TSDoc - #158

Merged
laithalsaadoon merged 2 commits into
mainfrom
docs/typedoc-contracts
Sep 7, 2026
Merged

laithalsaadoon merged 2 commits into
mainfrom
docs/typedoc-contracts

Conversation

@laithalsaadoon

Copy link
Copy Markdown
Contributor

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 new packages/contracts/README.md, at /api/. This is the first slice of TSDoc publication; contracts is the smallest package (imports only effect) 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/docs devDependencies: 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) against packages/contracts/tsconfig.json. Every published version is past the 3-day soak (2026-07-05, 2026-08-25, 2026-08-12).

Shape

  • Generated into src/content/docs/api/ on every astro 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:
    • list, not table, for parameters, and two doc comments added inside parseEntity's return type literal in packages/contracts/src/types.ts: the plugin renders an object-literal type as escaped \{ … \} prose unless the literal's members are documented, and apps/docs/tests/figures.test.ts holds every .md under src/content/docs to "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 seven Schema.TaggedError classes inherit a constructor whose source TypeDoc records as a path into node_modules, and no link template produces a real URL for it. excludeExternals does not drop inherited members and excludeNotDocumented skips 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.
  • Sidebar: a plain { autogenerate: { directory: "api" } } group after Reference. The plugin's typeDocSidebarGroup builds 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).
  • The README opens with a paragraph rather than an # heading: Starlight renders the frontmatter title as the h1, and static-crawl.test.ts requires exactly one.

Proof

Local, on this branch, logs in the maintenance workspace:

  • apps/docs vitest tier: 146/146.
  • Browser tier with /api/types/ TEMPORARILY added to AUDITED_PAGES and lighthouserc.json (reverted before commit, so no test/gate file changes here): test:a11y 33/33 (axe + layout stability), test:budget 5 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 check on 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)

  • Whether /api/types/ should join AUDITED_PAGES permanently as a fifth template (generated Markdown with long code blocks and parameter lists). It passes today; adding it changes src/gates.ts and lighthouserc.json, which this PR deliberately does not touch.
  • "Defined in" links. Options when wanted: a small local TypeDoc plugin filtering sources to paths under basePath, or @hideconstructor on the error classes once the Reference tier's doc-comment cleaner strips modifier tags (today it would print the tag on /reference/contracts/).

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.
Copilot AI lite review requested due to automatic review settings September 7, 2026 07:28
@laithalsaadoon

Copy link
Copy Markdown
Contributor Author

Local gate on this branch at 1d5dbb9: mise run check exit 0, 64/64 tasks, 3m23s (log kept in the maintenance workspace as artifacts/2026-09-07/check-typedoc-contracts.log.gz). Baseline on main at fb3218f before the change: exit 0, 64/64, 3m34s.

Browser gates with /api/types/ temporarily audited (edits reverted, not in this diff): test:a11y 33/33, test:budget 5 URLs x 3 runs with no assertion failures.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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) to apps/docs and lockfile.
  • Configure apps/docs to generate /api/ docs from the five @memhtml/contracts module entry points during astro check / astro build, and add an “API” sidebar group.
  • Add a packages/contracts/README.md to serve as the API index and adjust parseEntity’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.

Comment thread packages/contracts/src/types.ts Outdated
@@ -116,7 +116,14 @@ export const ENTITY_SEPARATOR = ":"
/** Split an entity reference into its type and name. Absent separator ⇒ `None` type. */

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@laithalsaadoon
laithalsaadoon merged commit 193fed0 into main Sep 7, 2026
11 checks passed
@laithalsaadoon
laithalsaadoon deleted the docs/typedoc-contracts branch September 7, 2026 07:50
laithalsaadoon added a commit that referenced this pull request Sep 9, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants