Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
57059dc
useAuth pass
LekoArts Mar 27, 2025
fdc7ffa
improvements
LekoArts Mar 31, 2025
af1144f
Merge branch 'main' into lekoarts/eco-534-first-review-pass
LekoArts Mar 31, 2025
f947dea
more improvements
LekoArts Mar 31, 2025
6efc447
Merge branch 'main' into lekoarts/eco-534-first-review-pass
LekoArts Mar 31, 2025
e9e2b5e
wip
LekoArts Apr 2, 2025
b68d9e8
dep update
LekoArts Apr 2, 2025
2f22078
Merge branch 'main' into lekoarts/eco-534-first-review-pass
LekoArts Apr 3, 2025
4f126b1
add missing inline
LekoArts Apr 4, 2025
59bd888
update typedoc version
LekoArts Apr 7, 2025
bcaba2e
fix blockTags
LekoArts Apr 7, 2025
8f93fc3
flatten output directories
LekoArts Apr 7, 2025
72036b1
adjust script
LekoArts Apr 8, 2025
0ae6ccb
Merge branch 'main' into lekoarts/eco-534-first-review-pass
LekoArts Apr 8, 2025
dbb3444
Merge branch 'main' into lekoarts/eco-534-first-review-pass
LekoArts Apr 9, 2025
d0a4398
output updates
LekoArts Apr 9, 2025
34d659a
add tests
LekoArts Apr 9, 2025
8405567
Merge branch 'main' into lekoarts/eco-534-first-review-pass
LekoArts Apr 10, 2025
a748bfa
update plugin
LekoArts Apr 10, 2025
da3188b
merge fixes
LekoArts Apr 10, 2025
e23074c
Merge branch 'main' into lekoarts/eco-534-first-review-pass
LekoArts Apr 10, 2025
feeac3b
lockfile
LekoArts Apr 10, 2025
2223183
add changeset
LekoArts Apr 10, 2025
361692c
simplify theme overrides ✨
LekoArts Apr 10, 2025
3eb7cd2
Merge branch 'main' into lekoarts/eco-534-first-review-pass
LekoArts Apr 10, 2025
7b2af64
finishing touches
LekoArts Apr 11, 2025
0fb9ede
update snapshot
LekoArts Apr 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/giant-bats-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@clerk/shared': patch
'@clerk/clerk-react': patch
'@clerk/types': patch
---

Improve JSDoc comments
237 changes: 123 additions & 114 deletions .typedoc/__tests__/__snapshots__/file-structure.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,119 +2,128 @@

