Skip to content

docs(backend,shared): Generate typedoc output for backend docs#8853

Draft
alexisintech wants to merge 12 commits into
mainfrom
aa/DOCS-10984
Draft

docs(backend,shared): Generate typedoc output for backend docs#8853
alexisintech wants to merge 12 commits into
mainfrom
aa/DOCS-10984

Conversation

@alexisintech

@alexisintech alexisintech commented Jun 13, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds JSDoc comments to resources in packages/backend/src/api/endpoints/**/*.
  • Adds a custom @expandProperties modifier tag (handled by .typedoc/custom-plugin.mjs) so generic-instantiation aliases like UserListParams = ClerkPaginationRequest<{...}> render as a single merged properties table instead of an empty page. typedoc-plugin-markdown otherwise has no rendering branch for top-level ReferenceTypes. Tag applied to ClerkPaginationRequest and ClerkPaginationParams.
  • Wires backend API endpoint classes into the existing extract-methods.mjs pipeline via a new BACKEND_API_CONFIG in .typedoc/reference-objects.mjs. Each endpoint class registered here gets a backend/<kebab-name>/ folder containing <name>.mdx (main page) and methods/<method>.mdx (one file per public method, with description + TypeScript signature + parameters).
  • extract-methods.mjs now supports two output styles via a methodFormat option plumbed from the config:
    • reference (existing reference-object pages — Clerk, UserResource, etc.): ### foo() title + #### Parameters heading. Designed for pages aggregating many methods.
    • page (new, used by BACKEND_API_CONFIG): no method-name title, ## Parameters heading. Designed for one-method-per-docs-page consumption.
  • getPrimaryCallSignature skips @deprecated overloads (preferring the canonical signature when multiple are exposed). parametersMarkdownTable overlays @param block tags from sig.comment onto each parameter when their own comment is missing — fixes overloaded methods where the implementation's JSDoc carries the descriptions but typedoc only wires them onto the hidden implementation signature, leaving overloads with no per-parameter descriptions.
  • nestedParameterRowsFromDocumentedProperties strips line breaks in the description column, so JSDoc descriptions containing <ul> blocks no longer shatter the markdown table.
  • resolveDeclarationWithObjectMembers now unwraps ArrayType.elementType so params: Array<{...}> (e.g. CreateBulkOrganizationInvitationParams) flattens into nested params.* rows instead of dumping the inline shape into the Type column.
  • formatNestedParamNameColumn now appends ? to nested rows when the child property is optional (read from child.flags?.isOptional) — matches the inline-{ ... } flatten behavior in clerkParametersTable.flattenParams. Retroactively adds ? markers to previously-incorrect rows like update-user.mdx's params.backupCodes?, params.firstName?, etc.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jun 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 49556f8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jun 18, 2026 8:31pm
swingset Building Building Preview, Comment Jun 18, 2026 8:31pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: fbb0de84-60b0-485f-bc8c-f1dbde6ff81d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-new Bot commented Jun 13, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8853

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8853

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8853

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8853

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@8853

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8853

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8853

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8853

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8853

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8853

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8853

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8853

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8853

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8853

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8853

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8853

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8853

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8853

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8853

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8853

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8853

commit: 9cb19e5

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… MDX pages

- JSDoc all 24 public OrganizationAPI methods + their parameter types.
- Register `organization-api` in `.typedoc/reference-objects.mjs` `BACKEND_API_CONFIG`.
- Disambiguate the colliding `GetOrganization{Membership,Invitation}ListParams`
  exports (user-scoped on `UserApi`, org-scoped on `OrganizationApi`) via an
  explicit `export type { ... } from './UserApi'` in `endpoints/index.ts`.
  UserApi's variants remain the canonical public exports; OrganizationApi's
  exports stay reachable for direct imports and for typedoc.
- `.typedoc/extract-methods.mjs`:
  - Resolve nested rows when a param type is `Array<{...}>` (e.g.
    `CreateBulkOrganizationInvitationParams`) by unwrapping the array element
    in `resolveDeclarationWithObjectMembers`.
  - Append `?` to nested `params.field` rows for optional child properties,
    matching the inline-`{ ... }` flatten behavior in `custom-theme.mjs`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…collision

ESLint's `import/export` rule flagged the `export *` from both UserApi and
OrganizationApi as a duplicate-export conflict on `GetOrganizationMembershipListParams`
and `GetOrganizationInvitationListParams`, and the earlier explicit `export type
{ ... } from './UserApi'` disambiguator only added a third source of the names.

Replace `export * from './OrganizationApi'` with an explicit enumeration that omits
the two colliders, so only UserApi's user-scoped variants reach the public barrel.
OrganizationApi's org-scoped variants stay exported from the file itself, reachable
via direct import and resolvable by typedoc on the class methods.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@SarahSoutoul

Copy link
Copy Markdown
Contributor

@alexisintech Have just committed a small docs review - organization for the Organization stuff. It fixes two things:

  • Capitalizes organization -> Organization for the createOrganization() method.
  • Added @generateWithEmptyComment to the GetInstanceOrganizationMembershipListParams to display the params properly.

See before

Screenshot 2026-06-17 at 1 45 05 pm

See after

Screenshot 2026-06-17 at 2 35 56 pm

Have noticed a few odd things but wanted to get your opinion first, so will post a separate comment for those on clerk-docs PR.

