Skip to content

chore(repo): Add logic to prevent duplication of legacy hooks Typedoc#8074

Open
SarahSoutoul wants to merge 6 commits intomainfrom
ss/fix-duplication-legacy-hooks
Open

chore(repo): Add logic to prevent duplication of legacy hooks Typedoc#8074
SarahSoutoul wants to merge 6 commits intomainfrom
ss/fix-duplication-legacy-hooks

Conversation

@SarahSoutoul
Copy link
Contributor

@SarahSoutoul SarahSoutoul commented Mar 13, 2026

Description

The whole reason for this PR is explained in this Slack comment/ thread. We introduced the extract script to split out Returns/Parameters into standalone Typedoc files. That was working when the legacy useSignIn/useSignUp hooks were the only ones exposed. Now that the new useSignIn/useSignUp hooks are no longer @internal, Typedoc generates outputs for both the new and legacy hooks. This causes:

  • The new hooks to take the canonical filenames (use-sign-in.mdx, use-sign-up.mdx, use-sign-in-return.mdx etc.)
  • The legacy hooks to be renamed by Typedoc to use-sign-in-1*.mdx / use-sign-up-1*.mdx

To prevent this duplication, here are the changes I applied.

Changes

The extractor now detects the legacy hook outputs and:

  1. Moves the legacy hooks into .typedoc/docs/react/legacy/
  2. Drops the -1 suffix
  3. Ensures matching return and params files are also placed in the same folder

Legacy docs are now written to:

  • .typedoc/docs/react/legacy/use-sign-in.mdx
  • .typedoc/docs/react/legacy/use-sign-up.mdx

Legacy returns/params are now written to:

.typedoc/docs/react/legacy/use-sign-in-return.mdx
.typedoc/docs/react/legacy/use-sign-in-params.mdx
.typedoc/docs/react/legacy/use-sign-up-return.mdx
.typedoc/docs/react/legacy/use-sign-up-params.mdx
Screenshot 2026-03-13 at 11 34 08 am

The new signal‑based hooks keep the normal canonical paths:

.typedoc/docs/react/use-sign-in.mdx
.typedoc/docs/react/use-sign-in-return.mdx
.typedoc/docs/react/use-sign-up.mdx
.typedoc/docs/react/use-sign-up-return.mdx

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • Chores
    • Improved documentation generation: legacy hook docs are now grouped into a dedicated legacy section, related "returns" and "parameters" pages are normalized to remove duplicate suffixes, and legacy docs are consistently relocated during processing to tidy output structure.
    • Added a small changeset marker and minor logging to surface relocation and creation events.

@SarahSoutoul SarahSoutoul self-assigned this Mar 13, 2026
@changeset-bot
Copy link

changeset-bot bot commented Mar 13, 2026

🦋 Changeset detected

Latest commit: a038f3e

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
Copy link

vercel bot commented Mar 13, 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 Mar 13, 2026 9:43pm

Request Review

@SarahSoutoul SarahSoutoul changed the title docs(repo): Add logic to prevent duplication of legacy hooks Typedoc docs(repo): Add logic to prevent duplication of legacy hooks Typedoc Mar 13, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 13, 2026

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@8074

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8074

@clerk/expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: a038f3e

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

📝 Walkthrough

Walkthrough