exports[`Typedoc output > should have a deliberate file structure 1`] = `
[
"types/type-aliases/check-authorization-from-session-claims.mdx",
"types/type-aliases/clerk-host-router.mdx",
"types/type-aliases/clerk-pagination-request.mdx",
"types/type-aliases/element-object-key.mdx",
"types/type-aliases/elements-config.mdx",
"types/type-aliases/id-selectors.mdx",
"types/type-aliases/legacy-redirect-props.mdx",
"types/type-aliases/localization-resource.mdx",
"types/type-aliases/multi-domain-and-or-proxy.mdx",
"types/type-aliases/organization-custom-role-key.mdx",
"types/type-aliases/organization-permission-key.mdx",
"types/type-aliases/organizations-jwt-claim.mdx",
"types/type-aliases/override.mdx",
"types/type-aliases/path-value.mdx",
"types/type-aliases/record-to-path.mdx",
"types/type-aliases/redirect-options.mdx",
"types/type-aliases/saml-strategy.mdx",
"types/type-aliases/sdk-metadata.mdx",
"types/type-aliases/session-status-claim.mdx",
"types/type-aliases/set-active.mdx",
"types/type-aliases/sign-up-authenticate-with-metamask-params.mdx",
"types/type-aliases/signed-in-session-resource.mdx",
"types/type-aliases/state-selectors.mdx",
"types/type-aliases/use-auth-return.mdx",
"types/type-aliases/use-session-list-return.mdx",
"types/type-aliases/use-session-return.mdx",
"types/type-aliases/use-sign-in-return.mdx",
"types/type-aliases/use-sign-up-return.mdx",
"types/type-aliases/use-user-return.mdx",
"types/type-aliases/without.mdx",
"types/interfaces/act-claim.mdx",
"types/interfaces/act-jwt-claim.mdx",
"types/interfaces/active-session-resource.mdx",
"types/interfaces/clerk-api-error.mdx",
"types/interfaces/clerk-jwt-claims.mdx",
"types/interfaces/clerk-paginated-response.mdx",
"types/interfaces/clerk-pagination-params.mdx",
"types/interfaces/clerk-resource.mdx",
"types/interfaces/clerk.mdx",
"types/interfaces/create-organization-params.mdx",
"types/interfaces/jwt-claims.mdx",
"types/interfaces/jwt-header.mdx",
"types/interfaces/pending-session-resource.mdx",
"types/interfaces/session-resource.mdx",
"types/interfaces/set-active-params.mdx",
"types/interfaces/sign-in-resource.mdx",
"types/interfaces/sign-out.mdx",
"types/interfaces/sign-up-resource.mdx",
"shared/react/types/type-aliases/paginated-hook-config.mdx",
"shared/react/types/interfaces/pages-or-infinite-options.mdx",
"shared/react/types/interfaces/paginated-resources.mdx",
"shared/react/hooks/use-clerk.mdx",
"shared/react/hooks/use-organization-list-params.mdx",
"shared/react/hooks/use-organization-list-return.mdx",
"shared/react/hooks/use-organization-list.mdx",
"shared/react/hooks/use-organization-params.mdx",
"shared/react/hooks/use-organization-return.mdx",
"shared/react/hooks/use-organization.mdx",
"shared/react/hooks/use-reverification.mdx",
"shared/react/hooks/use-session-list.mdx",
"shared/react/hooks/use-session.mdx",
"shared/react/hooks/use-user.mdx",
"shared/index/functions/build-clerk-js-script-attributes.mdx",
"shared/index/functions/clerk-js-script-url.mdx",
"shared/index/functions/create-path-matcher.mdx",
"shared/index/functions/deep-camel-to-snake.mdx",
"shared/index/functions/deep-snake-to-camel.mdx",
"shared/index/functions/deprecated-object-property.mdx",
"shared/index/functions/derive-state.mdx",
"shared/index/functions/extract-dev-browser-jwt-from-url.mdx",
"shared/index/functions/fast-deep-merge-and-replace.mdx",
"shared/index/functions/get-clerk-js-major-version-or-tag.mdx",
"shared/index/functions/get-env-variable.mdx",
"shared/index/functions/get-script-url.mdx",
"shared/index/functions/icon-image-url.mdx",
"shared/index/functions/in-browser.mdx",
"shared/index/functions/is-browser-online.mdx",
"shared/index/functions/is-clerk-runtime-error.mdx",
"shared/index/functions/is-publishable-key.mdx",
"shared/index/functions/is-staging.mdx",
"shared/index/functions/is-truthy.mdx",
"shared/index/functions/is-valid-browser-online.mdx",
"shared/index/functions/is-valid-browser.mdx",
"shared/index/functions/isomorphic-atob.mdx",
"shared/index/functions/load-clerk-js-script.mdx",
"shared/index/functions/read-json-file.mdx",
"shared/index/functions/set-clerk-js-loading-error-package-name.mdx",
"shared/index/functions/to-sentence.mdx",
"shared/index/functions/user-agent-is-robot.mdx",
"shared/index/functions/version-selector.mdx",
"shared/index/classes/clerk-runtime-error.mdx",
"nextjs/server/create-get-auth/variables/get-auth.mdx",
"nextjs/server/create-get-auth/functions/create-async-get-auth.mdx",
"nextjs/server/create-get-auth/functions/create-sync-get-auth.mdx",
"nextjs/server/clerk-middleware/variables/clerk-middleware.mdx",
"nextjs/server/clerk-middleware/interfaces/clerk-middleware-options.mdx",
"nextjs/server/build-clerk-props/variables/build-clerk-props.mdx",
"nextjs/app-router/server/current-user/functions/current-user.mdx",
"nextjs/app-router/server/auth/variables/auth.mdx",
"clerk-react/interfaces/clerk-provider-props.mdx",
"clerk-react/functions/protect.mdx",
"clerk-react/functions/redirect-to-create-organization.mdx",
"clerk-react/functions/redirect-to-organization-profile.mdx",
"clerk-react/functions/redirect-to-user-profile.mdx",
"clerk-react/functions/use-auth.mdx",
"clerk-react/functions/use-clerk.mdx",
"clerk-react/functions/use-organization-list.mdx",
"clerk-react/functions/use-organization.mdx",
"clerk-react/functions/use-reverification.mdx",
"clerk-react/functions/use-session-list.mdx",
"clerk-react/functions/use-session.mdx",
"clerk-react/functions/use-sign-in.mdx",
"clerk-react/functions/use-sign-up.mdx",
"clerk-react/functions/use-user.mdx",
"types/act-claim.mdx",
"types/act-jwt-claim.mdx",
"types/active-session-resource.mdx",
"types/check-authorization-fn.mdx",
"types/check-authorization-from-session-claims.mdx",
"types/check-authorization-with-custom-permissions.mdx",
"types/clerk-api-error.mdx",
"types/clerk-host-router.mdx",
"types/clerk-jwt-claims.mdx",
"types/clerk-paginated-response.mdx",
"types/clerk-pagination-params.mdx",
"types/clerk-pagination-request.mdx",
"types/clerk-resource.mdx",
"types/clerk.mdx",
"types/create-organization-params.mdx",
"types/element-object-key.mdx",
"types/elements-config.mdx",
"types/get-token.mdx",
"types/id-selectors.mdx",
"types/jwt-claims.mdx",
"types/jwt-header.mdx",
"types/legacy-redirect-props.mdx",
"types/localization-resource.mdx",
"types/multi-domain-and-or-proxy.mdx",
"types/organization-custom-role-key.mdx",
"types/organization-domain-verification-status.mdx",
"types/organization-enrollment-mode.mdx",
"types/organization-invitation-status.mdx",
"types/organization-permission-key.mdx",
"types/organization-suggestion-status.mdx",
"types/organizations-jwt-claim.mdx",
"types/override.mdx",
"types/path-value.mdx",
"types/pending-session-options.mdx",
"types/pending-session-resource.mdx",
"types/record-to-path.mdx",
"types/redirect-options.mdx",
"types/saml-strategy.mdx",
"types/sdk-metadata.mdx",
"types/session-resource.mdx",
"types/session-status-claim.mdx",
"types/set-active-params.mdx",
"types/set-active.mdx",
"types/sign-in-resource.mdx",
"types/sign-out.mdx",
"types/sign-up-authenticate-with-metamask-params.mdx",
"types/sign-up-resource.mdx",
"types/signed-in-session-resource.mdx",
"types/state-selectors.mdx",
"types/use-auth-return.mdx",
"types/use-session-list-return.mdx",
"types/use-session-return.mdx",
"types/use-sign-in-return.mdx",
"types/use-sign-up-return.mdx",
"types/use-user-return.mdx",
"types/user-resource.mdx",
"types/without.mdx",
"shared/build-clerk-js-script-attributes.mdx",
"shared/clerk-js-script-url.mdx",
"shared/clerk-runtime-error.mdx",
"shared/create-path-matcher.mdx",
"shared/deep-camel-to-snake.mdx",
"shared/deep-snake-to-camel.mdx",
"shared/deprecated-object-property.mdx",
"shared/derive-state.mdx",
"shared/extract-dev-browser-jwt-from-url.mdx",
"shared/fast-deep-merge-and-replace.mdx",
"shared/get-clerk-js-major-version-or-tag.mdx",
"shared/get-env-variable.mdx",
"shared/get-script-url.mdx",
"shared/icon-image-url.mdx",
"shared/in-browser.mdx",
"shared/is-browser-online.mdx",
"shared/is-clerk-runtime-error.mdx",
"shared/is-publishable-key.mdx",
"shared/is-staging.mdx",
"shared/is-truthy.mdx",
"shared/is-valid-browser-online.mdx",
"shared/is-valid-browser.mdx",
"shared/isomorphic-atob.mdx",
"shared/load-clerk-js-script.mdx",
"shared/pages-or-infinite-options.mdx",
"shared/paginated-hook-config.mdx",
"shared/paginated-resources.mdx",
"shared/read-json-file.mdx",
"shared/set-clerk-js-loading-error-package-name.mdx",
"shared/to-sentence.mdx",
"shared/use-clerk.mdx",
"shared/use-organization-list-params.mdx",
"shared/use-organization-list-return.mdx",
"shared/use-organization-list.mdx",
"shared/use-organization-params.mdx",
"shared/use-organization-return.mdx",
"shared/use-organization.mdx",
"shared/use-reverification.mdx",
"shared/use-session-list.mdx",
"shared/use-session.mdx",
"shared/use-user.mdx",
"shared/user-agent-is-robot.mdx",
"shared/version-selector.mdx",
"nextjs/auth.mdx",
"nextjs/build-clerk-props.mdx",
"nextjs/clerk-middleware-options.mdx",
"nextjs/clerk-middleware.mdx",
"nextjs/create-async-get-auth.mdx",
"nextjs/create-sync-get-auth.mdx",
"nextjs/current-user.mdx",
"nextjs/get-auth.mdx",
"clerk-react/clerk-provider-props.mdx",
"clerk-react/protect.mdx",
"clerk-react/redirect-to-create-organization.mdx",
"clerk-react/redirect-to-organization-profile.mdx",
"clerk-react/redirect-to-user-profile.mdx",
"clerk-react/use-auth.mdx",
"clerk-react/use-clerk.mdx",
"clerk-react/use-organization-list.mdx",
"clerk-react/use-organization.mdx",
"clerk-react/use-reverification.mdx",
"clerk-react/use-session-list.mdx",
"clerk-react/use-session.mdx",
"clerk-react/use-sign-in.mdx",
"clerk-react/use-sign-up.mdx",
"clerk-react/use-user.mdx",
]
`;
27 changes: 0 additions & 27 deletions .typedoc/__tests__/file-structure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,6 @@ describe('Typedoc output', () => {
"nextjs",
"shared",
"types",
"types/interfaces",
"types/type-aliases",
"shared/index",
"shared/react",
"shared/react/hooks",
"shared/react/types",
"shared/react/types/interfaces",
"shared/react/types/type-aliases",
"shared/index/classes",
"shared/index/functions",
"nextjs/app-router",
"nextjs/server",
"nextjs/server/build-clerk-props",
"nextjs/server/clerk-middleware",
"nextjs/server/create-get-auth",
"nextjs/server/create-get-auth/functions",
"nextjs/server/create-get-auth/variables",
"nextjs/server/clerk-middleware/interfaces",
"nextjs/server/clerk-middleware/variables",
"nextjs/server/build-clerk-props/variables",
"nextjs/app-router/server",
"nextjs/app-router/server/auth",
"nextjs/app-router/server/current-user",
"nextjs/app-router/server/current-user/functions",
"nextjs/app-router/server/auth/variables",
"clerk-react/functions",
"clerk-react/interfaces",
]
`);
});
Expand Down
43 changes: 41 additions & 2 deletions .typedoc/custom-plugin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const LINK_REPLACEMENTS = [
['session-resource', '/docs/references/javascript/session'],
['signed-in-session-resource', '/docs/references/javascript/session'],
['sign-up-resource', '/docs/references/javascript/sign-up'],
['user-resource', '/docs/references/javascript/user'],
['session-status-claim', '/docs/references/javascript/types/session-status'],
];

/**
Expand All @@ -34,16 +36,45 @@ const LINK_REPLACEMENTS = [
* It also shouldn't matter how level deep the relative link is.
*
* This function returns an array of `{ pattern: string, replace: string }` to pass into the `typedoc-plugin-replace-text` plugin.
*
* @example
* [foo](../../bar.mdx) -> [foo](/new-path)
* [foo](./bar.mdx) -> [foo](/new-path)
* [foo](bar.mdx) -> [foo](/new-path)
* [foo](bar.mdx#some-id) -> [foo](/new-path#some-id)
*/
function getRelativeLinkReplacements() {
return LINK_REPLACEMENTS.map(([fileName, newPath]) => {
return {
pattern: new RegExp(`\\((?:\\.{1,2}\\/)+.*?${fileName}\\.mdx\\)`, 'g'),
replace: `(${newPath})`,
// Match both path and optional anchor
pattern: new RegExp(`\\((?:(?:\\.{1,2}\\/)+[^()]*?|)${fileName}\\.mdx(#[^)]+)?\\)`, 'g'),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new regex accounts for two bugs I saw:

  • A string contained multiple []() and previously it replaced parts outside of that link (until the next occurence)
  • [foo](bar.mdx) and [foo](bar.mdx#test) didn't work

// Preserve the anchor in replacement if it exists
replace: (/** @type {string} */ _match, anchor = '') => `(${newPath}${anchor})`,
};
});
}

function getUnlinkedTypesReplacements() {
return [
{
pattern: /\(setActiveParams\)/g,
replace: '([setActiveParams](/docs/references/javascript/types/set-active-params))',
},
{
pattern: /`_LocalizationResource`/g,
replace: '[Localization](/docs/customization/localization)',
},
{
pattern: /`LoadedClerk`/g,
replace: '[Clerk](/docs/references/javascript/clerk)',
},
{
pattern: /`OrganizationCustomRoleKey`/g,
replace: '[OrganizationCustomRoleKey](/docs/references/javascript/types/organization-custom-role-key)',
},
];
}

/**
* @param {import('typedoc-plugin-markdown').MarkdownApplication} app
*/
Expand All @@ -58,6 +89,14 @@ export function load(app) {
}
}

const unlinkedTypesReplacements = getUnlinkedTypesReplacements();

for (const { pattern, replace } of unlinkedTypesReplacements) {
if (output.contents) {
output.contents = output.contents.replace(pattern, replace);
}
}

if (fileName) {
if (FILES_WITHOUT_HEADINGS.includes(fileName)) {
if (output.contents) {
Expand Down
Loading