-
Notifications
You must be signed in to change notification settings - Fork 460
Expand file tree
/
Copy pathtypedoc.config.mjs
More file actions
147 lines (142 loc) · 5.25 KB
/
Copy pathtypedoc.config.mjs
File metadata and controls
147 lines (142 loc) · 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import { OptionDefaults } from 'typedoc';
const CUSTOM_BLOCK_TAGS = [
'@unionReturnHeadings',
'@displayFunctionSignature',
'@paramExtension',
'@experimental',
'@hideReturns',
];
/** @type {import("typedoc-plugin-markdown").PluginOptions} */
const typedocPluginMarkdownOptions = {
hidePageHeader: true,
hideBreadcrumbs: true,
hidePageTitle: true,
parametersFormat: 'table',
interfacePropertiesFormat: 'table',
classPropertiesFormat: 'table',
enumMembersFormat: 'table',
propertyMembersFormat: 'table',
typeDeclarationFormat: 'table',
typeDeclarationVisibility: 'compact',
typeAliasPropertiesFormat: 'table',
useHTMLAnchors: false,
tableColumnSettings: {
hideSources: true,
hideModifiers: true,
hideDefaults: true,
hideInherited: true,
hideOverrides: true,
},
fileExtension: '.mdx',
excludeScopesInPaths: true,
expandObjects: true,
formatWithPrettier: true,
expandParameters: true,
};
/** @type {import("typedoc-plugin-replace-text").Config} */
const typedocPluginReplaceTextOptions = {
replaceText: {
replacements: [
{
/**
* Inside our JSDoc comments we have absolute links to our docs, e.g. [Foo](https://clerk.com/docs/bar).
* We want to replace these with relative links, e.g. [Foo](/docs/bar).
*/
pattern: /https:\/\/clerk\.com\/docs/,
replace: '/docs',
flags: 'g',
},
{
/**
* Sometimes we need to add ```empty``` to an @example so that it's properly rendered (but we don't want to show a codeblock). This removes these placeholders.
*/
pattern: /```empty```/,
replace: '',
},
{
/**
* In order to not render `<Tabs>` in the inline IntelliSense, the `items` prop was adjusted from `items={['item', 'item2']}` to `items='item,item2'`. It needs to be converted back so that clerk.com can render it properly.
*/
pattern: /Tabs items='([^']+)'/,
replace: (_, match) =>
`Tabs items={[${match
.split(',')
.map(item => `'${item.trim()}'`)
.join(', ')}]}`,
},
],
},
};
/** @type {import("typedoc").TypeDocOptions} */
const config = {
out: './.typedoc/temp-docs',
entryPointStrategy: 'packages',
plugin: [
'typedoc-plugin-replace-text',
'typedoc-plugin-markdown',
'./.typedoc/custom-router.mjs',
'./.typedoc/custom-theme.mjs',
'./.typedoc/custom-plugin.mjs',
/** Must load after custom-plugin.mjs so its END listener (link replacements) fires first. */
'./.typedoc/extract-methods.mjs',
],
theme: 'clerkTheme',
router: 'clerk-router',
readme: 'none',
notRenderedTags: [
...OptionDefaults.notRenderedTags,
...CUSTOM_BLOCK_TAGS,
/** Parsed for router/theme; must not appear as a doc section (otherwise renders as **Inline**). */
'@inline',
'@inlineType',
/** Opts into a dedicated reference page despite `@inline` (see `.typedoc/standalone-page-tag.mjs`). */
'@standalonePage',
],
packageOptions: {
includeVersion: false,
excludePrivate: true,
sortEntryPoints: true,
sort: 'alphabetical',
excludeExternals: true,
excludeInternal: true,
excludeNotDocumented: true,
gitRevision: 'main',
blockTags: [...OptionDefaults.blockTags, ...CUSTOM_BLOCK_TAGS],
modifierTags: [
...OptionDefaults.modifierTags.filter(tag => tag !== '@experimental'),
/** Suppresses the Parameters table in `.typedoc/extract-methods.mjs` method MDX. */
'@skipParametersSection',
/**
* On a reference-object property whose value is an inline object type: omit the parent from the main Properties table;
* extract each callable member as `methods/<parent>-<child>.mdx` and each non-callable object member as a nested heading + property table (see `.typedoc/extract-methods.mjs`).
*/
'@extractMethods',
/** Type-only / router hints; not user-facing prose (see `notRenderedTags`). */
'@inline',
'@inlineType',
/** With `@inline`, still emit a standalone `.mdx` page (see `.typedoc/standalone-page-tag.mjs`). */
'@standalonePage',
/** Self-documenting placeholder for declarations intentionally left without a description. */
'@generateWithEmptyComment',
/**
* On a generic wrapper type (e.g. `ClerkPaginationRequest<T>`), opts every alias of the form `Foo<{...}>` into a single merged properties table that includes the wrapper's own properties. Without this, typedoc-plugin-markdown renders such aliases as empty pages because the resolved type is a ReferenceType with no inline declaration.
* Handled by `.typedoc/custom-plugin.mjs`.
*/
'@expandProperties',
],
/**
* Keep `@inline` / `@inlineType` / `@standalonePage` in the model so the custom router and theme can read them.
*/
excludeTags: OptionDefaults.excludeTags.filter(
tag => tag !== '@inline' && tag !== '@inlineType' && tag !== '@standalonePage',
),
exclude: ['src/**/*.test.ts', 'src/**/*.test.tsx'],
readme: 'none',
disableGit: true,
disableSources: true,
...typedocPluginReplaceTextOptions,
},
entryPoints: ['packages/backend', 'packages/nextjs', 'packages/react', 'packages/shared'],
...typedocPluginMarkdownOptions,
};
export default config;