Adds legacy-hook handling to the TypeDoc extraction script (.typedoc/extract-returns-and-params.mjs): introduces LEGACY_HOOK_NAMES and getLegacyHookTarget(filePath) to detect legacy hooks and compute outputDir and baseName; updates extractReturnsSection and extractParametersSection to write outputs under a legacy/ subdirectory and strip trailing -1 from base names; adds moveLegacyHookDoc(filePath) to relocate legacy .mdx docs (removing any existing targets) with logging; invokes the mover after extraction and in the main loop; creates legacy directories as needed.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(repo): Add logic to prevent duplication of legacy hooks Typedoc' directly matches the main objective: adding logic to prevent duplication of legacy hooks in the Typedoc extractor by moving them to a legacy/ folder and removing the -1 suffix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.typedoc/extract-returns-and-params.mjs:
- Around line 40-45: Extract the duplicated legacy hook detection and
filename/path rewriting into a single helper (e.g., isLegacyHook(fileName) and
rewriteLegacyOutput(fileName, dirName) or a single getLegacyOutput(fileName,
dirName)) and use it from extractReturnsSection, extractParametersSection and
moveLegacyHookDoc; the helper should encapsulate the logic that currently checks
fileName === 'use-sign-in-1' || fileName === 'use-sign-up-1', produces the
outputBaseName by stripping /-1$/ and appends '-return', and returns the new
outputDir (path.join(dirName, 'legacy')) and ensures fs.mkdirSync(..., {
recursive: true }) is called once; update those three call sites to use the
helper instead of duplicating the checks and rewrites.
- Around line 126-129: Update the JSDoc for the function that handles legacy
hook doc moves (the block currently stating "Renames legacy hook docs to use a
-legacy suffix" with `@param` {string} filePath) to accurately describe what the
code does: it moves files into a legacy/ directory and strips a trailing "-1"
from filenames rather than appending a "-legacy" suffix; ensure the description
and any examples reflect "move into legacy/ and remove -1" so future maintainers
won't be misled.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: ASSERTIVE

Plan: Pro

Run ID: 76db7019-d139-4c33-8890-18be580056e3

📥 Commits

Reviewing files that changed from the base of the PR and between b764267 and f4b11d6.

📒 Files selected for processing (1)
  • .typedoc/extract-returns-and-params.mjs

@alexisintech
Copy link
Member

awesome fix!

but for the current useSignIn and useSignUp hooks, they're not returning the output we'd actually want in the docs:
Screenshot 2026-03-13 at 10 35 26

we'd want the signupsignalvalue type to be a table of those returns:
Screenshot 2026-03-13 at 10 36 55

@SarahSoutoul
Copy link
Contributor Author

but for the current useSignIn and useSignUp hooks, they're not returning the output we'd actually want in the docs:

@alexisintech Yeah that was always the case as they're not JSDoc documented properly, and currently the docs don't use these (they're manually typed). I think I'd prefer to keep the scope of this PR to just fixing the duplication, and can create another PR to make sure the output is good for those if that's okay.

@SarahSoutoul SarahSoutoul changed the title docs(repo): Add logic to prevent duplication of legacy hooks Typedoc chore(repo): Add logic to prevent duplication of legacy hooks Typedoc Mar 13, 2026
@SarahSoutoul SarahSoutoul changed the title chore(repo): Add logic to prevent duplication of legacy hooks Typedoc chore(react): Add logic to prevent duplication of legacy hooks Typedoc Mar 13, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.typedoc/extract-returns-and-params.mjs:
- Around line 57-65: When legacyTarget is set the script moves outputs to
legacy/ but does not remove any existing stale files with the old "-1" suffix,
leaving duplicates (e.g. use-sign-in-1-return.mdx); update the logic around
outputBaseName/outputDir/newFilePath to detect and delete those stale artifacts
before writing: when legacyTarget is true compute the originalLegacyPath(s) (the
prior filePath + `${legacyTarget.baseName}-1-return.mdx` and `-1-params.mdx` or
any `*-1-*.mdx` for that base name) and remove them (fs.unlinkSync or fs.rmSync
with exists checks) and/or remove any `*-1-*.mdx` in the original outputDir,
then continue to create the newFilePath in legacyTarget.outputDir as now. Ensure
this cleanup runs only when legacyTarget is truthy to avoid accidental
deletions.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: ASSERTIVE

Plan: Pro

Run ID: a9713ab3-ceca-4322-8997-139cddc57fdc

📥 Commits

Reviewing files that changed from the base of the PR and between f4b11d6 and 7b29be9.

📒 Files selected for processing (1)
  • .typedoc/extract-returns-and-params.mjs

@alexisintech
Copy link
Member

but for the current useSignIn and useSignUp hooks, they're not returning the output we'd actually want in the docs:

@alexisintech Yeah that was always the case as they're not JSDoc documented properly, and currently the docs don't use these (they're manually typed). I think I'd prefer to keep the scope of this PR to just fixing the duplication, and can create another PR to make sure the output is good for those if that's okay.

ohhh the current docs don't use them - okay sounds good!

Copy link
Member

@alexisintech alexisintech left a comment

Choose a reason for hiding this comment

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

LGTM!

@wobsoriano wobsoriano changed the title chore(react): Add logic to prevent duplication of legacy hooks Typedoc chore(repo): Add logic to prevent duplication of legacy hooks Typedoc Mar 13, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/short-apes-joke.md:
- Around line 1-2: The changeset file ".changeset/short-apes-joke.md" is empty
(only '---' delimiters); update it to declare the release intent by replacing
the empty frontmatter with a YAML changeset that lists the packages to bump
(each as package-name@version or package-name: patch/minor/major) and a short
summary message describing the change; ensure the file has the required opening
and closing '---' surrounding the package bump entries and the summary so
release/changelog tooling can parse it.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: ASSERTIVE

Plan: Pro

Run ID: ca16d884-5dae-485a-8ece-ad878dbac729

📥 Commits

Reviewing files that changed from the base of the PR and between 7b29be9 and 69f943a.

📒 Files selected for processing (1)
  • .changeset/short-apes-joke.md

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.

3 participants