Repository navigation
Generate the JavaScript API docs page from JSDoc with docgen - #477
Merged
Merged
Conversation
@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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The public
@prddd/contract/jsentry now documents itself, and the docs site gets a JavaScript API section built from that documentation.What changed
packages/contract/src/js.ts: a module overview, a@categoryper export (errors, parsing, rendering, commits, workspace) and short examples forparseConfig,parseEvent,parseManifest,appendEventandcairnDir.@effect/docgen4.1.5 (plustsx) as dev dependencies ofpackages/contract, configured inpackages/contract/docgen.json.pnpm --dir packages/contract run docgentypechecks and runs every example (--run-examples); a wrong assertion fails the build.enforceDescriptionsfails on an export with no description. Output goes topackages/contract/docs/, which is gitignored.apps/docs/scripts/api.tsturns 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:hostedandbuild:devrun docgen first; the build entry point requires the page and passes it tobuildDocs, so tests never read the generated file. A nav section, "JavaScript API", follows "File reference".turbo.jsonadds the contract sources anddocgen.jsonto the docs build inputs..agent_sources/effect/index.mdregenerated for the new@effect/*dependency.docgen declares
typescript <7as 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:
cairnDirexample depended on running inside the checkout and on POSIX separators; it now creates its own git repository and checks the path portably.PrdddContractError; only the parse functions andappendEventdo, andcairnDirthrows git's error outside a checkout.parseEventclaimed to fillactoron every event; it only does on status events.parseConfigclaimed to fill every setting;attempts.maxCostUsdhas no default and stays absent.apps/docs/test/api.test.ts).Round 2, two fixed in e5b41a0, two left open:
pnpm check.tsxcannot open the IPC socket it needs, so running the examples fails there. CI and local machines are unaffected.Known rough edges
parseEvent's signature prints in full, about 50 lines.formatTrailersandtrailerArgshave 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 fullpnpm checkwas not run locally; CI runs it.🤖 Generated with Claude Code