Skip to content

Commit c4b7cf0

Browse files
committed
handle top sections
1 parent 02d730d commit c4b7cf0

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

.typedoc/custom-plugin.mjs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @ts-check
1+
// @ts-check - Enable TypeScript checks for safer MDX post-processing and link rewriting
22
import { MarkdownPageEvent } from 'typedoc-plugin-markdown';
33

44
/**
@@ -83,6 +83,19 @@ function getRelativeLinkReplacements() {
8383

8484
function getCatchAllReplacements() {
8585
return [
86+
// Robustly remove the full Experimental section (including optional Example/code block)
87+
// from the first "**`Experimental`**" until the next heading (## ...) or end of file.
88+
// This covers variations in wording/whitespace and ensures the block is stripped.
89+
{
90+
pattern: /(?:^|\r?\n)\*\*`Experimental`\*\*[\s\S]*?(?=(?:\r?\n##\s)|$)/g,
91+
replace: '',
92+
},
93+
// As a safeguard, remove any leftover Example section that specifically shows ClerkProvider clerkJsVersion snippet
94+
{
95+
pattern:
96+
/(?:^|\r?\n)## Example\r?\n(?:\r?\n)?```tsx[\s\S]*?ClerkProvider\s+clerkJsVersion="[^"]*"[\s\S]*?```(?:\r?\n)?/g,
97+
replace: '',
98+
},
8699
{
87100
pattern: /\(setActiveParams\)/g,
88101
replace: '([setActiveParams](/docs/references/javascript/types/set-active-params))',
@@ -135,12 +148,6 @@ function getCatchAllReplacements() {
135148
pattern: /\*\*Deprecated\*\*/g,
136149
replace: '**Deprecated.**',
137150
},
138-
// Remove the standard experimental API notice block (with or without leading/trailing whitespace or newlines)
139-
{
140-
pattern:
141-
/(?:\r?\n)?\*\*`Experimental`\*\*\r?\n\r?\nThis is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change\.\r?\nIt is advised to pin the SDK version to avoid breaking changes\.\r?\n?/g,
142-
replace: '',
143-
},
144151
{
145152
/**
146153
* By default, `@default` is output with "**Default** `value`". We want to capture the value and place it inside "Defaults to `value`."

.typedoc/custom-theme.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ class ClerkMarkdownThemeContext extends MarkdownThemeContext {
4646

4747
this.partials = {
4848
...superPartials,
49+
/**
50+
* This hides the "Experimental" section from the output (by default).
51+
* @param {import('typedoc').Comment} model
52+
* @param {{ headingLevel?: number; showSummary?: boolean; showTags?: boolean; showReturns?: boolean; isTableColumn?: boolean }} [options]
53+
*/
54+
comment: (model, options) => {
55+
if (model?.modifierTags.has('@experimental')) {
56+
const originalBlockTags = model.blockTags;
57+
model.blockTags = model.blockTags.filter(tag => tag.name !== '@example');
58+
const res = superPartials.comment(model, options);
59+
model.blockTags = originalBlockTags;
60+
return res;
61+
}
62+
return superPartials.comment(model, options);
63+
},
4964
/**
5065
* This hides the "Type parameters" section and the signature title from the output (by default). Shows the signature title if the `@displayFunctionSignature` tag is present.
5166
* @param {import('typedoc').SignatureReflection} model

0 commit comments

Comments
 (0)