Skip to content

refactor(repo): Inline extract-methods + tighten parameter rendering#8637

Draft
alexisintech wants to merge 7 commits into
aa/generate-object-docsfrom
aa/generate-objects-docs-part2
Draft

refactor(repo): Inline extract-methods + tighten parameter rendering#8637
alexisintech wants to merge 7 commits into
aa/generate-object-docsfrom
aa/generate-objects-docs-part2

Conversation

@alexisintech
Copy link
Copy Markdown
Member

@alexisintech alexisintech commented May 22, 2026

Stacked on top of #8276 — review that one first.

Four independent refactors of .typedoc/ (each its own commit) plus snapshot tests to lock the contract for future changes.

Summary

  • Run extract-methods inside the markdown render pass — folds extract-methods.mjs into a MarkdownPageEvent.END listener that queues a preWriteAsyncJob. Removes the second Application.bootstrapWithPlugins + convert() and the prepare-markdown-renderer.mjs workaround it required.
  • Consolidate unwrap + slug helpers — three unwrap-optional helpers + a peel-all while-loop collapse into a single unwrapOptional(t, { deep }). The two toKebabCase flavors (one for method filenames, one for page URLs) move into .typedoc/slug.mjs — they intentionally differ on acronyms, so the module exports both rather than unifying.
  • Flatten params with optionality-aware separatorclerkParametersTable.flattenParams now joins parent.child with ?. when the parent is optional and . when required. Lets us delete formatMethodParametersTable (the regex post-process that did a blanket .?. rename plus a no-longer-needed reorder).
  • Inline markdown helpers, drop node_modules importscustom-theme.mjs and extract-methods.mjs were reaching into node_modules/typedoc-plugin-markdown/dist/libs/... for backTicks, heading, htmlTable, table, removeLineBreaks, and the TypeDeclarationVisibility enum — none of which the plugin exports publicly, so that coupling broke on any dependency update. The five utilities (plus their escapeChars / formatTableCell dependencies) are now inlined in .typedoc/markdown-helpers.mjs, and the enum check is replaced with the underlying string literal ('compact').

Also adds the snapshot dir to .prettierignore: lint-staged was silently transforming the committed snapshots after vitest run passed, leaving them out of sync with the raw output that extract-methods.mjs writes.

Output changes

Output is byte-identical to the pre-refactor baseline (diff -r, 695/695 files) for the first two and fourth commits. The third commit deliberately changes 8 files to fix a latent inconsistency:

  • shared/clerk/methods/handle-email-link-verification.mdx: parent params is required, children now render as params.foo (was params?.foo).
  • backend/get-auth-fn.mdx, backend/get-auth-fn-no-request.mdx, nextjs/current-user.mdx, shared/api-keys-namespace.mdx, shared/custom-navigation.mdx, shared/get-memberships.mdx, shared/on-event-listener.mdx: parent is optional, children now render as parent?.foo (was parent.foo).

All eight match the rule "separator reflects how the property would be accessed at runtime."

Test plan

  • pnpm typedoc:generate succeeds with no errors.
  • cd .typedoc && vitest run passes (11 new file-snapshot tests + the existing file-structure tests, 16 total).
  • Spot-check the 8 changed files in the rendered docs preview to confirm they read correctly.

🤖 Generated with Claude Code

alexisintech and others added 3 commits May 22, 2026 16:03
Folds extract-methods.mjs into a MarkdownPageEvent.END listener that queues a
preWriteAsyncJob, removing the second TypeDoc convert pass and its
prepare-markdown-renderer.mjs workaround. Output is byte-identical to the
prior two-pass flow (verified by full `diff -r`, 695/695 files); adds 10
file-snapshot tests to lock that contract for future refactors.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces three unwrap-optional helpers + a while-loop with a single
`unwrapOptional(t, { deep })`. Extracts the two `toKebabCase` flavors into
`.typedoc/slug.mjs` — `toFileSlug` (method filenames) and `toUrlSlug` (page URLs)
intentionally differ on acronyms, so the module exports both rather than unifying.

Also adds the snapshot dir to `.prettierignore`: lint-staged was silently
transforming the committed snapshots after `vitest run` passed, leaving them out of
sync with the raw output `extract-methods.mjs` writes. Regenerates them.

Output is byte-identical to the pre-refactor baseline (`diff -r`, 695/695 files).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`clerkParametersTable` now joins flattened parent.child names with `?.` when
the parent is optional and `.` when required, mirroring how the property
would be accessed at runtime. `nestedParameterRowsFromDocumentedProperties`
applies the same rule. With the theme correct, the regex post-process in
`formatMethodParametersTable` (reorder + blanket `.` → `?.` rename) is no
longer needed — removed (-116 LOC), along with `appendMarkdownTableRows`.

Fixes 8 files where the old blanket rule was wrong in one direction or
the other:

- `shared/clerk/methods/handle-email-link-verification.mdx`: parent
  `params` is required, children now render as `params.foo` (was
  `params?.foo`).
- `backend/get-auth-fn.mdx`, `backend/get-auth-fn-no-request.mdx`,
  `nextjs/current-user.mdx`, `shared/api-keys-namespace.mdx`,
  `shared/custom-navigation.mdx`, `shared/get-memberships.mdx`,
  `shared/on-event-listener.mdx`: parent is optional, children now
  render as `parent?.foo` (was `parent.foo`).

Adds a snapshot for `handle-email-link-verification.mdx` to lock in the
required-parent rendering.

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

changeset-bot Bot commented May 22, 2026

⚠️ No Changeset found

Latest commit: 829534f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

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

Click here to learn what changesets are, and how to add one.

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

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment May 23, 2026 1:02am

Request Review

@alexisintech alexisintech marked this pull request as draft May 22, 2026 23:50
@alexisintech alexisintech changed the title refactor(typedoc): inline extract-methods + tighten parameter rendering refactor(repo): Inline extract-methods + tighten parameter rendering May 23, 2026
alexisintech and others added 2 commits May 22, 2026 17:53
`custom-theme.mjs` and `extract-methods.mjs` were reaching into
`node_modules/typedoc-plugin-markdown/dist/libs/...` for `backTicks`, `heading`,
`htmlTable`, `table`, `removeLineBreaks`, and the `TypeDeclarationVisibility`
enum — none of which the plugin exports publicly. That coupling breaks on any
dependency update.

Inlines the five utilities (plus the `escapeChars` / `formatTableCell`
helpers they call) into `.typedoc/markdown-helpers.mjs`, and replaces the
enum check with the underlying string literal (`'compact'`). Generated
output is byte-identical to the upstream behavior (`diff -r` shows zero
deltas beyond the unrelated step-4 changes; 16 snapshot tests pass).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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