Skip to content

feat(doc-generator): add the API docs generator and its check - #381

Draft
cmelchior wants to merge 1 commit into
mainfrom
feature/doc-generator
Draft

cmelchior wants to merge 1 commit into
mainfrom
feature/doc-generator

Conversation

@cmelchior

@cmelchior cmelchior commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Adds two prototype packages that generate the API docs definition files for supabase.com/docs from the doc comments of an SDK, and check them against the schema of the docs site.

This is a draft, opened for feedback on the approach. The packages are private and not published to npm.

What changed

  • packages/doc-generator (@supabase/doc-generator): one generator for every SDK. A source adapter per doc format turns tool output into a neutral API model, and everything after that is shared. There are two adapters: Swift symbol graphs, and griffe dump JSON for Python.
  • packages/doc-check (@supabase/doc-check): checks the generated files against the JSON Schema of the docs site, and parses them with the parser the docs site uses. The schema comes from a bundled copy, a URL, or a file in a Git repository at a ref.
  • Two workflows, doc-generator-validate.yml and doc-check-validate.yml: type check, lint, knip, build and tests for each package.
  • Root files: both packages are listed in README.md, CLAUDE.md and CODEOWNERS, and their fixtures are left out of oxfmt in .oxfmtrc.json.

Why

The docs team is building new reference pages that read one Markdown file with YAML frontmatter for each function (supabase/supabase#53545). These packages generate those files from what every SDK already has, its doc comments, so the API docs are not written by hand for each SDK.

How it works

  • Every public function gets one definition, with a doc comment or without one. Overloads share one definition.
  • The adapter decides what is public and names each function in the terms of its language. The id of a definition is that name in lowercase words, so ids belong to one SDK and are not shared between languages.
  • strict: true in the config of an SDK makes a public function without a doc comment an error.
  • doc-generator preview <docs-checkout> copies the definitions into a local checkout of supabase/supabase and starts the docs site there, to see them as the site will show them.
  • An SDK repository holds only a package.json and a doc-generator.config.mjs.

The SDK side

Two SDK pull requests use these packages. Each links them from a checkout of this branch:

All of those definitions are valid against the bundled schema.

How it was tested

  • doc-generator: 408 tests. Unit tests for each mapping, and golden files: a small Swift package and a small Python package, the checked-in output of the real tools, and the expected definitions, compared byte for byte.
  • doc-check: 66 tests. They include a local HTTP server and a temporary Git repository for the schema sources.
  • Both packages: type check, oxlint, oxfmt, knip and build pass locally.

Where to look first

  • packages/doc-generator/README.md, then src/model.ts (the API model) and src/generate.ts.
  • src/sources/swift/ and src/sources/python/ for the two adapters. Each has a README on how to write doc comments.
  • Of the 34,000 added lines, about 21,400 are fixtures: real tool output and golden files. Source is about 4,200 lines, tests about 5,700 and docs about 1,400.

Not in this PR

  • No release setup. The SDK pull requests link the two packages from a checkout of this branch.
  • No adapters for JavaScript, Dart, Go, C# or Kotlin. Their pages under src/sources/ are placeholders.
  • The schema is not on master of supabase/supabase yet. The bundled copy is the one at commit 7fba2c3 of that repository.
File map (generated by Claude)

packages/doc-generator

  • src/config.ts, src/run.ts, src/main.ts, src/cli.ts: config parsing and the command line.
  • src/model.ts: the API model that every adapter produces.
  • src/generate.ts, src/definition.ts, src/slug.ts: from the model to definitions and their ids.
  • src/frontmatter.ts, src/markdown.ts, src/write.ts: writing the files.
  • src/preview.ts, src/serve.ts: the local preview on the docs site.
  • src/sources/swift/: symbol graph reader, declaration and doc comment parsing.
  • src/sources/python/: griffe dump reader, expression and docstring parsing.
  • src/sources/<language>/README.md: how to write doc comments in that language, or a placeholder.
  • test/fixtures/: a fixture package for each language, the output of the real tool, and the expected definitions.
  • scripts/refresh-fixtures.sh: rebuilds the fixtures. Needs macOS with Swift, uv and jq.

packages/doc-check

  • src/check.ts: reads and validates the definition files.
  • src/schema.ts: the three schema sources and the bundled copy.
  • src/main.ts, src/cli.ts: the command line and exit codes.
  • schema/definition.schema.json: the bundled schema.
  • test/corpus/: valid and invalid definition files.

Generated with Claude Code

Add two packages that turn the doc comments of an SDK into the API docs
definition files that supabase.com/docs reads, and check those files:

- packages/doc-generator: one generator for every SDK. A source adapter
  per doc format (Swift symbol graphs, `griffe dump` for Python) builds a
  neutral API model, and everything after that is shared.
- packages/doc-check: checks the generated files against the JSON Schema
  of the docs team, with the parser the docs site uses.

Both are prototypes and are not published to npm.

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

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
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