alexisintech and others added 2 commits June 17, 2026 13:57
The `./src/api/endpoints/**/*.ts` glob in `packages/backend/typedoc.json` was
silently expanding to zero files in CI (Linux + Node 24.15) while expanding
correctly locally (macOS), producing `[warning] The glob ... did not match
any files` and skipping backend extraction entirely. Replace the glob with an
explicit file list to sidestep the environment-sensitive expansion.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
"./src/api/endpoints/M2MTokenApi.ts",
"./src/api/endpoints/MachineApi.ts",
"./src/api/endpoints/OAuthApplicationsApi.ts",
"./src/api/endpoints/OrganizationApi.ts",

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.

@alexisintech Adding both UserApi.ts and OrganizationApi.ts as Typedoc entrypoints produces standalone page collisions for shared param type names like GetOrganizationMembershipListParams and GetOrganizationInvitationListParams.

The generated output currently includes both the canonical file and a -1 variant, for example:

Image Image

We could add a small post-processing step for these known endpoint param collisions so the generated files get stable scoped names (for example user-... vs organization-...) instead of leaking TypeDoc -1 suffixes into the public docs output?

So after Typedoc runs:

  • Detect the colliding generated pages

  • Rename them to stable names like:

    user-get-organization-membership-list-params.mdx
    organization-get-organization-membership-list-params.mdx
    
  • Rewrite generated links to use those names

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes this was a big issue I kept trying to find the solution for and this is what me and my AFF came to - we don't actually use these files at all so while yes, we could add logic to handle these file names, it wouldn't be for anything. I'd rather not add unnecessary tech debt!

/**
* Gets the corresponding [OAuth access token](!oauth-access-token) for a user that has previously authenticated with the given OAuth provider.
* @param userId - The ID of the user to get the OAuth access tokens for.
* @param provider - The OAuth provider to get the access tokens for. If using a custom OAuth provider, prefix the provider name with `custom_` (e.g. `custom_google`).

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.

@alexisintech Imo, the new description for provider looks a bit ambiguous next to the generated signature. The prose example says custom_google, but the rendered type resolves to oauth_custom_${string}, so I think it's easy to read the example as the full argument value rather than just the provider-name portion. Could we make the example explicit (for example oauth_custom_google) so the docs match the rendered signature more clearly?

@SarahSoutoul

SarahSoutoul commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

@alexisintech have left a docs review - user for the User stuff. It fixes two things.

  • One of the PaginatedResourceResponse was missing the backticks, which didn't render it properly like the other ones.
  • Updated getUserOauthAccessToken() so the generated docs now surface the preferred OAuthProvider overload instead of the deprecated oauth_-prefixed OAuthStrategy one. What changed:
    • Reordered the overloads in UserApi.ts so the preferred OAuthProvider signature comes first
    • Moved the main JSDoc onto that preferred overload so Typedoc attaches the full param/return descriptions to the right signature
    • Kept the deprecated prefixed overload in place for backwards compatibility
    • Updated the Typedoc link rewrites so both OAuthStrategy and OAuthProvider resolve correctly, rather than replacing one with the other

Also submitted a docs review - user in the clerk-docs repo.

Other than that, one issue I did find is the following:

updateUser() lost the deprecation guidance for publicMetadata, privateMetadata, and unsafeMetadata. But the source still marks those fields deprecated in UserApi.ts and explicitly tells readers to use updateUserMetadata() / replaceUserMetadata() instead. That guidance was present in the old live docs and seems important to preserve.

Old live docs

Screenshot 2026-06-17 at 6 55 19 pm

VS now

Screenshot 2026-06-17 at 6 54 53 pm

@SarahSoutoul

SarahSoutoul commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

@alexisintech Made a docs review - domains, allowlist and billing doing the following:

  • For the delete() method, I removed the description next to the @deprecated tag, as it looked odd on the UI, and was already in the warning callout above.

    Screenshot 2026-06-18 at 11 24 29 am
  • Added some missing {{ target: '_blank' }} to Backend API links to make sure they were external in the Typedoc output

And made a docs review - domains, allowlist and billing on the clerk-docs repo too.

One remaining thing I noticed is the descriptions of the params for createAllowlistIdentifier() are a bit more thorough in the live docs compared to the current Typedoc output. Think it might be worth adding that info unless it was omitted for any specific reason.

Screenshot 2026-06-18 at 11 18 40 am

@alexisintech

Copy link
Copy Markdown
Member Author

@alexisintech Made a docs review - domains, allowlist and billing doing the following:

  • For the delete() method, I removed the description next to the @deprecated tag, as it looked odd on the UI, and was already in the warning callout above.
    Screenshot 2026-06-18 at 11 24 29 am
  • Added some missing {{ target: '_blank' }} to Backend API links to make sure they were external in the Typedoc output

And made a docs review - domains, allowlist and billing on the clerk-docs repo too.

One remaining thing I noticed is the descriptions of the params for createAllowlistIdentifier() are a bit more thorough in the live docs compared to the current Typedoc output. Think it might be worth adding that info unless it was omitted for any specific reason.

Screenshot 2026-06-18 at 11 18 40 am

we still need the deprecated tag on the method for users that need that information in their IDE's when using the method, so we wouldn't want to remove that text from the tag - I have some work locally for a solution for deprecated tags producing output, so I'll work on this and get back to you! I'm glad to see you were able to catch this too! :)

and I agree with you on the needing that extra information! I will update those params with the extra information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants