@textmode/docs 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -121
- package/README.md +24 -33
- package/dist/cli/textmode-docs.d.ts +3 -0
- package/dist/cli/textmode-docs.d.ts.map +1 -0
- package/dist/cli/textmode-docs.js +227 -0
- package/dist/cli/textmode-docs.js.map +1 -0
- package/dist/example-quality.d.ts +59 -0
- package/dist/example-quality.d.ts.map +1 -0
- package/dist/example-quality.js +256 -0
- package/dist/example-quality.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/check-api-documentation.d.ts +5 -0
- package/dist/internal/check-api-documentation.d.ts.map +1 -0
- package/dist/internal/check-api-documentation.js +74 -0
- package/dist/internal/check-api-documentation.js.map +1 -0
- package/dist/internal/check-example-sketches.d.ts +3 -0
- package/dist/internal/check-example-sketches.d.ts.map +1 -0
- package/dist/internal/check-example-sketches.js +76 -0
- package/dist/internal/check-example-sketches.js.map +1 -0
- package/dist/internal/config.d.ts +104 -0
- package/dist/internal/config.d.ts.map +1 -0
- package/dist/internal/config.js +324 -0
- package/dist/internal/config.js.map +1 -0
- package/dist/internal/documentation-commands.d.ts +24 -0
- package/dist/internal/documentation-commands.d.ts.map +1 -0
- package/dist/internal/documentation-commands.js +43 -0
- package/dist/internal/documentation-commands.js.map +1 -0
- package/dist/internal/lib/api-doc-checks.d.ts +46 -0
- package/dist/internal/lib/api-doc-checks.d.ts.map +1 -0
- package/dist/internal/lib/api-doc-checks.js +111 -0
- package/dist/internal/lib/api-doc-checks.js.map +1 -0
- package/dist/internal/lib/api-doc-routes.d.ts +7 -0
- package/dist/internal/lib/api-doc-routes.d.ts.map +1 -0
- package/dist/internal/lib/api-doc-routes.js +74 -0
- package/dist/internal/lib/api-doc-routes.js.map +1 -0
- package/dist/internal/lib/example-checks.d.ts +58 -0
- package/dist/internal/lib/example-checks.d.ts.map +1 -0
- package/dist/internal/lib/example-checks.js +230 -0
- package/dist/internal/lib/example-checks.js.map +1 -0
- package/dist/internal/lib/jsdoc-comments.d.ts +8 -0
- package/dist/internal/lib/jsdoc-comments.d.ts.map +1 -0
- package/dist/internal/lib/jsdoc-comments.js +67 -0
- package/dist/internal/lib/jsdoc-comments.js.map +1 -0
- package/dist/internal/lib/label-schema.d.ts +18 -0
- package/dist/internal/lib/label-schema.d.ts.map +1 -0
- package/dist/internal/lib/label-schema.js +17 -0
- package/dist/internal/lib/label-schema.js.map +1 -0
- package/dist/internal/lib/reflection-policy.d.ts +21 -0
- package/dist/internal/lib/reflection-policy.d.ts.map +1 -0
- package/dist/internal/lib/reflection-policy.js +96 -0
- package/dist/internal/lib/reflection-policy.js.map +1 -0
- package/dist/internal/lib/reporting.d.ts +8 -0
- package/dist/internal/lib/reporting.d.ts.map +1 -0
- package/dist/internal/lib/reporting.js +21 -0
- package/dist/internal/lib/reporting.js.map +1 -0
- package/dist/internal/lib/sketch-title.d.ts +14 -0
- package/dist/internal/lib/sketch-title.d.ts.map +1 -0
- package/dist/internal/lib/sketch-title.js +13 -0
- package/dist/internal/lib/sketch-title.js.map +1 -0
- package/dist/internal/reconcile-dates.d.ts +19 -0
- package/dist/internal/reconcile-dates.d.ts.map +1 -0
- package/dist/internal/reconcile-dates.js +77 -0
- package/dist/internal/reconcile-dates.js.map +1 -0
- package/dist/internal/reflection-kinds.d.ts +12 -0
- package/dist/internal/reflection-kinds.d.ts.map +1 -0
- package/dist/internal/reflection-kinds.js +19 -0
- package/dist/internal/reflection-kinds.js.map +1 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/accessor-comments.d.ts +10 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/accessor-comments.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/accessor-comments.js +31 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/accessor-comments.js.map +1 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/index.d.ts +3 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/index.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/index.js +16 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/index.js.map +1 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/render-accessor.d.ts +9 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/render-accessor.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/render-accessor.js +85 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/render-accessor.js.map +1 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/theme-patch.d.ts +7 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/theme-patch.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/theme-patch.js +16 -0
- package/dist/internal/typedoc-plugins/accessor-docs-normalizer/theme-patch.js.map +1 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/child-pages.d.ts +16 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/child-pages.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/child-pages.js +33 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/child-pages.js.map +1 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/constants.d.ts +9 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/constants.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/constants.js +44 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/constants.js.map +1 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/index.d.ts +2 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/index.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/index.js +2 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/index.js.map +1 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/member-paths.d.ts +11 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/member-paths.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/member-paths.js +12 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/member-paths.js.map +1 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/member-reflections.d.ts +8 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/member-reflections.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/member-reflections.js +78 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/member-reflections.js.map +1 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/namespace-paths.d.ts +8 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/namespace-paths.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/namespace-paths.js +22 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/namespace-paths.js.map +1 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/router.d.ts +22 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/router.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/router.js +44 -0
- package/dist/internal/typedoc-plugins/all-member-pages-router/router.js.map +1 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/constants.d.ts +11 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/constants.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/constants.js +38 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/constants.js.map +1 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/descriptions.d.ts +18 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/descriptions.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/descriptions.js +43 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/descriptions.js.map +1 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/frontmatter.d.ts +5 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/frontmatter.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/frontmatter.js +29 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/frontmatter.js.map +1 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/index.d.ts +6 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/index.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/index.js +19 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/index.js.map +1 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/library-context.d.ts +9 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/library-context.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/library-context.js +11 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/library-context.js.map +1 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/reflection-metadata.d.ts +15 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/reflection-metadata.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/reflection-metadata.js +46 -0
- package/dist/internal/typedoc-plugins/api-frontmatter/reflection-metadata.js.map +1 -0
- package/dist/internal/typedoc-plugins/include-code-examples/code-fences.d.ts +7 -0
- package/dist/internal/typedoc-plugins/include-code-examples/code-fences.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/include-code-examples/code-fences.js +23 -0
- package/dist/internal/typedoc-plugins/include-code-examples/code-fences.js.map +1 -0
- package/dist/internal/typedoc-plugins/include-code-examples/example-metadata.d.ts +7 -0
- package/dist/internal/typedoc-plugins/include-code-examples/example-metadata.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/include-code-examples/example-metadata.js +18 -0
- package/dist/internal/typedoc-plugins/include-code-examples/example-metadata.js.map +1 -0
- package/dist/internal/typedoc-plugins/include-code-examples/index.d.ts +4 -0
- package/dist/internal/typedoc-plugins/include-code-examples/index.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/include-code-examples/index.js +12 -0
- package/dist/internal/typedoc-plugins/include-code-examples/index.js.map +1 -0
- package/dist/internal/typedoc-plugins/include-code-examples/transform-markdown.d.ts +2 -0
- package/dist/internal/typedoc-plugins/include-code-examples/transform-markdown.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/include-code-examples/transform-markdown.js +17 -0
- package/dist/internal/typedoc-plugins/include-code-examples/transform-markdown.js.map +1 -0
- package/dist/internal/typedoc-plugins/strip-api-self-links/index.d.ts +8 -0
- package/dist/internal/typedoc-plugins/strip-api-self-links/index.d.ts.map +1 -0
- package/dist/internal/typedoc-plugins/strip-api-self-links/index.js +62 -0
- package/dist/internal/typedoc-plugins/strip-api-self-links/index.js.map +1 -0
- package/dist/internal/typedoc-runner.d.ts +31 -0
- package/dist/internal/typedoc-runner.d.ts.map +1 -0
- package/dist/internal/typedoc-runner.js +179 -0
- package/dist/internal/typedoc-runner.js.map +1 -0
- package/dist/internal/update-api-links.d.ts +7 -0
- package/dist/internal/update-api-links.d.ts.map +1 -0
- package/dist/internal/update-api-links.js +65 -0
- package/dist/internal/update-api-links.js.map +1 -0
- package/package.json +57 -59
- package/index.d.ts +0 -64
- package/src/cli/textmode-docs.mjs +0 -219
- package/src/example-quality.mjs +0 -227
- package/src/index.js +0 -27
- package/src/internal/config.js +0 -387
- package/src/internal/lib/api-doc-checks.mjs +0 -147
- package/src/internal/lib/api-doc-routes.mjs +0 -93
- package/src/internal/lib/example-checks.mjs +0 -315
- package/src/internal/lib/jsdoc-comments.mjs +0 -78
- package/src/internal/lib/label-schema.mjs +0 -13
- package/src/internal/lib/reflection-policy.mjs +0 -113
- package/src/internal/lib/reporting.mjs +0 -23
- package/src/internal/lib/sketch-title.mjs +0 -8
- package/src/internal/operations.js +0 -282
- package/src/internal/reconcile-dates.js +0 -72
- package/src/internal/reflection-kinds.js +0 -21
- package/src/internal/typedoc-plugins/accessor-docs-normalizer/README.md +0 -45
- package/src/internal/typedoc-plugins/accessor-docs-normalizer/accessor-comments.js +0 -53
- package/src/internal/typedoc-plugins/accessor-docs-normalizer/index.js +0 -32
- package/src/internal/typedoc-plugins/accessor-docs-normalizer/render-accessor.js +0 -144
- package/src/internal/typedoc-plugins/accessor-docs-normalizer/theme-patch.js +0 -28
- package/src/internal/typedoc-plugins/all-member-pages-router/README.md +0 -57
- package/src/internal/typedoc-plugins/all-member-pages-router/child-pages.js +0 -65
- package/src/internal/typedoc-plugins/all-member-pages-router/constants.js +0 -58
- package/src/internal/typedoc-plugins/all-member-pages-router/index.js +0 -18
- package/src/internal/typedoc-plugins/all-member-pages-router/member-paths.js +0 -48
- package/src/internal/typedoc-plugins/all-member-pages-router/member-reflections.js +0 -164
- package/src/internal/typedoc-plugins/all-member-pages-router/namespace-paths.js +0 -44
- package/src/internal/typedoc-plugins/all-member-pages-router/router.js +0 -58
- package/src/internal/typedoc-plugins/api-frontmatter/README.md +0 -66
- package/src/internal/typedoc-plugins/api-frontmatter/constants.js +0 -52
- package/src/internal/typedoc-plugins/api-frontmatter/descriptions.js +0 -87
- package/src/internal/typedoc-plugins/api-frontmatter/frontmatter.js +0 -57
- package/src/internal/typedoc-plugins/api-frontmatter/index.js +0 -39
- package/src/internal/typedoc-plugins/api-frontmatter/library-context.js +0 -38
- package/src/internal/typedoc-plugins/api-frontmatter/reflection-metadata.js +0 -95
- package/src/internal/typedoc-plugins/include-code-examples/README.md +0 -40
- package/src/internal/typedoc-plugins/include-code-examples/code-fences.js +0 -55
- package/src/internal/typedoc-plugins/include-code-examples/example-metadata.js +0 -41
- package/src/internal/typedoc-plugins/include-code-examples/index.js +0 -23
- package/src/internal/typedoc-plugins/include-code-examples/transform-markdown.js +0 -33
- package/src/internal/typedoc-plugins/strip-api-self-links/index.js +0 -117
- package/src/internal/typedoc-runner.js +0 -200
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { i18n, ReflectionKind } from 'typedoc';
|
|
4
|
-
|
|
5
|
-
import { hasSyntheticAccessorComment } from './accessor-comments.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @param {number} level
|
|
9
|
-
* @param {string} text
|
|
10
|
-
* @returns {string}
|
|
11
|
-
*/
|
|
12
|
-
function heading(level, text) {
|
|
13
|
-
return `${'#'.repeat(level)} ${text}`;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Render one getter or setter signature.
|
|
18
|
-
*
|
|
19
|
-
* @param {import('typedoc-plugin-markdown').MarkdownThemeContext} context
|
|
20
|
-
* @param {import('typedoc').SignatureReflection} signature
|
|
21
|
-
* @param {{
|
|
22
|
-
* accessor: 'get' | 'set';
|
|
23
|
-
* headingLevel: number;
|
|
24
|
-
* includeParameters: boolean;
|
|
25
|
-
* showSources: boolean;
|
|
26
|
-
* title: string;
|
|
27
|
-
* }} options
|
|
28
|
-
* @returns {string}
|
|
29
|
-
*/
|
|
30
|
-
function renderAccessorSignature(context, signature, options) {
|
|
31
|
-
const md = [];
|
|
32
|
-
|
|
33
|
-
md.push(heading(options.headingLevel, options.title));
|
|
34
|
-
md.push(
|
|
35
|
-
context.partials.signatureTitle(signature, {
|
|
36
|
-
accessor: options.accessor,
|
|
37
|
-
})
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
if (options.showSources && !context.options.getValue('disableSources') && signature.sources) {
|
|
41
|
-
md.push(context.partials.sources(signature));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (signature.comment) {
|
|
45
|
-
md.push(
|
|
46
|
-
context.partials.comment(signature.comment, {
|
|
47
|
-
headingLevel: options.headingLevel + 1,
|
|
48
|
-
showTags: false,
|
|
49
|
-
showSummary: true,
|
|
50
|
-
})
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (options.includeParameters && signature.parameters?.length) {
|
|
55
|
-
md.push(heading(options.headingLevel + 1, ReflectionKind.pluralString(ReflectionKind.Parameter)));
|
|
56
|
-
if (context.helpers.useTableFormat('parameters')) {
|
|
57
|
-
md.push(context.partials.parametersTable(signature.parameters));
|
|
58
|
-
} else {
|
|
59
|
-
md.push(
|
|
60
|
-
context.partials.parametersList(signature.parameters, {
|
|
61
|
-
headingLevel: options.headingLevel + 1,
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (signature.type) {
|
|
68
|
-
md.push(
|
|
69
|
-
context.partials.signatureReturns(signature, {
|
|
70
|
-
headingLevel: options.headingLevel + 1,
|
|
71
|
-
})
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (signature.comment) {
|
|
76
|
-
md.push(
|
|
77
|
-
context.partials.comment(signature.comment, {
|
|
78
|
-
headingLevel: options.headingLevel + 1,
|
|
79
|
-
showTags: true,
|
|
80
|
-
showSummary: false,
|
|
81
|
-
})
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return md.filter(Boolean).join('\n\n');
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Render accessor documentation with getter content before setter content.
|
|
90
|
-
*
|
|
91
|
-
* @param {import('typedoc-plugin-markdown').MarkdownThemeContext} context
|
|
92
|
-
* @param {import('typedoc').DeclarationReflection} accessor
|
|
93
|
-
* @param {{ headingLevel: number }} options
|
|
94
|
-
* @returns {string}
|
|
95
|
-
*/
|
|
96
|
-
export function renderAccessorDocs(context, accessor, options) {
|
|
97
|
-
const md = [];
|
|
98
|
-
const showSources = accessor.parent?.kind !== ReflectionKind.TypeLiteral;
|
|
99
|
-
|
|
100
|
-
if (accessor.getSignature) {
|
|
101
|
-
md.push(
|
|
102
|
-
renderAccessorSignature(context, accessor.getSignature, {
|
|
103
|
-
accessor: 'get',
|
|
104
|
-
headingLevel: options.headingLevel,
|
|
105
|
-
includeParameters: false,
|
|
106
|
-
showSources,
|
|
107
|
-
title: i18n.kind_get_signature(),
|
|
108
|
-
})
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (accessor.setSignature) {
|
|
113
|
-
md.push(
|
|
114
|
-
renderAccessorSignature(context, accessor.setSignature, {
|
|
115
|
-
accessor: 'set',
|
|
116
|
-
headingLevel: options.headingLevel,
|
|
117
|
-
includeParameters: true,
|
|
118
|
-
showSources,
|
|
119
|
-
title: i18n.kind_set_signature(),
|
|
120
|
-
})
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (
|
|
125
|
-
showSources &&
|
|
126
|
-
!context.options.getValue('disableSources') &&
|
|
127
|
-
!accessor.getSignature &&
|
|
128
|
-
!accessor.setSignature
|
|
129
|
-
) {
|
|
130
|
-
md.push(context.partials.sources(accessor));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (accessor.comment && !hasSyntheticAccessorComment(accessor)) {
|
|
134
|
-
md.push(
|
|
135
|
-
context.partials.comment(accessor.comment, {
|
|
136
|
-
headingLevel: options.headingLevel,
|
|
137
|
-
})
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
md.push(context.partials.inheritance(accessor, { headingLevel: options.headingLevel }));
|
|
142
|
-
|
|
143
|
-
return md.filter(Boolean).join('\n\n');
|
|
144
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { MarkdownTheme } from 'typedoc-plugin-markdown';
|
|
4
|
-
|
|
5
|
-
let isPatched = false;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Patch typedoc-plugin-markdown's theme render-context factory once.
|
|
9
|
-
*
|
|
10
|
-
* This is the only place this plugin reaches into markdown theme internals.
|
|
11
|
-
* Keep the patch idempotent because TypeDoc can load plugins repeatedly in
|
|
12
|
-
* watch mode and tests can import the plugin more than once.
|
|
13
|
-
*
|
|
14
|
-
* @param {(theme: MarkdownTheme, page: import('typedoc-plugin-markdown').MarkdownPageEvent<import('typedoc').Reflection>) => import('typedoc-plugin-markdown').MarkdownThemeContext} createContext
|
|
15
|
-
* @returns {boolean} True when this call installed the patch.
|
|
16
|
-
*/
|
|
17
|
-
export function patchMarkdownThemeRenderContext(createContext) {
|
|
18
|
-
if (isPatched) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
MarkdownTheme.prototype.getRenderContext = function (page) {
|
|
23
|
-
return createContext(this, page);
|
|
24
|
-
};
|
|
25
|
-
isPatched = true;
|
|
26
|
-
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# All Member Pages Router
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
|
|
5
|
-
This TypeDoc router makes direct public methods render as focused Markdown pages when an owner page would otherwise
|
|
6
|
-
render too many Sandpack examples.
|
|
7
|
-
|
|
8
|
-
`typedoc-plugin-markdown` can render top-level API structures as pages, but textmode.js also needs compact class and
|
|
9
|
-
interface overview pages that link to individual methods once their inline examples would make the page heavy. This
|
|
10
|
-
router keeps those owner pages small and gives each direct method a stable page.
|
|
11
|
-
|
|
12
|
-
## Member Pages
|
|
13
|
-
|
|
14
|
-
The router creates pages for direct class/interface methods when rendering the owner page inline would exceed three
|
|
15
|
-
Sandpack examples:
|
|
16
|
-
|
|
17
|
-
- methods
|
|
18
|
-
|
|
19
|
-
Nested type-literal fields intentionally remain inline or anchor-based so structural types do not explode into many
|
|
20
|
-
small pages.
|
|
21
|
-
|
|
22
|
-
## Paths
|
|
23
|
-
|
|
24
|
-
Examples:
|
|
25
|
-
|
|
26
|
-
- `classes/Textmodifier/methods/background.md`
|
|
27
|
-
- `namespaces/layering/classes/TextmodeLayer/methods/draw.md`
|
|
28
|
-
|
|
29
|
-
## Preserved Output Contract
|
|
30
|
-
|
|
31
|
-
- The router name remains `all-member-pages`.
|
|
32
|
-
- Direct methods get pages only when their class/interface owner would otherwise exceed three Sandpack examples.
|
|
33
|
-
- Properties, accessors, constructors, variables, type aliases, functions, and nested type-literal members do not get
|
|
34
|
-
extra pages from this router.
|
|
35
|
-
- Existing `MemberRouter` behavior for modules, namespaces, documents, and configured `membersWithOwnFile` kinds is
|
|
36
|
-
preserved.
|
|
37
|
-
- Project-root namespaces use the flattened textmode.js path shape, for example `namespaces/color/classes/TextmodeColor.md`.
|
|
38
|
-
- Sidebar entries include generated member pages under their owners.
|
|
39
|
-
|
|
40
|
-
## Contributor Notes
|
|
41
|
-
|
|
42
|
-
- Safe to edit: constants, helper names, tests, and README wording.
|
|
43
|
-
- Be careful with: `child-pages.js`, which intentionally mirrors upstream `MemberRouter` traversal.
|
|
44
|
-
- Do not casually change: path segment names, namespace path flattening, example-count thresholds, or direct-method page
|
|
45
|
-
eligibility.
|
|
46
|
-
|
|
47
|
-
## Maintenance
|
|
48
|
-
|
|
49
|
-
This plugin extends `typedoc-plugin-markdown`'s `MemberRouter` and copies its child-page traversal policy so direct
|
|
50
|
-
members can participate in TypeDoc's `hasOwnDocument` behavior. Re-check this router after upgrading TypeDoc or
|
|
51
|
-
`typedoc-plugin-markdown`, especially around router APIs, `membersWithOwnFile`, and namespace path handling.
|
|
52
|
-
|
|
53
|
-
Upgrade checklist:
|
|
54
|
-
|
|
55
|
-
- Compare `child-pages.js` against the current upstream `MemberRouter.buildChildPages`.
|
|
56
|
-
- Confirm `PageKind.Reflection`, `Slugger`, `fullUrls`, and `sluggers` are still the correct router APIs.
|
|
57
|
-
- Run `npm run build:docs` and verify generated method links still resolve.
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { Reflection, Slugger } from 'typedoc';
|
|
4
|
-
|
|
5
|
-
import { isDirectMemberPageReflection, shouldRenderOwnPage } from './member-reflections.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {{
|
|
9
|
-
* extension: string;
|
|
10
|
-
* fullUrls: Map<import('typedoc').Reflection, string>;
|
|
11
|
-
* sluggerConfiguration: unknown;
|
|
12
|
-
* sluggers: Map<import('typedoc').Reflection, Slugger>;
|
|
13
|
-
* getFileName(idealName: string): string;
|
|
14
|
-
* getIdealBaseName(reflection: import('typedoc').Reflection): string;
|
|
15
|
-
* getPageKind(reflection: import('typedoc').Reflection): import('typedoc').PageKind | undefined;
|
|
16
|
-
* shouldWritePage(reflection: import('typedoc').Reflection): boolean;
|
|
17
|
-
* buildAnchors(reflection: import('typedoc').Reflection, parent?: import('typedoc').Reflection): void;
|
|
18
|
-
* membersWithOwnFile: string[];
|
|
19
|
-
* kindsToString: Map<import('typedoc').ReflectionKind, string>;
|
|
20
|
-
* }} ChildPageRouter
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Build child pages using typedoc-plugin-markdown's MemberRouter traversal
|
|
25
|
-
* shape, while delegating textmode.js' expanded own-page policy to local
|
|
26
|
-
* helpers. This mirrors upstream traversal intentionally; when upgrading
|
|
27
|
-
* typedoc-plugin-markdown, compare this function against MemberRouter.
|
|
28
|
-
*
|
|
29
|
-
* @param {ChildPageRouter} router
|
|
30
|
-
* @param {import('typedoc').Reflection} reflection
|
|
31
|
-
* @param {import('typedoc').PageDefinition[]} outPages
|
|
32
|
-
* @returns {void}
|
|
33
|
-
*/
|
|
34
|
-
export function buildMemberRouterChildPages(router, reflection, outPages) {
|
|
35
|
-
const kind = router.getPageKind(reflection);
|
|
36
|
-
if (!kind) {
|
|
37
|
-
router.buildAnchors(reflection, reflection.parent);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const shouldWritePage = isDirectMemberPageReflection(reflection) || router.shouldWritePage(reflection);
|
|
42
|
-
const idealName = router.getIdealBaseName(reflection);
|
|
43
|
-
const actualName = shouldWritePage ? router.getFileName(idealName) : `${idealName}${router.extension}`;
|
|
44
|
-
router.fullUrls.set(reflection, actualName);
|
|
45
|
-
|
|
46
|
-
if (shouldRenderOwnPage(reflection, router)) {
|
|
47
|
-
if (shouldWritePage) {
|
|
48
|
-
router.sluggers.set(reflection, new Slugger(router.sluggerConfiguration));
|
|
49
|
-
outPages.push({
|
|
50
|
-
kind,
|
|
51
|
-
model: reflection,
|
|
52
|
-
url: actualName,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
} else {
|
|
56
|
-
router.buildAnchors(reflection, reflection.parent);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (reflection instanceof Reflection) {
|
|
60
|
-
reflection.traverse((child) => {
|
|
61
|
-
buildMemberRouterChildPages(router, child, outPages);
|
|
62
|
-
return true;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { ReflectionKind } from 'typedoc';
|
|
4
|
-
|
|
5
|
-
export const ROUTER_NAME = 'all-member-pages';
|
|
6
|
-
|
|
7
|
-
export const ALWAYS_OWN_PAGE_KIND_NAMES = ['Module', 'Namespace', 'Document'];
|
|
8
|
-
|
|
9
|
-
export const MAX_INLINE_SANDPACK_EXAMPLES = 3;
|
|
10
|
-
|
|
11
|
-
export const MEMBER_PAGE_OWNER_KINDS = new Set([ReflectionKind.Class, ReflectionKind.Interface]);
|
|
12
|
-
|
|
13
|
-
export const MEMBER_PAGE_KINDS = new Set([ReflectionKind.Method, ReflectionKind.Property, ReflectionKind.Accessor]);
|
|
14
|
-
|
|
15
|
-
export const MEMBER_DIRECTORIES = new Map([
|
|
16
|
-
[ReflectionKind.Method, 'methods'],
|
|
17
|
-
[ReflectionKind.Property, 'properties'],
|
|
18
|
-
[ReflectionKind.Accessor, 'accessors'],
|
|
19
|
-
]);
|
|
20
|
-
|
|
21
|
-
const MEMBER_KIND_BY_NAME = new Map([
|
|
22
|
-
['method', ReflectionKind.Method],
|
|
23
|
-
['property', ReflectionKind.Property],
|
|
24
|
-
['accessor', ReflectionKind.Accessor],
|
|
25
|
-
]);
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @param {string[]} memberPageKindNames
|
|
29
|
-
* @returns {void}
|
|
30
|
-
*/
|
|
31
|
-
export function configureMemberPages(memberPageKindNames) {
|
|
32
|
-
MEMBER_PAGE_KINDS.clear();
|
|
33
|
-
MEMBER_DIRECTORIES.clear();
|
|
34
|
-
|
|
35
|
-
const normalizedMemberPageKindNames = Array.isArray(memberPageKindNames)
|
|
36
|
-
? memberPageKindNames
|
|
37
|
-
: String(memberPageKindNames).split(',');
|
|
38
|
-
|
|
39
|
-
for (const memberPageKindName of normalizedMemberPageKindNames) {
|
|
40
|
-
const kind = MEMBER_KIND_BY_NAME.get(String(memberPageKindName).toLowerCase());
|
|
41
|
-
|
|
42
|
-
if (kind === undefined) {
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
MEMBER_PAGE_KINDS.add(kind);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (MEMBER_PAGE_KINDS.has(ReflectionKind.Method)) {
|
|
50
|
-
MEMBER_DIRECTORIES.set(ReflectionKind.Method, 'methods');
|
|
51
|
-
}
|
|
52
|
-
if (MEMBER_PAGE_KINDS.has(ReflectionKind.Property)) {
|
|
53
|
-
MEMBER_DIRECTORIES.set(ReflectionKind.Property, 'properties');
|
|
54
|
-
}
|
|
55
|
-
if (MEMBER_PAGE_KINDS.has(ReflectionKind.Accessor)) {
|
|
56
|
-
MEMBER_DIRECTORIES.set(ReflectionKind.Accessor, 'accessors');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { configureMemberPages, ROUTER_NAME } from './constants.js';
|
|
4
|
-
import { AllMemberPagesRouter } from './router.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* TypeDoc plugin load function.
|
|
8
|
-
*
|
|
9
|
-
* @param {import('typedoc').Application} app
|
|
10
|
-
* @param {{ memberPageKinds?: string[] }} [options]
|
|
11
|
-
* @returns {void}
|
|
12
|
-
*/
|
|
13
|
-
export function load(app, options = {}) {
|
|
14
|
-
configureMemberPages(options.memberPageKinds ?? ['method', 'property', 'accessor']);
|
|
15
|
-
|
|
16
|
-
app.renderer.defineRouter(ROUTER_NAME, AllMemberPagesRouter);
|
|
17
|
-
app.logger.verbose('[typedoc] Registered all member pages router');
|
|
18
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { MEMBER_DIRECTORIES } from './constants.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {{
|
|
7
|
-
* getIdealBaseName(reflection: import('typedoc').Reflection): string;
|
|
8
|
-
* }} MemberDirectoryRouter
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {{
|
|
13
|
-
* getReflectionAlias(reflection: import('typedoc').Reflection): string;
|
|
14
|
-
* }} ReflectionAliasRouter
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Get the directory name for a direct Sandpack member kind.
|
|
19
|
-
*
|
|
20
|
-
* @param {import('typedoc').ReflectionKind} kind
|
|
21
|
-
* @returns {string | undefined}
|
|
22
|
-
*/
|
|
23
|
-
export function getMemberDirectoryName(kind) {
|
|
24
|
-
return MEMBER_DIRECTORIES.get(kind);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Build the directory path for a direct Sandpack member page.
|
|
29
|
-
*
|
|
30
|
-
* @param {MemberDirectoryRouter} router
|
|
31
|
-
* @param {import('typedoc').Reflection} reflection
|
|
32
|
-
* @returns {string}
|
|
33
|
-
*/
|
|
34
|
-
export function getDirectMemberDirectory(router, reflection) {
|
|
35
|
-
const directory = getMemberDirectoryName(reflection.kind);
|
|
36
|
-
return `${router.getIdealBaseName(reflection.parent)}/${directory}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Build a reflection filename for a direct Sandpack member page.
|
|
41
|
-
*
|
|
42
|
-
* @param {ReflectionAliasRouter} router
|
|
43
|
-
* @param {import('typedoc').Reflection} reflection
|
|
44
|
-
* @returns {string}
|
|
45
|
-
*/
|
|
46
|
-
export function getReflectionFileName(router, reflection) {
|
|
47
|
-
return router.getReflectionAlias(reflection);
|
|
48
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { ReflectionKind } from 'typedoc';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
ALWAYS_OWN_PAGE_KIND_NAMES,
|
|
7
|
-
MEMBER_PAGE_KINDS,
|
|
8
|
-
MEMBER_PAGE_OWNER_KINDS,
|
|
9
|
-
MAX_INLINE_SANDPACK_EXAMPLES,
|
|
10
|
-
} from './constants.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @typedef {{
|
|
14
|
-
* membersWithOwnFile: string[];
|
|
15
|
-
* kindsToString: Map<import('typedoc').ReflectionKind, string>;
|
|
16
|
-
* }} OwnPagePolicyRouter
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @param {import('typedoc').Reflection | undefined} reflection
|
|
21
|
-
* @returns {string[]}
|
|
22
|
-
*/
|
|
23
|
-
function getOwnSandpackExamples(reflection) {
|
|
24
|
-
return (reflection?.comment?.blockTags || []).flatMap((tag) => {
|
|
25
|
-
if (tag.tag !== '@example') {
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const content = (tag.content || []).map((part) => part.text).join('');
|
|
30
|
-
return /```(?:js|javascript|jsx|ts|typescript|tsx)\b/i.test(content) && /@title\b/.test(content)
|
|
31
|
-
? [content]
|
|
32
|
-
: [];
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param {import('typedoc').Reflection} reflection
|
|
38
|
-
* @returns {number}
|
|
39
|
-
*/
|
|
40
|
-
function countReflectionSandpackExamples(reflection) {
|
|
41
|
-
const examples = new Set([
|
|
42
|
-
...getOwnSandpackExamples(reflection),
|
|
43
|
-
...(reflection.signatures || []).flatMap((signature) => getOwnSandpackExamples(signature)),
|
|
44
|
-
...getOwnSandpackExamples(reflection.getSignature),
|
|
45
|
-
...getOwnSandpackExamples(reflection.setSignature),
|
|
46
|
-
]);
|
|
47
|
-
|
|
48
|
-
return examples.size;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @param {import('typedoc').Reflection} reflection
|
|
53
|
-
* @returns {boolean}
|
|
54
|
-
*/
|
|
55
|
-
function isPropertyLikeReflection(reflection) {
|
|
56
|
-
return reflection.kind === ReflectionKind.Property || reflection.kind === ReflectionKind.Accessor;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @param {import('typedoc').Reflection} reflection
|
|
61
|
-
* @returns {boolean}
|
|
62
|
-
*/
|
|
63
|
-
function isSandpackThresholdMemberReflection(reflection) {
|
|
64
|
-
return (
|
|
65
|
-
(reflection.kind === ReflectionKind.Method || isPropertyLikeReflection(reflection)) &&
|
|
66
|
-
countReflectionSandpackExamples(reflection) > 0
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @param {import('typedoc').Reflection} owner
|
|
72
|
-
* @returns {number}
|
|
73
|
-
*/
|
|
74
|
-
function countInlineMemberSandpackExamples(owner) {
|
|
75
|
-
return (owner.children || [])
|
|
76
|
-
.filter((child) => isSandpackThresholdMemberReflection(child))
|
|
77
|
-
.reduce((count, member) => count + countReflectionSandpackExamples(member), 0);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Check whether direct members should become focused pages for this owner.
|
|
82
|
-
*
|
|
83
|
-
* @param {import('typedoc').Reflection} owner
|
|
84
|
-
* @returns {boolean}
|
|
85
|
-
*/
|
|
86
|
-
function shouldRenderMemberPages(owner) {
|
|
87
|
-
if (!MEMBER_PAGE_OWNER_KINDS.has(owner.kind)) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const inlineExampleCount = countReflectionSandpackExamples(owner) + countInlineMemberSandpackExamples(owner);
|
|
92
|
-
return inlineExampleCount > MAX_INLINE_SANDPACK_EXAMPLES;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @param {import('typedoc').Reflection | undefined} reflection
|
|
97
|
-
* @returns {boolean}
|
|
98
|
-
*/
|
|
99
|
-
function isDirectManagedMemberReflection(reflection) {
|
|
100
|
-
return Boolean(
|
|
101
|
-
reflection?.parent &&
|
|
102
|
-
MEMBER_PAGE_OWNER_KINDS.has(reflection.parent.kind) &&
|
|
103
|
-
MEMBER_PAGE_KINDS.has(reflection.kind)
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function shouldSuppressDefaultDirectMemberPagePolicy() {
|
|
108
|
-
return MEMBER_PAGE_KINDS.has(ReflectionKind.Property) || MEMBER_PAGE_KINDS.has(ReflectionKind.Accessor);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function shouldRenderAllDirectMethodPages() {
|
|
112
|
-
return MEMBER_PAGE_KINDS.size === 1 && MEMBER_PAGE_KINDS.has(ReflectionKind.Method);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Check whether a reflection is a direct method or example-bearing property
|
|
117
|
-
* that should become a focused page.
|
|
118
|
-
*
|
|
119
|
-
* @param {import('typedoc').Reflection | undefined} reflection
|
|
120
|
-
* @returns {boolean}
|
|
121
|
-
*/
|
|
122
|
-
export function isDirectMemberPageReflection(reflection) {
|
|
123
|
-
if (
|
|
124
|
-
shouldRenderAllDirectMethodPages() &&
|
|
125
|
-
reflection?.parent &&
|
|
126
|
-
MEMBER_PAGE_OWNER_KINDS.has(reflection.parent.kind) &&
|
|
127
|
-
reflection.kind === ReflectionKind.Method
|
|
128
|
-
) {
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (!isDirectManagedMemberReflection(reflection) || !shouldRenderMemberPages(reflection.parent)) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (reflection.kind === ReflectionKind.Method) {
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return isSandpackThresholdMemberReflection(reflection);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Preserve the markdown MemberRouter own-page policy while extending it to
|
|
145
|
-
* direct methods and example-bearing properties when the owner page would
|
|
146
|
-
* otherwise render too many Sandpack examples.
|
|
147
|
-
*
|
|
148
|
-
* @param {import('typedoc').Reflection} reflection
|
|
149
|
-
* @param {OwnPagePolicyRouter} router
|
|
150
|
-
* @returns {boolean}
|
|
151
|
-
*/
|
|
152
|
-
export function shouldRenderOwnPage(reflection, router) {
|
|
153
|
-
if (isDirectMemberPageReflection(reflection)) {
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (shouldSuppressDefaultDirectMemberPagePolicy() && isDirectManagedMemberReflection(reflection)) {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return [...ALWAYS_OWN_PAGE_KIND_NAMES, ...router.membersWithOwnFile].includes(
|
|
162
|
-
router.kindsToString.get(reflection.kind)
|
|
163
|
-
);
|
|
164
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { ReflectionKind } from 'typedoc';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Check whether a namespace is directly rooted in the TypeDoc project after
|
|
7
|
-
* walking through any nested namespace ancestors.
|
|
8
|
-
*
|
|
9
|
-
* @param {import('typedoc').Reflection} reflection
|
|
10
|
-
* @returns {boolean}
|
|
11
|
-
*/
|
|
12
|
-
export function isProjectNamespace(reflection) {
|
|
13
|
-
let ancestor = reflection.parent;
|
|
14
|
-
while (ancestor && ancestor.kind === ReflectionKind.Namespace) {
|
|
15
|
-
ancestor = ancestor.parent;
|
|
16
|
-
}
|
|
17
|
-
return ancestor?.kind === ReflectionKind.Project;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Build the flattened project namespace path used by the textmode.js docs.
|
|
22
|
-
*
|
|
23
|
-
* @param {{
|
|
24
|
-
* directories: Map<import('typedoc').ReflectionKind, string>;
|
|
25
|
-
* getReflectionAlias(reflection: import('typedoc').Reflection): string;
|
|
26
|
-
* }} router
|
|
27
|
-
* @param {import('typedoc').Reflection} reflection
|
|
28
|
-
* @returns {string}
|
|
29
|
-
*/
|
|
30
|
-
export function buildNamespacePath(router, reflection) {
|
|
31
|
-
const stack = [];
|
|
32
|
-
let current = reflection;
|
|
33
|
-
while (current && current.kind === ReflectionKind.Namespace) {
|
|
34
|
-
stack.unshift(current);
|
|
35
|
-
current = current.parent;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const segments = [];
|
|
39
|
-
for (const namespace of stack) {
|
|
40
|
-
segments.push(router.directories.get(ReflectionKind.Namespace), router.getReflectionAlias(namespace));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return segments.join('/');
|
|
44
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { PageKind } from 'typedoc';
|
|
4
|
-
import { MemberRouter } from 'typedoc-plugin-markdown';
|
|
5
|
-
|
|
6
|
-
import { buildMemberRouterChildPages } from './child-pages.js';
|
|
7
|
-
import { getDirectMemberDirectory, getReflectionFileName as getMemberReflectionFileName } from './member-paths.js';
|
|
8
|
-
import { isDirectMemberPageReflection } from './member-reflections.js';
|
|
9
|
-
import { buildNamespacePath, isProjectNamespace } from './namespace-paths.js';
|
|
10
|
-
|
|
11
|
-
export class AllMemberPagesRouter extends MemberRouter {
|
|
12
|
-
/** @param {import('typedoc').Reflection} reflection */
|
|
13
|
-
getPageKind(reflection) {
|
|
14
|
-
if (isDirectMemberPageReflection(reflection)) {
|
|
15
|
-
return PageKind.Reflection;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return super.getPageKind(reflection);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* This mirrors typedoc-plugin-markdown's MemberRouter child traversal while
|
|
23
|
-
* delegating the "own page" policy to this plugin's helpers.
|
|
24
|
-
*
|
|
25
|
-
* @param {import('typedoc').Reflection} reflection
|
|
26
|
-
* @param {import('typedoc').PageDefinition[]} outPages
|
|
27
|
-
*/
|
|
28
|
-
buildChildPages(reflection, outPages) {
|
|
29
|
-
buildMemberRouterChildPages(this, reflection, outPages);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** @param {import('typedoc').Reflection} reflection */
|
|
33
|
-
getNamespaceDirectory(reflection) {
|
|
34
|
-
if (isProjectNamespace(reflection)) {
|
|
35
|
-
return buildNamespacePath(this, reflection);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return super.getNamespaceDirectory(reflection);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** @param {import('typedoc').Reflection} reflection */
|
|
42
|
-
getReflectionDirectory(reflection) {
|
|
43
|
-
if (isDirectMemberPageReflection(reflection)) {
|
|
44
|
-
return getDirectMemberDirectory(this, reflection);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return super.getReflectionDirectory(reflection);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** @param {import('typedoc').Reflection} reflection */
|
|
51
|
-
getReflectionFileName(reflection) {
|
|
52
|
-
if (isDirectMemberPageReflection(reflection)) {
|
|
53
|
-
return getMemberReflectionFileName(this, reflection);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return super.getReflectionFileName(reflection);
|
|
57
|
-
}
|
|
58
|
-
}
|