Skip to content

Generate the JavaScript API docs page from JSDoc with docgen - #477

Merged
benschac merged 3 commits into
mainfrom
docs/generated-reference
Dec 1, 2026
Merged

benschac merged 3 commits into
mainfrom
docs/generated-reference

Conversation

@benschac

@benschac benschac commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

The public @prddd/contract/js entry now documents itself, and the docs site gets a JavaScript API section built from that documentation.

What changed

  • JSDoc on every export of packages/contract/src/js.ts: a module overview, a @category per export (errors, parsing, rendering, commits, workspace) and short examples for parseConfig, parseEvent, parseManifest, appendEvent and cairnDir.
  • @effect/docgen 4.1.5 (plus tsx) as dev dependencies of packages/contract, configured in packages/contract/docgen.json. pnpm --dir packages/contract run docgen typechecks and runs every example (--run-examples); a wrong assertion fails the build. enforceDescriptions fails on an export with no description. Output goes to packages/contract/docs/, which is gitignored.
  • apps/docs/scripts/api.ts turns docgen's page into a docs page: drops the front matter and the table of contents (the renderer gives headings no anchors), titles it @prddd/contract/js, moves the other headings down a level, and leaves fenced code untouched.
  • apps/docs: build, build:hosted and build:dev run docgen first; the build entry point requires the page and passes it to buildDocs, so tests never read the generated file. A nav section, "JavaScript API", follows "File reference". turbo.json adds the contract sources and docgen.json to the docs build inputs.
  • .agent_sources/effect/index.md regenerated for the new @effect/* dependency.

docgen declares typescript <7 as a peer; it parses with ts-morph's own bundled TypeScript, so it runs alongside TypeScript 7 with only the peer warning.

Review by Codex

Round 1, all fixed in 5352db2:

  • The cairnDir example depended on running inside the checkout and on POSIX separators; it now creates its own git repository and checks the path portably.
  • The overview said every function throws PrdddContractError; only the parse functions and appendEvent do, and cairnDir throws git's error outside a checkout.
  • parseEvent claimed to fill actor on every event; it only does on status events.
  • parseConfig claimed to fill every setting; attempts.maxCostUsd has no default and stays absent.
  • The page adapter collapsed blank lines inside code fences; it now leaves fences alone (covered by apps/docs/test/api.test.ts).

Round 2, two fixed in e5b41a0, two left open:

  • Fixed: a publishing build now fails when the API page is missing, and the page is passed in explicitly, so tests and docgen no longer race over the same file in pnpm check.
  • Fixed: the examples remove the temporary directories they create.
  • Open: in Codex's sandbox tsx cannot open the IPC socket it needs, so running the examples fails there. CI and local machines are unaffected.
  • Open: the regex that removes docgen's table of contents would cut too much if a module overview contained the heading "Exports Grouped by Category" inside a code block. No overview does.

Known rough edges

  • parseEvent's signature prints in full, about 50 lines.
  • formatTrailers and trailerArgs have no examples: they take branded IDs that a short example cannot build without the Effect schemas.

Checks

Docs and contract typecheck, oxlint, oxfmt, the 22 docs tests, the full docs build (writes dist/reference/js/index.html) and the pre-commit hook pass. The full pnpm check was not run locally; CI runs it.

🤖 Generated with Claude Code

benschac and others added 3 commits November 30, 2026 21:05
@effect/docgen reads the JSDoc on each export of packages/contract/src/js.ts,
typechecks and runs every example in it, and writes a markdown page. The docs
build runs it first and adds the page under "JavaScript API". A wrong example
fails the build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the first Codex review: the cairnDir example runs in its own git
repository and checks the path portably, the overview says which functions
throw PrdddContractError, parseEvent and parseConfig name the defaults they
fill, and the page adapter keeps blank lines inside code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the second Codex review: the build entry point reads docgen's page and
fails when it is missing, then passes it to buildDocs, so tests never read the
file docgen rewrites while pnpm check runs. The examples remove the temporary
directories they create.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

benschac commented Dec 1, 2026

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@benschac
benschac merged commit c304356 into main Dec 1, 2026
1 of 2 checks passed
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.

1 participant