@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,117 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { Converter, ReflectionKind } from 'typedoc';
|
|
4
|
-
import { MarkdownPageEvent } from 'typedoc-plugin-markdown';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Check whether a comment display part links to the hosted textmode.js API.
|
|
8
|
-
*
|
|
9
|
-
* @param {import('typedoc').CommentDisplayPart} part
|
|
10
|
-
* @param {string} apiBaseUrl
|
|
11
|
-
* @returns {boolean}
|
|
12
|
-
*/
|
|
13
|
-
function isHostedApiLink(part, apiBaseUrl) {
|
|
14
|
-
return part.kind === 'inline-tag' && part.tag === '@link' && String(part.target ?? '').startsWith(apiBaseUrl);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Remove `@see` tags that point back to the generated API site itself.
|
|
19
|
-
*
|
|
20
|
-
* These links are useful in emitted declaration hover docs, but they are redundant
|
|
21
|
-
* inside the TypeDoc API pages hosted at the same URLs.
|
|
22
|
-
*
|
|
23
|
-
* @param {import('typedoc').Comment | undefined} comment
|
|
24
|
-
* @param {string} apiBaseUrl
|
|
25
|
-
* @returns {void}
|
|
26
|
-
*/
|
|
27
|
-
function stripHostedApiSeeTags(comment, apiBaseUrl) {
|
|
28
|
-
if (!comment) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
comment.blockTags = comment.blockTags.filter(
|
|
33
|
-
(tag) => tag.tag !== '@see' || !tag.content.some((part) => isHostedApiLink(part, apiBaseUrl))
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @param {import('typedoc').Reflection} reflection
|
|
39
|
-
* @param {string} apiBaseUrl
|
|
40
|
-
* @returns {void}
|
|
41
|
-
*/
|
|
42
|
-
function stripReflectionHostedApiSeeTags(reflection, apiBaseUrl) {
|
|
43
|
-
stripHostedApiSeeTags(reflection.comment, apiBaseUrl);
|
|
44
|
-
|
|
45
|
-
if (!reflection.isDeclaration()) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
for (const signature of reflection.signatures ?? []) {
|
|
50
|
-
stripHostedApiSeeTags(signature.comment, apiBaseUrl);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
stripHostedApiSeeTags(reflection.getSignature?.comment, apiBaseUrl);
|
|
54
|
-
stripHostedApiSeeTags(reflection.setSignature?.comment, apiBaseUrl);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Remove generated Markdown links back to the same hosted API reference.
|
|
59
|
-
*
|
|
60
|
-
* @param {string} contents
|
|
61
|
-
* @param {string} apiBaseUrl
|
|
62
|
-
* @param {'minimal' | 'full'} stripMode
|
|
63
|
-
* @returns {string}
|
|
64
|
-
*/
|
|
65
|
-
function stripHostedApiMarkdownLinks(contents, apiBaseUrl, stripMode) {
|
|
66
|
-
const escapedBaseUrl = apiBaseUrl.replaceAll('.', '\\.');
|
|
67
|
-
const hostedApiLinkPattern = `\\[[^\\]]+ API reference\\]\\(${escapedBaseUrl}[^)]*\\)`;
|
|
68
|
-
const standaloneSeeSection = new RegExp(`\\n#{2,6} See\\n\\n${hostedApiLinkPattern}\\n`, 'g');
|
|
69
|
-
const inlineSeeLink = new RegExp(`\\s*\\*\\*See\\*\\*\\s*${hostedApiLinkPattern}`, 'g');
|
|
70
|
-
const standaloneLinkLine =
|
|
71
|
-
stripMode === 'minimal'
|
|
72
|
-
? new RegExp(`^${hostedApiLinkPattern}\\n`, 'gm')
|
|
73
|
-
: new RegExp(`^\\s*${hostedApiLinkPattern}\\n?`, 'gm');
|
|
74
|
-
|
|
75
|
-
let nextContents = contents
|
|
76
|
-
.replace(standaloneSeeSection, '\n')
|
|
77
|
-
.replace(inlineSeeLink, '')
|
|
78
|
-
.replace(standaloneLinkLine, '');
|
|
79
|
-
|
|
80
|
-
if (stripMode === 'full') {
|
|
81
|
-
const listItemLinkLine = new RegExp(`^\\s*-\\s*${hostedApiLinkPattern}\\n?`, 'gm');
|
|
82
|
-
const emptySeeSection = /\n#{2,6} See\n(?:\s*\n)+(?=#{1,6}\s|\n*$)/g;
|
|
83
|
-
nextContents = nextContents.replace(listItemLinkLine, '').replace(emptySeeSection, '\n');
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return nextContents;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* TypeDoc plugin load function.
|
|
91
|
-
*
|
|
92
|
-
* @param {import('typedoc').Application} app
|
|
93
|
-
* @param {{ apiBaseUrl?: string, stripMode?: 'minimal' | 'full' }} [options]
|
|
94
|
-
* @returns {void}
|
|
95
|
-
*/
|
|
96
|
-
export function load(app, options = {}) {
|
|
97
|
-
const apiBaseUrl = options.apiBaseUrl ?? 'https://code.textmode.art/api/textmode.js';
|
|
98
|
-
const stripMode = options.stripMode ?? 'full';
|
|
99
|
-
|
|
100
|
-
app.converter.on(Converter.EVENT_RESOLVE_END, (context) => {
|
|
101
|
-
const reflections = context.project.getReflectionsByKind(ReflectionKind.All);
|
|
102
|
-
|
|
103
|
-
for (const reflection of reflections) {
|
|
104
|
-
stripReflectionHostedApiSeeTags(reflection, apiBaseUrl);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
app.renderer.on(MarkdownPageEvent.END, (page) => {
|
|
109
|
-
if (!page.contents) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
page.contents = stripHostedApiMarkdownLinks(page.contents, apiBaseUrl, stripMode);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
app.logger.verbose('[typedoc] Registered hosted API self-link stripper');
|
|
117
|
-
}
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { Application, TSConfigReader } from 'typedoc';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import os from 'node:os';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { load as loadFrontmatter } from 'typedoc-plugin-frontmatter';
|
|
6
|
-
import { load as loadMarkdown } from 'typedoc-plugin-markdown';
|
|
7
|
-
import { load as loadVitepressTheme } from 'typedoc-vitepress-theme';
|
|
8
|
-
|
|
9
|
-
import { load as loadAccessorDocsNormalizer } from './typedoc-plugins/accessor-docs-normalizer/index.js';
|
|
10
|
-
import { load as loadMemberPages } from './typedoc-plugins/all-member-pages-router/index.js';
|
|
11
|
-
import { load as loadApiFrontmatter } from './typedoc-plugins/api-frontmatter/index.js';
|
|
12
|
-
import { load as loadCodeExamples } from './typedoc-plugins/include-code-examples/index.js';
|
|
13
|
-
import { load as loadSelfLinkStripper } from './typedoc-plugins/strip-api-self-links/index.js';
|
|
14
|
-
import { DEFAULT_TYPEDOC_OPTIONS } from './config.js';
|
|
15
|
-
|
|
16
|
-
const BASE_TYPEDOC_OPTIONS = {
|
|
17
|
-
readme: 'none',
|
|
18
|
-
excludeInternal: true,
|
|
19
|
-
excludePrivate: true,
|
|
20
|
-
excludeProtected: true,
|
|
21
|
-
excludeExternals: false,
|
|
22
|
-
includeVersion: false,
|
|
23
|
-
disableSources: true,
|
|
24
|
-
useCodeBlocks: true,
|
|
25
|
-
jsDocCompatibility: {
|
|
26
|
-
exampleTag: false,
|
|
27
|
-
},
|
|
28
|
-
exclude: ['**/node_modules/**'],
|
|
29
|
-
...DEFAULT_TYPEDOC_OPTIONS,
|
|
30
|
-
logLevel: 'Verbose',
|
|
31
|
-
frontmatterCommentTags: ['author', 'since', 'deprecated'],
|
|
32
|
-
preserveFrontmatterCommentTags: false,
|
|
33
|
-
frontmatterNamingConvention: 'camelCase',
|
|
34
|
-
indexFormat: 'table',
|
|
35
|
-
parametersFormat: 'table',
|
|
36
|
-
interfacePropertiesFormat: 'table',
|
|
37
|
-
enumMembersFormat: 'list',
|
|
38
|
-
propertyMembersFormat: 'table',
|
|
39
|
-
typeDeclarationFormat: 'table',
|
|
40
|
-
cleanOutputDir: true,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
function pluginInitializers(config) {
|
|
44
|
-
const plugins = [loadMarkdown, loadFrontmatter, loadVitepressTheme, loadAccessorDocsNormalizer];
|
|
45
|
-
|
|
46
|
-
if (config.memberPageKinds.length > 0) {
|
|
47
|
-
plugins.push(function textmodeMemberPages(app) {
|
|
48
|
-
loadMemberPages(app, { memberPageKinds: config.memberPageKinds });
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
plugins.push(
|
|
53
|
-
function textmodeSelfLinkStripper(app) {
|
|
54
|
-
loadSelfLinkStripper(app, {
|
|
55
|
-
apiBaseUrl: config.apiBaseUrl,
|
|
56
|
-
stripMode: config.stripApiSelfLinks,
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
loadCodeExamples,
|
|
60
|
-
function textmodeApiFrontmatter(app) {
|
|
61
|
-
loadApiFrontmatter(app, { packageDescription: config.packageDescription });
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
return plugins;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function createEntrypointTsconfig({ tsconfig, projectRoot, entryPoints }) {
|
|
69
|
-
const temporaryDirectory = fs.mkdtempSync(path.join(os.tmpdir(), 'textmode-docs-tsconfig-'));
|
|
70
|
-
const configPath = path.join(temporaryDirectory, 'tsconfig.json');
|
|
71
|
-
fs.writeFileSync(
|
|
72
|
-
configPath,
|
|
73
|
-
`${JSON.stringify(
|
|
74
|
-
{
|
|
75
|
-
extends: tsconfig,
|
|
76
|
-
compilerOptions: {
|
|
77
|
-
noEmit: true,
|
|
78
|
-
rootDir: projectRoot,
|
|
79
|
-
types: [],
|
|
80
|
-
},
|
|
81
|
-
files: entryPoints,
|
|
82
|
-
},
|
|
83
|
-
null,
|
|
84
|
-
2
|
|
85
|
-
)}\n`
|
|
86
|
-
);
|
|
87
|
-
return {
|
|
88
|
-
configPath,
|
|
89
|
-
cleanup() {
|
|
90
|
-
fs.rmSync(temporaryDirectory, { recursive: true, force: true });
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function applicationOptions(config, { outputDir, strict = false, watch = false } = {}) {
|
|
96
|
-
const { compilerOptions = {}, ...typedocOptions } = config.typedoc;
|
|
97
|
-
return {
|
|
98
|
-
...BASE_TYPEDOC_OPTIONS,
|
|
99
|
-
frontmatterGlobals: {
|
|
100
|
-
layout: 'doc',
|
|
101
|
-
editLink: config.editLink ?? false,
|
|
102
|
-
},
|
|
103
|
-
...typedocOptions,
|
|
104
|
-
entryPoints: config.entryPoints,
|
|
105
|
-
entryPointStrategy: 'resolve',
|
|
106
|
-
tsconfig: config.tsconfig,
|
|
107
|
-
compilerOptions: {
|
|
108
|
-
...compilerOptions,
|
|
109
|
-
noEmit: true,
|
|
110
|
-
rootDir: config.projectRoot,
|
|
111
|
-
},
|
|
112
|
-
out: outputDir ?? config.outputDir,
|
|
113
|
-
name: config.packageName,
|
|
114
|
-
emit: 'docs',
|
|
115
|
-
watch,
|
|
116
|
-
plugin: pluginInitializers(config),
|
|
117
|
-
...(config.memberPageKinds.length > 0 ? { router: 'all-member-pages' } : {}),
|
|
118
|
-
treatWarningsAsErrors: strict,
|
|
119
|
-
treatValidationWarningsAsErrors: strict,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export async function createDocsApplication(config, options = {}) {
|
|
124
|
-
const temporaryConfig = createEntrypointTsconfig({
|
|
125
|
-
tsconfig: config.tsconfig,
|
|
126
|
-
projectRoot: config.projectRoot,
|
|
127
|
-
entryPoints: config.entryPoints,
|
|
128
|
-
});
|
|
129
|
-
try {
|
|
130
|
-
const app = await Application.bootstrapWithPlugins(
|
|
131
|
-
applicationOptions({ ...config, tsconfig: temporaryConfig.configPath }, options),
|
|
132
|
-
[new TSConfigReader()]
|
|
133
|
-
);
|
|
134
|
-
if (options.watch) {
|
|
135
|
-
process.once('exit', temporaryConfig.cleanup);
|
|
136
|
-
} else {
|
|
137
|
-
temporaryConfig.cleanup();
|
|
138
|
-
}
|
|
139
|
-
return app;
|
|
140
|
-
} catch (error) {
|
|
141
|
-
temporaryConfig.cleanup();
|
|
142
|
-
throw error;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export async function buildDocs(config, { outputDir, strict = false } = {}) {
|
|
147
|
-
const app = await createDocsApplication(config, { outputDir, strict });
|
|
148
|
-
const project = await app.convert();
|
|
149
|
-
if (!project || app.logger.hasErrors()) {
|
|
150
|
-
return { app, project, ok: false };
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
app.validate(project);
|
|
154
|
-
if (app.logger.hasErrors()) {
|
|
155
|
-
return { app, project, ok: false };
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
await app.generateOutputs(project);
|
|
159
|
-
return { app, project, ok: !app.logger.hasErrors() };
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export async function watchDocs(config, { outputDir } = {}) {
|
|
163
|
-
const app = await createDocsApplication(config, { outputDir, watch: true });
|
|
164
|
-
const started = await app.convertAndWatch(async (project) => {
|
|
165
|
-
app.validate(project);
|
|
166
|
-
if (!app.logger.hasErrors()) {
|
|
167
|
-
await app.generateOutputs(project);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
return { app, ok: started };
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export async function loadEntryPointProject({ entryPoint, tsconfig, packageName, projectRoot }) {
|
|
174
|
-
const temporaryConfig = createEntrypointTsconfig({ tsconfig, projectRoot, entryPoints: [entryPoint] });
|
|
175
|
-
let app;
|
|
176
|
-
try {
|
|
177
|
-
app = await Application.bootstrap(
|
|
178
|
-
{
|
|
179
|
-
entryPoints: [entryPoint],
|
|
180
|
-
entryPointStrategy: 'resolve',
|
|
181
|
-
tsconfig: temporaryConfig.configPath,
|
|
182
|
-
name: packageName,
|
|
183
|
-
excludeInternal: true,
|
|
184
|
-
excludePrivate: true,
|
|
185
|
-
excludeProtected: true,
|
|
186
|
-
readme: 'none',
|
|
187
|
-
emit: 'none',
|
|
188
|
-
logLevel: 'Error',
|
|
189
|
-
},
|
|
190
|
-
[new TSConfigReader()]
|
|
191
|
-
);
|
|
192
|
-
} finally {
|
|
193
|
-
temporaryConfig.cleanup();
|
|
194
|
-
}
|
|
195
|
-
const project = await app.convert();
|
|
196
|
-
if (!project || app.logger.hasErrors()) {
|
|
197
|
-
throw new Error(`TypeDoc failed to resolve ${entryPoint}.`);
|
|
198
|
-
}
|
|
199
|
-
return project;
|
|
200
|
-
}
|