@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
package/src/example-quality.mjs
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
import { checkSketchTitle } from './internal/lib/sketch-title.mjs';
|
|
3
|
-
import { LABEL_SCHEMA } from './internal/lib/label-schema.mjs';
|
|
4
|
-
|
|
5
|
-
function countSketchLines(content) {
|
|
6
|
-
if (!content) return 0;
|
|
7
|
-
const lines = content.split(/\r\n|\r|\n/);
|
|
8
|
-
if (/\r\n$|[\r\n]$/.test(content)) lines.pop();
|
|
9
|
-
return lines.length;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/** Strip supported formatting tags before counting displayed characters. */
|
|
13
|
-
export function displayedRowLength(value, markup = true) {
|
|
14
|
-
const text = markup ? value.replace(/\[\/?(?:fg|bg|inv|rot|fx|fy)(?:=[^\]]*)?\]/gi, '') : value;
|
|
15
|
-
return [...text].length;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** Locate a conventional top-level label declaration for optional observation. */
|
|
19
|
-
function labelDeclaration(source) {
|
|
20
|
-
for (const statement of source.statements) {
|
|
21
|
-
if (!ts.isVariableStatement(statement) || !(statement.declarationList.flags & ts.NodeFlags.Const)) continue;
|
|
22
|
-
for (const declaration of statement.declarationList.declarations) {
|
|
23
|
-
if (!ts.isIdentifier(declaration.name) || !/^label\w*$/i.test(declaration.name.text)) continue;
|
|
24
|
-
const init = declaration.initializer;
|
|
25
|
-
if (
|
|
26
|
-
!init ||
|
|
27
|
-
!ts.isCallExpression(init) ||
|
|
28
|
-
!ts.isPropertyAccessExpression(init.expression) ||
|
|
29
|
-
init.expression.name.text !== 'add'
|
|
30
|
-
)
|
|
31
|
-
continue;
|
|
32
|
-
const layers = init.expression.expression;
|
|
33
|
-
if (
|
|
34
|
-
!ts.isPropertyAccessExpression(layers) ||
|
|
35
|
-
layers.name.text !== 'layers' ||
|
|
36
|
-
!ts.isIdentifier(layers.expression)
|
|
37
|
-
)
|
|
38
|
-
continue;
|
|
39
|
-
return { end: statement.end, layer: declaration.name.text, instance: layers.expression.text };
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** Check what can be established from source; leave visual and dynamic claims for review. */
|
|
46
|
-
export function analyzeExampleSource(content, { title, fileName = 'sketch.js' } = {}) {
|
|
47
|
-
const source = ts.createSourceFile(fileName, content, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
|
|
48
|
-
const issues = [];
|
|
49
|
-
const review = [];
|
|
50
|
-
const lineCount = countSketchLines(content);
|
|
51
|
-
if (lineCount > 100) issues.push(`Sketch has ${lineCount} lines; maximum is 100.`);
|
|
52
|
-
for (const diagnostic of source.parseDiagnostics) {
|
|
53
|
-
issues.push(`Syntax: ${ts.flattenDiagnosticMessageText(diagnostic.messageText, ' ')}`);
|
|
54
|
-
}
|
|
55
|
-
const titleCheck = checkSketchTitle(content, title);
|
|
56
|
-
if (titleCheck.kind === 'missing') issues.push('Missing @title in the leading JSDoc header.');
|
|
57
|
-
else if (titleCheck.kind === 'mismatch')
|
|
58
|
-
issues.push(`Header title "${titleCheck.actual}" does not match manifest title "${title}".`);
|
|
59
|
-
|
|
60
|
-
const layers = new Set();
|
|
61
|
-
const callbacks = [];
|
|
62
|
-
const instances = new Set();
|
|
63
|
-
function findInstances(node) {
|
|
64
|
-
if (
|
|
65
|
-
ts.isVariableDeclaration(node) &&
|
|
66
|
-
ts.isIdentifier(node.name) &&
|
|
67
|
-
node.initializer &&
|
|
68
|
-
ts.isCallExpression(node.initializer) &&
|
|
69
|
-
node.initializer.expression.getText(source) === 'textmode.create'
|
|
70
|
-
)
|
|
71
|
-
instances.add(node.name.text);
|
|
72
|
-
ts.forEachChild(node, findInstances);
|
|
73
|
-
}
|
|
74
|
-
findInstances(source);
|
|
75
|
-
let createOptions;
|
|
76
|
-
let hasResizeHandler = false;
|
|
77
|
-
let hasViewportResize = false;
|
|
78
|
-
function visit(node) {
|
|
79
|
-
if (ts.isFunctionDeclaration(node) && node.name?.text === 'windowResized') hasResizeHandler = true;
|
|
80
|
-
if (ts.isVariableDeclarationList(node) && !(node.flags & (ts.NodeFlags.Const | ts.NodeFlags.Let))) {
|
|
81
|
-
issues.push('Do not use `var`; prefer `const` or `let`.');
|
|
82
|
-
}
|
|
83
|
-
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)) {
|
|
84
|
-
const method = node.expression.name.text;
|
|
85
|
-
if (method === 'create' && node.expression.expression.getText(source) === 'textmode')
|
|
86
|
-
createOptions = node.arguments[0];
|
|
87
|
-
if (method === 'windowResized' && instances.has(node.expression.expression.getText(source)))
|
|
88
|
-
hasResizeHandler = true;
|
|
89
|
-
if (
|
|
90
|
-
method === 'resizeCanvas' &&
|
|
91
|
-
instances.has(node.expression.expression.getText(source)) &&
|
|
92
|
-
node.arguments[0]?.getText(source) === 'window.innerWidth' &&
|
|
93
|
-
node.arguments[1]?.getText(source) === 'window.innerHeight'
|
|
94
|
-
)
|
|
95
|
-
hasViewportResize = true;
|
|
96
|
-
}
|
|
97
|
-
if (
|
|
98
|
-
ts.isCallExpression(node) &&
|
|
99
|
-
ts.isIdentifier(node.expression) &&
|
|
100
|
-
node.expression.text === 'resizeCanvas' &&
|
|
101
|
-
node.arguments[0]?.getText(source) === 'window.innerWidth' &&
|
|
102
|
-
node.arguments[1]?.getText(source) === 'window.innerHeight'
|
|
103
|
-
)
|
|
104
|
-
hasViewportResize = true;
|
|
105
|
-
if (
|
|
106
|
-
ts.isVariableDeclaration(node) &&
|
|
107
|
-
ts.isIdentifier(node.name) &&
|
|
108
|
-
node.initializer &&
|
|
109
|
-
ts.isCallExpression(node.initializer)
|
|
110
|
-
) {
|
|
111
|
-
const call = node.initializer.expression;
|
|
112
|
-
if (
|
|
113
|
-
ts.isPropertyAccessExpression(call) &&
|
|
114
|
-
call.name.text === 'add' &&
|
|
115
|
-
ts.isPropertyAccessExpression(call.expression) &&
|
|
116
|
-
call.expression.name.text === 'layers'
|
|
117
|
-
)
|
|
118
|
-
layers.add(node.name.text);
|
|
119
|
-
}
|
|
120
|
-
if (
|
|
121
|
-
ts.isCallExpression(node) &&
|
|
122
|
-
ts.isPropertyAccessExpression(node.expression) &&
|
|
123
|
-
node.expression.name.text === 'draw' &&
|
|
124
|
-
ts.isIdentifier(node.expression.expression)
|
|
125
|
-
)
|
|
126
|
-
callbacks.push(node);
|
|
127
|
-
ts.forEachChild(node, visit);
|
|
128
|
-
}
|
|
129
|
-
visit(source);
|
|
130
|
-
if (!createOptions || !ts.isObjectLiteralExpression(createOptions)) {
|
|
131
|
-
review.push('Could not establish viewport sizing in textmode.create options.');
|
|
132
|
-
} else {
|
|
133
|
-
const options = new Map(
|
|
134
|
-
createOptions.properties
|
|
135
|
-
.filter(ts.isPropertyAssignment)
|
|
136
|
-
.map((property) => [property.name.getText(source), property.initializer])
|
|
137
|
-
);
|
|
138
|
-
for (const [name, expected] of [
|
|
139
|
-
['width', 'window.innerWidth'],
|
|
140
|
-
['height', 'window.innerHeight'],
|
|
141
|
-
]) {
|
|
142
|
-
const option = options.get(name);
|
|
143
|
-
if (
|
|
144
|
-
createOptions.properties.some(ts.isSpreadAssignment) ||
|
|
145
|
-
(option && !ts.isNumericLiteral(option) && option.getText(source) !== expected)
|
|
146
|
-
)
|
|
147
|
-
review.push(`Check \`${name}\` in create options; its value cannot be established statically.`);
|
|
148
|
-
else if (!option || option.getText(source) !== expected)
|
|
149
|
-
issues.push(`\`${name}\` must be set to \`${expected}\` in create options.`);
|
|
150
|
-
}
|
|
151
|
-
const fontSize = options.get('fontSize');
|
|
152
|
-
if (fontSize && ts.isNumericLiteral(fontSize) && ![8, 16, 32].includes(Number(fontSize.text)))
|
|
153
|
-
issues.push('Literal `fontSize` must be 8, 16, or 32.');
|
|
154
|
-
}
|
|
155
|
-
if (!hasResizeHandler || !hasViewportResize) review.push('Check the resize handler and viewport resize behavior.');
|
|
156
|
-
// A layer name alone does not prove intent, but it limits definite row checks
|
|
157
|
-
// to the conventional label callback instead of unrelated artwork text.
|
|
158
|
-
const layerCallbacks = callbacks.filter(
|
|
159
|
-
(node) => layers.has(node.expression.expression.text) && /label/i.test(node.expression.expression.text)
|
|
160
|
-
);
|
|
161
|
-
if (!layerCallbacks.length)
|
|
162
|
-
review.push('Could not establish a dedicated label layer and draw callback; inspect it manually.');
|
|
163
|
-
let foundPrint = false;
|
|
164
|
-
let dynamic = false;
|
|
165
|
-
const recognizedDefaults = new Set();
|
|
166
|
-
const palette = LABEL_SCHEMA.palette;
|
|
167
|
-
for (const callback of layerCallbacks) {
|
|
168
|
-
function inspect(node) {
|
|
169
|
-
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)) {
|
|
170
|
-
const method = node.expression.name.text;
|
|
171
|
-
const rgb = node.arguments
|
|
172
|
-
.slice(0, 3)
|
|
173
|
-
.map((arg) => (ts.isNumericLiteral(arg) ? arg.text : '?'))
|
|
174
|
-
.join(',');
|
|
175
|
-
if (method === 'charColor' && palette[rgb]) recognizedDefaults.add(palette[rgb]);
|
|
176
|
-
if (method === 'cellColor' && rgb === LABEL_SCHEMA.panelColor) recognizedDefaults.add('panel color');
|
|
177
|
-
}
|
|
178
|
-
if (
|
|
179
|
-
ts.isCallExpression(node) &&
|
|
180
|
-
ts.isPropertyAccessExpression(node.expression) &&
|
|
181
|
-
node.expression.name.text === 'print'
|
|
182
|
-
) {
|
|
183
|
-
foundPrint = true;
|
|
184
|
-
const value = node.arguments[0];
|
|
185
|
-
if (value && (ts.isStringLiteral(value) || ts.isNoSubstitutionTemplateLiteral(value))) {
|
|
186
|
-
if (value.text === '-'.repeat(LABEL_SCHEMA.dividerLength))
|
|
187
|
-
recognizedDefaults.add(`${LABEL_SCHEMA.dividerLength}-character divider`);
|
|
188
|
-
const options = node.arguments[3];
|
|
189
|
-
const markupDisabled =
|
|
190
|
-
options &&
|
|
191
|
-
ts.isObjectLiteralExpression(options) &&
|
|
192
|
-
options.properties.some(
|
|
193
|
-
(p) =>
|
|
194
|
-
ts.isPropertyAssignment(p) &&
|
|
195
|
-
p.name.getText(source) === 'markup' &&
|
|
196
|
-
p.initializer.kind === ts.SyntaxKind.FalseKeyword
|
|
197
|
-
);
|
|
198
|
-
if (/[\r\n\t]/.test(value.text) || (options && !ts.isObjectLiteralExpression(options))) {
|
|
199
|
-
review.push('Label text or print options need review to establish displayed row lengths.');
|
|
200
|
-
} else {
|
|
201
|
-
const length = displayedRowLength(value.text, !markupDisabled);
|
|
202
|
-
if (length > LABEL_SCHEMA.rowLimit)
|
|
203
|
-
issues.push(
|
|
204
|
-
`Possible label row has ${length} displayed characters; maximum is ${LABEL_SCHEMA.rowLimit}.`
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
} else dynamic = true;
|
|
208
|
-
}
|
|
209
|
-
ts.forEachChild(node, inspect);
|
|
210
|
-
}
|
|
211
|
-
for (const arg of callback.arguments)
|
|
212
|
-
if (ts.isArrowFunction(arg) || ts.isFunctionExpression(arg)) inspect(arg.body);
|
|
213
|
-
}
|
|
214
|
-
if (!foundPrint) review.push('Label text could not be identified statically; inspect row lengths and content.');
|
|
215
|
-
if (dynamic)
|
|
216
|
-
review.push(
|
|
217
|
-
`Dynamic label text needs runtime observation and a bound of ${LABEL_SCHEMA.rowLimit} displayed characters.`
|
|
218
|
-
);
|
|
219
|
-
review.push('Inspect label layer identity, opaque panel, layout, palette, readability, and educational quality.');
|
|
220
|
-
return {
|
|
221
|
-
lineCount,
|
|
222
|
-
issues,
|
|
223
|
-
review,
|
|
224
|
-
recognizedDefaults: [...recognizedDefaults],
|
|
225
|
-
labelDeclaration: labelDeclaration(source),
|
|
226
|
-
};
|
|
227
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const CONFIG_MARKER = Symbol.for('@textmode/docs/config');
|
|
2
|
-
|
|
3
|
-
export { analyzeExampleSource, displayedRowLength } from './example-quality.mjs';
|
|
4
|
-
export { LABEL_SCHEMA as exampleLabelSchema } from './internal/lib/label-schema.mjs';
|
|
5
|
-
export { validateExamplesManifest } from './internal/lib/example-checks.mjs';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Define project-specific documentation policy.
|
|
9
|
-
*
|
|
10
|
-
* @template {import('../index.d.ts').TextmodeDocsConfig} T
|
|
11
|
-
* @param {T} config
|
|
12
|
-
* @returns {T}
|
|
13
|
-
*/
|
|
14
|
-
export function defineDocs(config) {
|
|
15
|
-
if (config === null || typeof config !== 'object' || Array.isArray(config)) {
|
|
16
|
-
throw new TypeError('defineDocs expects a configuration object.');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(config, CONFIG_MARKER, {
|
|
20
|
-
configurable: false,
|
|
21
|
-
enumerable: false,
|
|
22
|
-
value: true,
|
|
23
|
-
writable: false,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
return config;
|
|
27
|
-
}
|
package/src/internal/config.js
DELETED
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { pathToFileURL } from 'node:url';
|
|
4
|
-
|
|
5
|
-
const CONFIG_MARKER = Symbol.for('@textmode/docs/config');
|
|
6
|
-
const TOP_LEVEL_KEYS = new Set([
|
|
7
|
-
'entryPoints',
|
|
8
|
-
'linkEntryPoints',
|
|
9
|
-
'sourceRoots',
|
|
10
|
-
'outputDir',
|
|
11
|
-
'apiBaseUrl',
|
|
12
|
-
'tsconfig',
|
|
13
|
-
'memberPageKinds',
|
|
14
|
-
'stripApiSelfLinks',
|
|
15
|
-
'editLink',
|
|
16
|
-
'checks',
|
|
17
|
-
'examples',
|
|
18
|
-
'typedoc',
|
|
19
|
-
]);
|
|
20
|
-
const CHECK_KEYS = new Set(['apiLinks', 'docstrings', 'examples']);
|
|
21
|
-
const EXAMPLE_KEYS = new Set(['forbidGallerySourceBase']);
|
|
22
|
-
const LINK_ENTRY_POINT_KEYS = new Set(['path', 'tsconfig', 'namespaceExportsOnly']);
|
|
23
|
-
const REFLECTION_KINDS = new Set([
|
|
24
|
-
'class',
|
|
25
|
-
'interface',
|
|
26
|
-
'typeAlias',
|
|
27
|
-
'enum',
|
|
28
|
-
'variable',
|
|
29
|
-
'function',
|
|
30
|
-
'method',
|
|
31
|
-
'accessor',
|
|
32
|
-
'property',
|
|
33
|
-
]);
|
|
34
|
-
const MEMBER_PAGE_KINDS = new Set(['method', 'property', 'accessor']);
|
|
35
|
-
const PROTECTED_TYPEDOC_KEYS = new Set([
|
|
36
|
-
'entryPoints',
|
|
37
|
-
'out',
|
|
38
|
-
'tsconfig',
|
|
39
|
-
'plugin',
|
|
40
|
-
'router',
|
|
41
|
-
'emit',
|
|
42
|
-
'watch',
|
|
43
|
-
'treatWarningsAsErrors',
|
|
44
|
-
'treatValidationWarningsAsErrors',
|
|
45
|
-
]);
|
|
46
|
-
|
|
47
|
-
export const DEFAULT_API_LINK_KINDS = [
|
|
48
|
-
'class',
|
|
49
|
-
'interface',
|
|
50
|
-
'typeAlias',
|
|
51
|
-
'enum',
|
|
52
|
-
'variable',
|
|
53
|
-
'function',
|
|
54
|
-
'method',
|
|
55
|
-
'accessor',
|
|
56
|
-
'property',
|
|
57
|
-
];
|
|
58
|
-
export const DEFAULT_DOCSTRING_KINDS = [...DEFAULT_API_LINK_KINDS];
|
|
59
|
-
export const DEFAULT_EXAMPLE_KINDS = ['function', 'method', 'accessor'];
|
|
60
|
-
export const DEFAULT_MEMBER_PAGE_KINDS = ['method', 'property', 'accessor'];
|
|
61
|
-
export const DEFAULT_TYPEDOC_OPTIONS = {
|
|
62
|
-
sort: ['kind', 'instance-first', 'alphabetical-ignoring-documents'],
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
function isRecord(value) {
|
|
66
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function unknownKeys(value, allowed) {
|
|
70
|
-
return Object.keys(value).filter((key) => !allowed.has(key));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function assertNoUnknownKeys(value, allowed, label) {
|
|
74
|
-
const keys = unknownKeys(value, allowed);
|
|
75
|
-
if (keys.length > 0) {
|
|
76
|
-
throw new Error(`${label} contains unknown key${keys.length === 1 ? '' : 's'}: ${keys.join(', ')}`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function assertString(value, label) {
|
|
81
|
-
if (typeof value !== 'string' || value.length === 0) {
|
|
82
|
-
throw new Error(`${label} must be a non-empty string.`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function assertStringArray(value, label, { allowEmpty = false, allowedValues } = {}) {
|
|
87
|
-
if (!Array.isArray(value) || (!allowEmpty && value.length === 0)) {
|
|
88
|
-
throw new Error(`${label} must be ${allowEmpty ? 'an' : 'a non-empty'} array.`);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
for (const item of value) {
|
|
92
|
-
assertString(item, `${label} entries`);
|
|
93
|
-
if (allowedValues && !allowedValues.has(item)) {
|
|
94
|
-
throw new Error(`${label} contains unsupported value "${item}".`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (new Set(value).size !== value.length) {
|
|
99
|
-
throw new Error(`${label} must not contain duplicate values.`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function validateLinkEntryPoints(value) {
|
|
104
|
-
if (!Array.isArray(value) || value.length === 0) {
|
|
105
|
-
throw new Error('linkEntryPoints must be a non-empty array.');
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
for (const [index, entryPoint] of value.entries()) {
|
|
109
|
-
if (!isRecord(entryPoint)) {
|
|
110
|
-
throw new Error(`linkEntryPoints[${index}] must be an object.`);
|
|
111
|
-
}
|
|
112
|
-
assertNoUnknownKeys(entryPoint, LINK_ENTRY_POINT_KEYS, `linkEntryPoints[${index}]`);
|
|
113
|
-
assertString(entryPoint.path, `linkEntryPoints[${index}].path`);
|
|
114
|
-
if (entryPoint.tsconfig !== undefined) {
|
|
115
|
-
assertString(entryPoint.tsconfig, `linkEntryPoints[${index}].tsconfig`);
|
|
116
|
-
}
|
|
117
|
-
if (entryPoint.namespaceExportsOnly !== undefined && typeof entryPoint.namespaceExportsOnly !== 'boolean') {
|
|
118
|
-
throw new Error(`linkEntryPoints[${index}].namespaceExportsOnly must be a boolean.`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function validateChecks(value) {
|
|
124
|
-
if (!isRecord(value)) {
|
|
125
|
-
throw new Error('checks must be an object.');
|
|
126
|
-
}
|
|
127
|
-
assertNoUnknownKeys(value, CHECK_KEYS, 'checks');
|
|
128
|
-
for (const key of CHECK_KEYS) {
|
|
129
|
-
if (value[key] !== undefined) {
|
|
130
|
-
assertStringArray(value[key], `checks.${key}`, {
|
|
131
|
-
allowEmpty: true,
|
|
132
|
-
allowedValues: REFLECTION_KINDS,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function validateExamples(value) {
|
|
139
|
-
if (value === false) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
if (!isRecord(value)) {
|
|
143
|
-
throw new Error('examples must be false or an object.');
|
|
144
|
-
}
|
|
145
|
-
assertNoUnknownKeys(value, EXAMPLE_KEYS, 'examples');
|
|
146
|
-
for (const key of EXAMPLE_KEYS) {
|
|
147
|
-
if (value[key] !== undefined && typeof value[key] !== 'boolean') {
|
|
148
|
-
throw new Error(`examples.${key} must be a boolean.`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function validateTypeDocOverrides(value) {
|
|
154
|
-
if (!isRecord(value)) {
|
|
155
|
-
throw new Error('typedoc must be an object.');
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
for (const key of Object.keys(value)) {
|
|
159
|
-
if (PROTECTED_TYPEDOC_KEYS.has(key) || key.toLowerCase().startsWith('textmode')) {
|
|
160
|
-
throw new Error(`typedoc.${key} is owned by @textmode/docs and cannot be overridden.`);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export function validateDocsConfig(config) {
|
|
166
|
-
if (!isRecord(config)) {
|
|
167
|
-
throw new Error('The documentation config must export an object created by defineDocs().');
|
|
168
|
-
}
|
|
169
|
-
assertNoUnknownKeys(config, TOP_LEVEL_KEYS, 'Documentation config');
|
|
170
|
-
|
|
171
|
-
if (config.entryPoints !== undefined) {
|
|
172
|
-
assertStringArray(config.entryPoints, 'entryPoints');
|
|
173
|
-
}
|
|
174
|
-
if (config.linkEntryPoints !== undefined) {
|
|
175
|
-
validateLinkEntryPoints(config.linkEntryPoints);
|
|
176
|
-
}
|
|
177
|
-
if (config.sourceRoots !== undefined) {
|
|
178
|
-
assertStringArray(config.sourceRoots, 'sourceRoots');
|
|
179
|
-
}
|
|
180
|
-
if (config.outputDir !== undefined) {
|
|
181
|
-
assertString(config.outputDir, 'outputDir');
|
|
182
|
-
}
|
|
183
|
-
if (config.apiBaseUrl !== undefined) {
|
|
184
|
-
assertString(config.apiBaseUrl, 'apiBaseUrl');
|
|
185
|
-
try {
|
|
186
|
-
new URL(config.apiBaseUrl);
|
|
187
|
-
} catch {
|
|
188
|
-
throw new Error('apiBaseUrl must be an absolute URL.');
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
if (config.tsconfig !== undefined) {
|
|
192
|
-
assertString(config.tsconfig, 'tsconfig');
|
|
193
|
-
}
|
|
194
|
-
if (config.memberPageKinds !== undefined) {
|
|
195
|
-
assertStringArray(config.memberPageKinds, 'memberPageKinds', {
|
|
196
|
-
allowEmpty: true,
|
|
197
|
-
allowedValues: MEMBER_PAGE_KINDS,
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
if (
|
|
201
|
-
config.stripApiSelfLinks !== undefined &&
|
|
202
|
-
config.stripApiSelfLinks !== 'minimal' &&
|
|
203
|
-
config.stripApiSelfLinks !== 'full'
|
|
204
|
-
) {
|
|
205
|
-
throw new Error('stripApiSelfLinks must be "minimal" or "full".');
|
|
206
|
-
}
|
|
207
|
-
if (config.editLink !== undefined && typeof config.editLink !== 'boolean') {
|
|
208
|
-
throw new Error('editLink must be a boolean.');
|
|
209
|
-
}
|
|
210
|
-
if (config.checks !== undefined) {
|
|
211
|
-
validateChecks(config.checks);
|
|
212
|
-
}
|
|
213
|
-
if (config.examples !== undefined) {
|
|
214
|
-
validateExamples(config.examples);
|
|
215
|
-
}
|
|
216
|
-
if (config.typedoc !== undefined) {
|
|
217
|
-
validateTypeDocOverrides(config.typedoc);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function sourceRootsForEntryPoints(entryPoints) {
|
|
222
|
-
return Array.from(
|
|
223
|
-
new Set(
|
|
224
|
-
entryPoints.map((entryPoint) => {
|
|
225
|
-
const normalized = entryPoint.path.replaceAll('\\', '/').replace(/^\.\//, '');
|
|
226
|
-
const firstSegment = normalized.split('/')[0];
|
|
227
|
-
return firstSegment || path.dirname(normalized);
|
|
228
|
-
})
|
|
229
|
-
)
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function resolveProjectPath(projectRoot, value) {
|
|
234
|
-
return path.resolve(projectRoot, value);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function origin(config, key, fallback) {
|
|
238
|
-
return Object.hasOwn(config, key) ? 'textmode.docs.config.mjs' : fallback;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
async function loadProjectConfig(projectRoot, requestedConfigPath) {
|
|
242
|
-
const configPath = requestedConfigPath
|
|
243
|
-
? resolveProjectPath(projectRoot, requestedConfigPath)
|
|
244
|
-
: path.join(projectRoot, 'textmode.docs.config.mjs');
|
|
245
|
-
|
|
246
|
-
if (!fs.existsSync(configPath)) {
|
|
247
|
-
if (requestedConfigPath) {
|
|
248
|
-
throw new Error(`Documentation config does not exist: ${configPath}`);
|
|
249
|
-
}
|
|
250
|
-
return { config: {}, configPath: null };
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const module = await import(pathToFileURL(configPath).href);
|
|
254
|
-
const config = module.default;
|
|
255
|
-
if (!config?.[CONFIG_MARKER]) {
|
|
256
|
-
throw new Error(`${configPath} must default-export defineDocs({ ... }).`);
|
|
257
|
-
}
|
|
258
|
-
validateDocsConfig(config);
|
|
259
|
-
return { config, configPath };
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
export async function resolveDocsConfig({ cwd = process.cwd(), configPath: requestedConfigPath, out } = {}) {
|
|
263
|
-
const projectRoot = path.resolve(cwd);
|
|
264
|
-
const packageJsonPath = path.join(projectRoot, 'package.json');
|
|
265
|
-
if (!fs.existsSync(packageJsonPath)) {
|
|
266
|
-
throw new Error(`Missing package.json in documentation project root: ${projectRoot}`);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
270
|
-
assertString(packageJson.name, 'package.json#name');
|
|
271
|
-
const packageDescription =
|
|
272
|
-
typeof packageJson.description === 'string' && packageJson.description.trim()
|
|
273
|
-
? packageJson.description.trim()
|
|
274
|
-
: `API reference for ${packageJson.name}`;
|
|
275
|
-
const { config, configPath } = await loadProjectConfig(projectRoot, requestedConfigPath);
|
|
276
|
-
|
|
277
|
-
const entryPoints = config.entryPoints ?? ['src/index.ts'];
|
|
278
|
-
const tsconfig = config.tsconfig ?? 'tsconfig.json';
|
|
279
|
-
const linkEntryPoints =
|
|
280
|
-
config.linkEntryPoints ??
|
|
281
|
-
entryPoints.map((entryPoint) => ({
|
|
282
|
-
path: entryPoint,
|
|
283
|
-
tsconfig,
|
|
284
|
-
namespaceExportsOnly: false,
|
|
285
|
-
}));
|
|
286
|
-
const sourceRoots = config.sourceRoots ?? sourceRootsForEntryPoints(linkEntryPoints);
|
|
287
|
-
const checks = {
|
|
288
|
-
apiLinks: config.checks?.apiLinks ?? DEFAULT_API_LINK_KINDS,
|
|
289
|
-
docstrings: config.checks?.docstrings ?? DEFAULT_DOCSTRING_KINDS,
|
|
290
|
-
examples: config.checks?.examples ?? DEFAULT_EXAMPLE_KINDS,
|
|
291
|
-
};
|
|
292
|
-
const examples =
|
|
293
|
-
config.examples === false
|
|
294
|
-
? false
|
|
295
|
-
: {
|
|
296
|
-
forbidGallerySourceBase: config.examples?.forbidGallerySourceBase ?? true,
|
|
297
|
-
};
|
|
298
|
-
const outputDir = out ?? config.outputDir ?? `api/${packageJson.name}`;
|
|
299
|
-
|
|
300
|
-
const resolved = {
|
|
301
|
-
projectRoot,
|
|
302
|
-
configPath,
|
|
303
|
-
packageJsonPath,
|
|
304
|
-
packageName: packageJson.name,
|
|
305
|
-
packageDescription,
|
|
306
|
-
entryPoints: entryPoints.map((entryPoint) => resolveProjectPath(projectRoot, entryPoint)),
|
|
307
|
-
linkEntryPoints: linkEntryPoints.map((entryPoint) => ({
|
|
308
|
-
path: resolveProjectPath(projectRoot, entryPoint.path),
|
|
309
|
-
tsconfig: resolveProjectPath(projectRoot, entryPoint.tsconfig ?? tsconfig),
|
|
310
|
-
namespaceExportsOnly: entryPoint.namespaceExportsOnly ?? false,
|
|
311
|
-
})),
|
|
312
|
-
sourceRoots: sourceRoots.map((sourceRoot) => resolveProjectPath(projectRoot, sourceRoot)),
|
|
313
|
-
outputDir: resolveProjectPath(projectRoot, outputDir),
|
|
314
|
-
apiBaseUrl: config.apiBaseUrl ?? `https://code.textmode.art/api/${packageJson.name}`,
|
|
315
|
-
tsconfig: resolveProjectPath(projectRoot, tsconfig),
|
|
316
|
-
memberPageKinds: config.memberPageKinds ?? DEFAULT_MEMBER_PAGE_KINDS,
|
|
317
|
-
stripApiSelfLinks: config.stripApiSelfLinks ?? 'full',
|
|
318
|
-
editLink: config.editLink ?? false,
|
|
319
|
-
checks,
|
|
320
|
-
examples,
|
|
321
|
-
typedoc: { ...DEFAULT_TYPEDOC_OPTIONS, ...(config.typedoc ?? {}) },
|
|
322
|
-
origins: {
|
|
323
|
-
packageName: 'package.json#name',
|
|
324
|
-
packageDescription:
|
|
325
|
-
typeof packageJson.description === 'string' && packageJson.description.trim()
|
|
326
|
-
? 'package.json#description'
|
|
327
|
-
: 'default',
|
|
328
|
-
entryPoints: origin(config, 'entryPoints', 'default'),
|
|
329
|
-
linkEntryPoints: origin(config, 'linkEntryPoints', origin(config, 'entryPoints', 'default')),
|
|
330
|
-
sourceRoots: origin(config, 'sourceRoots', 'derived:linkEntryPoints'),
|
|
331
|
-
outputDir: out ? 'command:--out' : origin(config, 'outputDir', 'derived:package.json#name'),
|
|
332
|
-
apiBaseUrl: origin(config, 'apiBaseUrl', 'derived:package.json#name'),
|
|
333
|
-
tsconfig: origin(config, 'tsconfig', 'default'),
|
|
334
|
-
memberPageKinds: origin(config, 'memberPageKinds', 'default'),
|
|
335
|
-
stripApiSelfLinks: origin(config, 'stripApiSelfLinks', 'default'),
|
|
336
|
-
editLink: origin(config, 'editLink', 'default'),
|
|
337
|
-
checks: {
|
|
338
|
-
apiLinks: config.checks?.apiLinks ? 'textmode.docs.config.mjs' : 'default',
|
|
339
|
-
docstrings: config.checks?.docstrings ? 'textmode.docs.config.mjs' : 'default',
|
|
340
|
-
examples: config.checks?.examples ? 'textmode.docs.config.mjs' : 'default',
|
|
341
|
-
},
|
|
342
|
-
examples:
|
|
343
|
-
config.examples === false
|
|
344
|
-
? 'textmode.docs.config.mjs'
|
|
345
|
-
: {
|
|
346
|
-
forbidGallerySourceBase:
|
|
347
|
-
config.examples?.forbidGallerySourceBase !== undefined
|
|
348
|
-
? 'textmode.docs.config.mjs'
|
|
349
|
-
: 'default',
|
|
350
|
-
},
|
|
351
|
-
typedoc: origin(config, 'typedoc', 'default'),
|
|
352
|
-
},
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
return resolved;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
function displayPath(projectRoot, value) {
|
|
359
|
-
const relative = path.relative(projectRoot, value);
|
|
360
|
-
return relative && !relative.startsWith('..') ? relative.split(path.sep).join('/') : value;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
export function formatResolvedConfig(config) {
|
|
364
|
-
return {
|
|
365
|
-
projectRoot: config.projectRoot,
|
|
366
|
-
configPath: config.configPath,
|
|
367
|
-
packageName: config.packageName,
|
|
368
|
-
packageDescription: config.packageDescription,
|
|
369
|
-
entryPoints: config.entryPoints.map((value) => displayPath(config.projectRoot, value)),
|
|
370
|
-
linkEntryPoints: config.linkEntryPoints.map((entryPoint) => ({
|
|
371
|
-
path: displayPath(config.projectRoot, entryPoint.path),
|
|
372
|
-
tsconfig: displayPath(config.projectRoot, entryPoint.tsconfig),
|
|
373
|
-
namespaceExportsOnly: entryPoint.namespaceExportsOnly,
|
|
374
|
-
})),
|
|
375
|
-
sourceRoots: config.sourceRoots.map((value) => displayPath(config.projectRoot, value)),
|
|
376
|
-
outputDir: displayPath(config.projectRoot, config.outputDir),
|
|
377
|
-
apiBaseUrl: config.apiBaseUrl,
|
|
378
|
-
tsconfig: displayPath(config.projectRoot, config.tsconfig),
|
|
379
|
-
memberPageKinds: config.memberPageKinds,
|
|
380
|
-
stripApiSelfLinks: config.stripApiSelfLinks,
|
|
381
|
-
editLink: config.editLink,
|
|
382
|
-
checks: config.checks,
|
|
383
|
-
examples: config.examples,
|
|
384
|
-
typedoc: config.typedoc,
|
|
385
|
-
origins: config.origins,
|
|
386
|
-
};
|
|
387
|
-
}
|