Skip to content

Commit 847d2a6

Browse files
authored
fix(repo): Add standalonePage tag for JSDoc comments (#8524)
1 parent 365ca33 commit 847d2a6

8 files changed

Lines changed: 71 additions & 40 deletions

File tree

.typedoc/custom-router.mjs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { ReflectionKind } from 'typedoc';
33
import { MemberRouter } from 'typedoc-plugin-markdown';
44

5+
import { isInlineModifierWithoutStandalonePage } from './standalone-page-tag.mjs';
56
import { REFERENCE_OBJECT_PAGE_SYMBOLS } from './reference-objects.mjs';
67

78
/** @type {Set<string>} */
@@ -58,15 +59,11 @@ class ClerkRouter extends MemberRouter {
5859
}
5960

6061
/**
61-
* `@inline` marks types that should be expanded at use sites, not documented as their own page.
62+
* `@inline` marks types that should be expanded at use sites, not documented as their own page unless `@standalonePage` is also set (see `standalone-page-tag.mjs`).
6263
* TypeDoc still assigns `fullUrls` for exported aliases, so we also strip links in the theme's `referenceType` partial (`custom-theme.mjs`).
6364
*/
6465
const model = page.model;
65-
if (
66-
model &&
67-
'comment' in model &&
68-
/** @type {{ comment?: import('typedoc').Comment | undefined }} */ (model).comment?.hasModifier('@inline')
69-
) {
66+
if (model && isInlineModifierWithoutStandalonePage(/** @type {import('typedoc').Reflection} */ (model))) {
7067
return false;
7168
}
7269

.typedoc/custom-theme.mjs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { removeLineBreaks } from '../node_modules/typedoc-plugin-markdown/dist/l
1111
import { TypeDeclarationVisibility } from '../node_modules/typedoc-plugin-markdown/dist/options/maps.js';
1212

1313
import { applyTodoStrippingToComment } from './comment-utils.mjs';
14+
import { isInlineModifierWithoutStandalonePage } from './standalone-page-tag.mjs';
1415
import { REFERENCE_OBJECTS_LIST } from './reference-objects.mjs';
1516

1617
export { REFERENCE_OBJECTS_LIST };
@@ -802,7 +803,7 @@ function renderMergedIntersectionDeclaration(ctx, model, opts, mergedChildren, s
802803
}
803804
if (model.comment) {
804805
md.push(
805-
superPartials.comment(model.comment, {
806+
ctx.partials.comment(model.comment, {
806807
headingLevel,
807808
showSummary: true,
808809
showTags: false,
@@ -821,7 +822,7 @@ function renderMergedIntersectionDeclaration(ctx, model, opts, mergedChildren, s
821822

822823
if (model.comment) {
823824
md.push(
824-
superPartials.comment(model.comment, {
825+
ctx.partials.comment(model.comment, {
825826
headingLevel,
826827
showSummary: false,
827828
showTags: true,
@@ -1060,9 +1061,9 @@ class ClerkMarkdownThemeContext extends MarkdownThemeContext {
10601061
);
10611062
},
10621063
/**
1063-
* Stock `comments.comment` prints every {@link Comment.modifierTags} as **`TitleCase`** before the summary.
1064-
* `@inline` / `@inlineType` are router/type hints only; `@experimental` is SDK-only guidance — none of these
1065-
* must appear in property tables or prose.
1064+
* Stock `comments.comment` prints every {@link Comment.modifierTags} as **`TitleCase`** before the summary
1065+
* (it does not consult `notRenderedTags`; that option only filters block tags). `@inline` / `@inlineType` are
1066+
* router/type hints; `@experimental` is SDK-only guidance — none of these must appear in property tables or prose.
10661067
*
10671068
* @param {import('typedoc').Comment} model
10681069
* @param {Parameters<typeof superPartials.comment>[1]} [options]
@@ -1072,7 +1073,7 @@ class ClerkMarkdownThemeContext extends MarkdownThemeContext {
10721073
return superPartials.comment.call(this, model, options);
10731074
}
10741075
const modelToRender = applyTodoStrippingToComment(model) ?? model;
1075-
const hidden = new Set(['@inline', '@inlineType', '@experimental']);
1076+
const hidden = new Set(['@inline', '@inlineType', '@experimental', '@standalonePage']);
10761077
const modTags = Array.from(modelToRender.modifierTags ?? []);
10771078
if (modTags.some(/** @param {string} t */ t => hidden.has(t))) {
10781079
const clone = Object.assign(Object.create(Object.getPrototypeOf(modelToRender)), modelToRender, {
@@ -1089,12 +1090,12 @@ class ClerkMarkdownThemeContext extends MarkdownThemeContext {
10891090
*/
10901091
declarationTitle: () => '',
10911092
/**
1092-
* TypeDoc's default links every {@link ReferenceType} to a URL. Types marked `@inline` are expanded at use sites and (via the router) have no standalone page — linking produces broken relative `.mdx` paths in extracted method docs. Render the **aliased type** (RHS) so literals and unions show as `'phone_code'`, not `PhoneCodeStrategy`.
1093+
* TypeDoc's default links every {@link ReferenceType} to a URL. Types marked `@inline` are expanded at use sites and (via the router) have no standalone page — linking produces broken relative `.mdx` paths in extracted method docs. Render the **aliased type** (RHS) so literals and unions show as `'phone_code'`, not `PhoneCodeStrategy`, unless `@standalonePage` is set (`standalone-page-tag.mjs`).
10931094
*
10941095
* @param {import('typedoc').ReferenceType} model
10951096
*/
10961097
referenceType: model => {
1097-
if (model.reflection?.comment?.hasModifier('@inline')) {
1098+
if (isInlineModifierWithoutStandalonePage(model.reflection)) {
10981099
const decl = /** @type {import('typedoc').DeclarationReflection} */ (model.reflection);
10991100
// Generic instantiation, e.g. `Fn<Args>` — let `someType` apply type arguments.
11001101
if (model.typeArguments?.length) {

.typedoc/extract-methods.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
applyRelativeLinkReplacements,
3333
stripReferenceObjectPropertiesSection,
3434
} from './custom-plugin.mjs';
35+
import { isInlineModifierWithoutStandalonePage } from './standalone-page-tag.mjs';
3536
import { prepareMarkdownRenderer } from './prepare-markdown-renderer.mjs';
3637
import { applyTodoStrippingToComment } from './comment-utils.mjs';
3738
import { REFERENCE_OBJECTS_LIST, REFERENCE_OBJECT_CONFIG } from './reference-objects.mjs';
@@ -1048,7 +1049,7 @@ function unwrapOptionalParamType(t) {
10481049

10491050
/**
10501051
* When TypeDoc renders a parameter type as a markdown link to another generated `.mdx` file, that type has a dedicated page — omit nested `param?.prop` rows so readers follow the type link instead.
1051-
* `@inline` aliases are expanded by the theme and do not link to a standalone page.
1052+
* `@inline` aliases are expanded by the theme and do not link to a standalone page unless `@standalonePage` is set (`standalone-page-tag.mjs`).
10521053
*
10531054
* @param {import('typedoc').SomeType | undefined} t
10541055
* @param {import('typedoc-plugin-markdown').MarkdownThemeContext} ctx
@@ -1060,7 +1061,7 @@ function parameterTypeLinksToStandaloneMdxPage(t, ctx) {
10601061
}
10611062
if (bare.type === 'reference') {
10621063
const ref = /** @type {import('typedoc').ReferenceType} */ (bare);
1063-
if (ref.reflection?.comment?.hasModifier('@inline')) {
1064+
if (isInlineModifierWithoutStandalonePage(ref.reflection)) {
10641065
return false;
10651066
}
10661067
}

.typedoc/standalone-page-tag.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// @ts-check
2+
3+
/**
4+
* Modifier tag: keep a dedicated `.mdx` page even when `@inline` is present (TypeDoc + our router otherwise drop inline-marked declarations; the theme also expands references instead of linking).
5+
*/
6+
export const STANDALONE_PAGE_MODIFIER_TAG = '@standalonePage';
7+
8+
/**
9+
* @param {import('typedoc').Reflection | undefined} reflection
10+
* @returns {boolean} True when `@inline` should suppress a standalone page / force in-place expansion.
11+
*/
12+
export function isInlineModifierWithoutStandalonePage(reflection) {
13+
const comment =
14+
reflection && 'comment' in reflection
15+
? /** @type {{ comment?: import('typedoc').Comment | undefined }} */ (reflection).comment
16+
: undefined;
17+
if (!comment?.hasModifier('@inline')) {
18+
return false;
19+
}
20+
if (comment.hasModifier(STANDALONE_PAGE_MODIFIER_TAG)) {
21+
return false;
22+
}
23+
return true;
24+
}

packages/shared/src/react/hooks/createBillingPaginatedHook.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,28 @@ type BillingHookConfig<TResource extends ClerkResource, TParams extends PagesOrI
2525

2626
/**
2727
* @interface
28+
* @standalonePage
2829
*/
29-
export interface HookParams
30-
extends PaginatedHookConfig<
31-
PagesOrInfiniteOptions & {
32-
/**
33-
* If `true`, a request will be triggered when the hook is mounted.
34-
*
35-
* @default true
36-
*/
37-
enabled?: boolean;
38-
/**
39-
* On `cache` mode, no request will be triggered when the hook is mounted and the data will be fetched from the cache.
40-
*
41-
* @default undefined
42-
*
43-
* @hidden
44-
*
45-
* @experimental
46-
*/
47-
__experimental_mode?: 'cache';
48-
}
49-
> {
30+
export interface HookParams extends PaginatedHookConfig<
31+
PagesOrInfiniteOptions & {
32+
/**
33+
* If `true`, a request will be triggered when the hook is mounted.
34+
*
35+
* @default true
36+
*/
37+
enabled?: boolean;
38+
/**
39+
* On `cache` mode, no request will be triggered when the hook is mounted and the data will be fetched from the cache.
40+
*
41+
* @default undefined
42+
*
43+
* @hidden
44+
*
45+
* @experimental
46+
*/
47+
__experimental_mode?: 'cache';
48+
}
49+
> {
5050
/**
5151
* Specifies whether to fetch for the current user or Organization.
5252
*

packages/shared/src/react/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export type PaginatedResourcesWithDefault<T> = {
8585

8686
/**
8787
* @inline
88+
* @standalonePage
8889
*/
8990
export type PaginatedHookConfig<T> = T & {
9091
/**

turbo.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@
345345
".typedoc/reference-objects.mjs",
346346
".typedoc/comment-utils.mjs",
347347
".typedoc/extract-methods.mjs",
348-
".typedoc/extract-returns-and-params.mjs"
348+
".typedoc/extract-returns-and-params.mjs",
349+
".typedoc/standalone-page-tag.mjs"
349350
],
350351
"outputs": [".typedoc/**"],
351352
"outputLogs": "new-only"

typedoc.config.mjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ const config = {
9191
/** Parsed for router/theme; must not appear as a doc section (otherwise renders as **Inline**). */
9292
'@inline',
9393
'@inlineType',
94+
/** Opts into a dedicated reference page despite `@inline` (see `.typedoc/standalone-page-tag.mjs`). */
95+
'@standalonePage',
9496
],
9597
packageOptions: {
9698
includeVersion: false,
@@ -114,11 +116,15 @@ const config = {
114116
/** Type-only / router hints; not user-facing prose (see `notRenderedTags`). */
115117
'@inline',
116118
'@inlineType',
119+
/** With `@inline`, still emit a standalone `.mdx` page (see `.typedoc/standalone-page-tag.mjs`). */
120+
'@standalonePage',
117121
],
118122
/**
119-
* Stops TypeDoc from generating standalone pages for inline types.
123+
* Keep `@inline` / `@inlineType` / `@standalonePage` in the model so the custom router and theme can read them.
120124
*/
121-
excludeTags: OptionDefaults.excludeTags.filter(tag => tag !== '@inline' && tag !== '@inlineType'),
125+
excludeTags: OptionDefaults.excludeTags.filter(
126+
tag => tag !== '@inline' && tag !== '@inlineType' && tag !== '@standalonePage',
127+
),
122128
exclude: ['src/**/*.test.ts', 'src/**/*.test.tsx'],
123129
readme: 'none',
124130
disableGit: true,

0 commit comments

Comments
 (0)