@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,147 +0,0 @@
|
|
|
1
|
-
import { hostedApiUrl, routeForReflection } from './api-doc-routes.mjs';
|
|
2
|
-
import { getPrimaryLocation, getRelevantComments } from './reflection-policy.mjs';
|
|
3
|
-
|
|
4
|
-
export const ISSUE_KIND = {
|
|
5
|
-
MISSING_DOCSTRING: 'missing-docstring',
|
|
6
|
-
MISSING_EXAMPLE: 'missing-example',
|
|
7
|
-
MISSING_API_LINK: 'missing-api-link',
|
|
8
|
-
INVALID_API_LINK: 'invalid-api-link',
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export function hasDocstring(reflection) {
|
|
12
|
-
return getRelevantComments(reflection).length > 0;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function hasExample(reflection) {
|
|
16
|
-
return getRelevantComments(reflection).some(({ comment }) =>
|
|
17
|
-
comment.getTags('@example').some((tag) => tag.content.some((part) => (part.text ?? '').trim().length > 0))
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function getApiLinkTargets(comment, apiBaseUrl) {
|
|
22
|
-
return comment
|
|
23
|
-
.getTags('@see')
|
|
24
|
-
.flatMap((tag) => tag.content)
|
|
25
|
-
.filter((part) => part.kind === 'inline-tag' && part.tag === '@link')
|
|
26
|
-
.map((part) => part.target)
|
|
27
|
-
.filter((target) => typeof target === 'string' && target.startsWith(`${apiBaseUrl}/`));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function getInvalidApiLinkTargets(comment, routes, apiBaseUrl) {
|
|
31
|
-
return getApiLinkTargets(comment, apiBaseUrl).filter((target) => {
|
|
32
|
-
const routeWithAnchor = target.slice(`${apiBaseUrl}/`.length);
|
|
33
|
-
if (!routeWithAnchor || routeWithAnchor === 'index') {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const [route] = routeWithAnchor.split('#');
|
|
38
|
-
return !routes.has(route);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function hasApiLink(comment, apiBaseUrl) {
|
|
43
|
-
return getApiLinkTargets(comment, apiBaseUrl).length > 0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function createApiLinkTargets(reflection, routes, apiBaseUrl) {
|
|
47
|
-
const route = routeForReflection(reflection, routes);
|
|
48
|
-
if (!route) {
|
|
49
|
-
return [];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const routeWithoutAnchor = route.split('#')[0];
|
|
53
|
-
if (!routes.has(routeWithoutAnchor)) {
|
|
54
|
-
return [];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const url = hostedApiUrl(apiBaseUrl, route);
|
|
58
|
-
const label = `${reflection.getFriendlyFullName()} API reference`;
|
|
59
|
-
const seeLine = `@see {@link ${url} | ${label}}`;
|
|
60
|
-
|
|
61
|
-
return getRelevantComments(reflection).map(({ source }) => ({
|
|
62
|
-
reflection,
|
|
63
|
-
source,
|
|
64
|
-
seeLine,
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function createIssue(reflection, kind) {
|
|
69
|
-
const location = getPrimaryLocation(reflection);
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
kind,
|
|
73
|
-
name: reflection.getFriendlyFullName(),
|
|
74
|
-
file: location.file,
|
|
75
|
-
line: location.line,
|
|
76
|
-
column: location.column,
|
|
77
|
-
location: location.printable,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function createCommentIssue(reflection, commentSource, kind, detail) {
|
|
82
|
-
const location = commentSource
|
|
83
|
-
? {
|
|
84
|
-
file: commentSource.fullFileName || getPrimaryLocation(reflection).file,
|
|
85
|
-
line: commentSource.line || 1,
|
|
86
|
-
column: (commentSource.character ?? 0) + 1,
|
|
87
|
-
}
|
|
88
|
-
: getPrimaryLocation(reflection);
|
|
89
|
-
|
|
90
|
-
return {
|
|
91
|
-
kind,
|
|
92
|
-
name: reflection.getFriendlyFullName(),
|
|
93
|
-
file: location.file,
|
|
94
|
-
line: location.line,
|
|
95
|
-
column: location.column,
|
|
96
|
-
location: `${location.file}:${location.line}:${location.column}`,
|
|
97
|
-
detail,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function collectApiDocIssues({
|
|
102
|
-
apiBaseUrl,
|
|
103
|
-
apiLinkReflections,
|
|
104
|
-
docstringReflections,
|
|
105
|
-
exampleReflections,
|
|
106
|
-
routes,
|
|
107
|
-
}) {
|
|
108
|
-
const missingDocstrings = docstringReflections
|
|
109
|
-
.filter((reflection) => !hasDocstring(reflection))
|
|
110
|
-
.map((reflection) => createIssue(reflection, ISSUE_KIND.MISSING_DOCSTRING))
|
|
111
|
-
.sort(compareIssues);
|
|
112
|
-
|
|
113
|
-
const missingExamples = exampleReflections
|
|
114
|
-
.filter((reflection) => hasDocstring(reflection) && !hasExample(reflection))
|
|
115
|
-
.map((reflection) => createIssue(reflection, ISSUE_KIND.MISSING_EXAMPLE))
|
|
116
|
-
.sort(compareIssues);
|
|
117
|
-
|
|
118
|
-
const comments = apiLinkReflections.flatMap((reflection) =>
|
|
119
|
-
getRelevantComments(reflection).map(({ comment, source }) => ({ reflection, comment, source }))
|
|
120
|
-
);
|
|
121
|
-
const missingApiLinks = comments
|
|
122
|
-
.filter(({ comment }) => !hasApiLink(comment, apiBaseUrl))
|
|
123
|
-
.map(({ reflection, source }) => createCommentIssue(reflection, source, ISSUE_KIND.MISSING_API_LINK))
|
|
124
|
-
.sort(compareIssues);
|
|
125
|
-
const invalidApiLinks = comments
|
|
126
|
-
.flatMap(({ reflection, comment, source }) =>
|
|
127
|
-
getInvalidApiLinkTargets(comment, routes, apiBaseUrl).map((target) =>
|
|
128
|
-
createCommentIssue(reflection, source, ISSUE_KIND.INVALID_API_LINK, target)
|
|
129
|
-
)
|
|
130
|
-
)
|
|
131
|
-
.sort(compareIssues);
|
|
132
|
-
|
|
133
|
-
return { missingDocstrings, missingExamples, missingApiLinks, invalidApiLinks };
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export function countApiDocIssues(issueGroups) {
|
|
137
|
-
return Object.values(issueGroups).reduce((total, issues) => total + issues.length, 0);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export function compareIssues(left, right) {
|
|
141
|
-
return (
|
|
142
|
-
left.file.localeCompare(right.file) ||
|
|
143
|
-
left.line - right.line ||
|
|
144
|
-
left.column - right.column ||
|
|
145
|
-
left.name.localeCompare(right.name)
|
|
146
|
-
);
|
|
147
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
|
|
4
|
-
import { ReflectionKind } from 'typedoc';
|
|
5
|
-
|
|
6
|
-
export const KIND_DIRECTORIES = new Map([
|
|
7
|
-
[ReflectionKind.Class, 'classes'],
|
|
8
|
-
[ReflectionKind.Interface, 'interfaces'],
|
|
9
|
-
[ReflectionKind.TypeAlias, 'type-aliases'],
|
|
10
|
-
[ReflectionKind.Enum, 'enumerations'],
|
|
11
|
-
[ReflectionKind.Variable, 'variables'],
|
|
12
|
-
[ReflectionKind.Function, 'functions'],
|
|
13
|
-
[ReflectionKind.Method, 'methods'],
|
|
14
|
-
[ReflectionKind.Accessor, 'accessors'],
|
|
15
|
-
[ReflectionKind.Property, 'properties'],
|
|
16
|
-
]);
|
|
17
|
-
|
|
18
|
-
export function readMarkdownRoutes(apiDocsDir) {
|
|
19
|
-
const routes = new Set();
|
|
20
|
-
|
|
21
|
-
function walk(dir) {
|
|
22
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
23
|
-
const fullPath = path.join(dir, entry.name);
|
|
24
|
-
if (entry.isDirectory()) {
|
|
25
|
-
walk(fullPath);
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!entry.name.endsWith('.md')) {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const relative = path.relative(apiDocsDir, fullPath).replaceAll(path.sep, '/');
|
|
34
|
-
const withoutExtension = relative.replace(/\.md$/, '');
|
|
35
|
-
const route = withoutExtension.endsWith('/index')
|
|
36
|
-
? withoutExtension.slice(0, -'/index'.length)
|
|
37
|
-
: withoutExtension;
|
|
38
|
-
routes.add(route);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
walk(apiDocsDir);
|
|
43
|
-
return routes;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function slugAnchor(name) {
|
|
47
|
-
return name
|
|
48
|
-
.toLowerCase()
|
|
49
|
-
.replace(/[^a-z0-9_-]+/g, '-')
|
|
50
|
-
.replace(/^-+|-+$/g, '');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function routeForReflection(reflection, routes) {
|
|
54
|
-
if (reflection.isProject()) {
|
|
55
|
-
return '';
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (reflection.kind === ReflectionKind.Namespace) {
|
|
59
|
-
const parentRoute =
|
|
60
|
-
reflection.parent && !reflection.parent.isProject() ? routeForReflection(reflection.parent, routes) : '';
|
|
61
|
-
return [parentRoute, 'namespaces', reflection.name].filter(Boolean).join('/');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
reflection.kind === ReflectionKind.Method ||
|
|
66
|
-
reflection.kind === ReflectionKind.Accessor ||
|
|
67
|
-
reflection.kind === ReflectionKind.Property
|
|
68
|
-
) {
|
|
69
|
-
const ownerRoute = routeForReflection(reflection.parent, routes);
|
|
70
|
-
const ownPageRoute = [ownerRoute, KIND_DIRECTORIES.get(reflection.kind), reflection.name]
|
|
71
|
-
.filter(Boolean)
|
|
72
|
-
.join('/');
|
|
73
|
-
|
|
74
|
-
if (routes.has(ownPageRoute)) {
|
|
75
|
-
return ownPageRoute;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return `${ownerRoute}#${slugAnchor(reflection.name)}`;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const directory = KIND_DIRECTORIES.get(reflection.kind);
|
|
82
|
-
if (!directory) {
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const parentRoute =
|
|
87
|
-
reflection.parent && !reflection.parent.isProject() ? routeForReflection(reflection.parent, routes) : '';
|
|
88
|
-
return [parentRoute, directory, reflection.name].filter(Boolean).join('/');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function hostedApiUrl(apiBaseUrl, route) {
|
|
92
|
-
return `${apiBaseUrl}/${route}`;
|
|
93
|
-
}
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import { checkSketchTitle } from './sketch-title.mjs';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
|
|
5
|
-
const INCLUDE_CODE_PATTERN = /\{@includeCode\s+([^}\s]+)[^}]*\}/g;
|
|
6
|
-
const MANIFEST_KEYS = new Set(['version', 'description', 'groups']);
|
|
7
|
-
const GROUP_KEYS = new Set(['name', 'description', 'examples', 'subgroups']);
|
|
8
|
-
const SUBGROUP_KEYS = new Set(['name', 'description', 'examples']);
|
|
9
|
-
const EXAMPLE_KEYS = new Set(['title', 'description', 'sourceFile', 'status']);
|
|
10
|
-
|
|
11
|
-
export const EXAMPLES_DIR = 'examples';
|
|
12
|
-
export const EXAMPLES_INDEX = path.join(EXAMPLES_DIR, 'index.html');
|
|
13
|
-
export const EXAMPLES_MANIFEST = path.join(EXAMPLES_DIR, 'manifest.json');
|
|
14
|
-
export const SOURCE_DIR = 'src';
|
|
15
|
-
|
|
16
|
-
export function isRecord(value) {
|
|
17
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function getUnknownKeys(value, allowedKeys) {
|
|
21
|
-
return Object.keys(value).filter((key) => !allowedKeys.has(key));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function toRepositoryPath(filePath, projectRoot) {
|
|
25
|
-
return path.relative(projectRoot, filePath).split(path.sep).join('/');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function getTypeScriptFiles(directory) {
|
|
29
|
-
const files = [];
|
|
30
|
-
|
|
31
|
-
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
32
|
-
const entryPath = path.join(directory, entry.name);
|
|
33
|
-
|
|
34
|
-
if (entry.isDirectory()) {
|
|
35
|
-
files.push(...getTypeScriptFiles(entryPath));
|
|
36
|
-
} else if (entry.isFile() && entry.name.endsWith('.ts')) {
|
|
37
|
-
files.push(entryPath);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return files;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function readExamplesManifest(manifestPath = EXAMPLES_MANIFEST) {
|
|
45
|
-
return JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function readExamplesIndex(indexPath = EXAMPLES_INDEX) {
|
|
49
|
-
return fs.readFileSync(indexPath, 'utf8');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function getManifestExamples(manifest) {
|
|
53
|
-
return manifest.groups.flatMap((group) => {
|
|
54
|
-
if (Array.isArray(group.subgroups)) {
|
|
55
|
-
return group.subgroups.flatMap((sg) =>
|
|
56
|
-
Array.isArray(sg.examples)
|
|
57
|
-
? sg.examples.filter(isRecord).map((example) => ({
|
|
58
|
-
...example,
|
|
59
|
-
groupName: group.name,
|
|
60
|
-
groupDescription: group.description,
|
|
61
|
-
subgroupName: sg.name,
|
|
62
|
-
}))
|
|
63
|
-
: []
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return Array.isArray(group.examples)
|
|
68
|
-
? group.examples.filter(isRecord).map((example) => ({
|
|
69
|
-
...example,
|
|
70
|
-
groupName: group.name,
|
|
71
|
-
groupDescription: group.description,
|
|
72
|
-
}))
|
|
73
|
-
: [];
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function getTypeDocExampleIncludes(
|
|
78
|
-
sourceDir,
|
|
79
|
-
examplesDir = EXAMPLES_DIR,
|
|
80
|
-
projectRoot = path.dirname(sourceDir)
|
|
81
|
-
) {
|
|
82
|
-
const includes = [];
|
|
83
|
-
|
|
84
|
-
for (const file of getTypeScriptFiles(sourceDir)) {
|
|
85
|
-
const content = fs.readFileSync(file, 'utf8');
|
|
86
|
-
let match;
|
|
87
|
-
|
|
88
|
-
INCLUDE_CODE_PATTERN.lastIndex = 0;
|
|
89
|
-
while ((match = INCLUDE_CODE_PATTERN.exec(content)) !== null) {
|
|
90
|
-
const includeTarget = match[1];
|
|
91
|
-
const resolvedPath = path.resolve(path.dirname(file), includeTarget);
|
|
92
|
-
const sourceFile = toRepositoryPath(resolvedPath, projectRoot);
|
|
93
|
-
|
|
94
|
-
if (sourceFile.startsWith(`${examplesDir}/`)) {
|
|
95
|
-
includes.push({
|
|
96
|
-
file: toRepositoryPath(file, projectRoot),
|
|
97
|
-
includeTarget,
|
|
98
|
-
sourceFile,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return includes;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function validateExamplesGallery(
|
|
108
|
-
indexContent,
|
|
109
|
-
{ examplesIndex = EXAMPLES_INDEX, examplesManifest = EXAMPLES_MANIFEST, forbidGallerySourceBase = true } = {}
|
|
110
|
-
) {
|
|
111
|
-
const issues = [];
|
|
112
|
-
|
|
113
|
-
if (/const\s+GROUPS\s*=/.test(indexContent)) {
|
|
114
|
-
issues.push(`${examplesIndex} must not declare \`const GROUPS\`; ${examplesManifest} is authoritative.`);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (!indexContent.includes('manifest.json')) {
|
|
118
|
-
issues.push(`${examplesIndex} must load ${examplesManifest}.`);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (forbidGallerySourceBase && /data-source-base\s*=/.test(indexContent)) {
|
|
122
|
-
issues.push(
|
|
123
|
-
`${examplesIndex} must not hardcode a source base; preview links should resolve from example paths.`
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return issues;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function validateExamplesManifest(manifest, options = {}) {
|
|
131
|
-
if (typeof options.projectRoot !== 'string' || options.projectRoot.length === 0) {
|
|
132
|
-
throw new Error('validateExamplesManifest requires projectRoot.');
|
|
133
|
-
}
|
|
134
|
-
const projectRoot = options.projectRoot;
|
|
135
|
-
const examplesDir = options.examplesDir ?? EXAMPLES_DIR;
|
|
136
|
-
const examplesManifest = options.examplesManifest ?? EXAMPLES_MANIFEST;
|
|
137
|
-
const sourceDir = options.sourceDir ?? path.resolve(projectRoot, SOURCE_DIR);
|
|
138
|
-
const issues = [];
|
|
139
|
-
|
|
140
|
-
if (!isRecord(manifest)) {
|
|
141
|
-
return ['Manifest root must be an object.'];
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
for (const key of getUnknownKeys(manifest, MANIFEST_KEYS)) {
|
|
145
|
-
issues.push(`Manifest contains unknown top-level key: ${key}`);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (manifest.version !== 1) {
|
|
149
|
-
issues.push('Manifest `version` must be `1`.');
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (typeof manifest.description !== 'string' || manifest.description.length === 0) {
|
|
153
|
-
issues.push('Manifest `description` must be a non-empty string.');
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (!Array.isArray(manifest.groups)) {
|
|
157
|
-
return ['Manifest `groups` must be an array.'];
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
for (const [groupIndex, group] of manifest.groups.entries()) {
|
|
161
|
-
if (!isRecord(group)) {
|
|
162
|
-
issues.push(`Manifest group ${groupIndex + 1} must be an object.`);
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
for (const key of getUnknownKeys(group, GROUP_KEYS)) {
|
|
167
|
-
issues.push(`Manifest group "${group.name ?? groupIndex + 1}" contains unknown key: ${key}`);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (typeof group.name !== 'string' || group.name.length === 0) {
|
|
171
|
-
issues.push(`Manifest group ${groupIndex + 1} is missing a name.`);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (typeof group.description !== 'string' || group.description.length === 0) {
|
|
175
|
-
issues.push(`Manifest group "${group.name ?? groupIndex + 1}" is missing a description.`);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const hasExamples = Array.isArray(group.examples);
|
|
179
|
-
const hasSubgroups = Array.isArray(group.subgroups);
|
|
180
|
-
|
|
181
|
-
if (hasExamples && hasSubgroups) {
|
|
182
|
-
issues.push(
|
|
183
|
-
`Manifest group "${group.name}" must not have both \`examples\` and \`subgroups\`. Use one or the other.`
|
|
184
|
-
);
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (!hasExamples && !hasSubgroups) {
|
|
189
|
-
issues.push(
|
|
190
|
-
`Manifest group "${group.name}" must have either an \`examples\` array or a \`subgroups\` array.`
|
|
191
|
-
);
|
|
192
|
-
continue;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (hasSubgroups) {
|
|
196
|
-
for (const [sgIndex, sg] of group.subgroups.entries()) {
|
|
197
|
-
if (!isRecord(sg)) {
|
|
198
|
-
issues.push(`Manifest subgroup ${sgIndex + 1} in group "${group.name}" must be an object.`);
|
|
199
|
-
continue;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
for (const key of getUnknownKeys(sg, SUBGROUP_KEYS)) {
|
|
203
|
-
issues.push(
|
|
204
|
-
`Manifest subgroup "${sg.name ?? sgIndex + 1}" in group "${group.name}" contains unknown key: ${key}`
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (typeof sg.name !== 'string' || sg.name.length === 0) {
|
|
209
|
-
issues.push(`Manifest subgroup ${sgIndex + 1} in group "${group.name}" is missing a name.`);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (!Array.isArray(sg.examples)) {
|
|
213
|
-
issues.push(
|
|
214
|
-
`Manifest subgroup "${sg.name ?? sgIndex + 1}" in group "${group.name}" examples must be an array.`
|
|
215
|
-
);
|
|
216
|
-
continue;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
for (const [exampleIndex, example] of sg.examples.entries()) {
|
|
220
|
-
if (!isRecord(example)) {
|
|
221
|
-
issues.push(
|
|
222
|
-
`Manifest example ${exampleIndex + 1} in subgroup "${sg.name}" of group "${group.name}" must be an object.`
|
|
223
|
-
);
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
for (const key of getUnknownKeys(example, EXAMPLE_KEYS)) {
|
|
228
|
-
issues.push(
|
|
229
|
-
`Manifest example "${example.sourceFile ?? `${group.name}.${sg.name}.${exampleIndex + 1}`}" contains unknown key: ${key}`
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
} else {
|
|
235
|
-
for (const [exampleIndex, example] of group.examples.entries()) {
|
|
236
|
-
if (!isRecord(example)) {
|
|
237
|
-
issues.push(`Manifest example ${exampleIndex + 1} in group "${group.name}" must be an object.`);
|
|
238
|
-
continue;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
for (const key of getUnknownKeys(example, EXAMPLE_KEYS)) {
|
|
242
|
-
issues.push(
|
|
243
|
-
`Manifest example "${example.sourceFile ?? `${group.name}.${exampleIndex + 1}`}" contains unknown key: ${key}`
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const manifestExamples = getManifestExamples(manifest);
|
|
251
|
-
const manifestFiles = manifestExamples.map((example) => example.sourceFile);
|
|
252
|
-
|
|
253
|
-
if (manifestFiles.length === 0) {
|
|
254
|
-
issues.push('Manifest must include at least one example.');
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const seen = new Set();
|
|
258
|
-
for (const example of manifestExamples) {
|
|
259
|
-
if (typeof example.sourceFile !== 'string') {
|
|
260
|
-
issues.push('Manifest examples must include a string sourceFile.');
|
|
261
|
-
continue;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (seen.has(example.sourceFile)) {
|
|
265
|
-
issues.push(`Manifest contains duplicate source file: ${example.sourceFile}`);
|
|
266
|
-
}
|
|
267
|
-
seen.add(example.sourceFile);
|
|
268
|
-
|
|
269
|
-
if (typeof example.title !== 'string' || example.title.length === 0) {
|
|
270
|
-
issues.push(`Manifest example "${example.sourceFile}" is missing a title.`);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
if (
|
|
274
|
-
example.status !== undefined &&
|
|
275
|
-
example.status !== 'good' &&
|
|
276
|
-
example.status !== 'bad' &&
|
|
277
|
-
example.status !== 'unrated'
|
|
278
|
-
) {
|
|
279
|
-
issues.push(
|
|
280
|
-
`Manifest example "${example.sourceFile}" status must be "good", "bad", or "unrated", but found "${example.status}".`
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
if (!example.sourceFile.startsWith(`${examplesDir}/`) || !example.sourceFile.endsWith('/sketch.js')) {
|
|
285
|
-
issues.push(`Manifest example "${example.sourceFile}" sourceFile must be an examples/**/sketch.js path.`);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
const sketchPath = path.resolve(projectRoot, example.sourceFile);
|
|
289
|
-
if (!fs.existsSync(sketchPath)) {
|
|
290
|
-
issues.push(`Manifest example is missing its sketch file: ${example.sourceFile}`);
|
|
291
|
-
continue;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
const titleCheck = checkSketchTitle(fs.readFileSync(sketchPath, 'utf8'), example.title);
|
|
295
|
-
|
|
296
|
-
if (titleCheck.kind === 'missing') {
|
|
297
|
-
issues.push(`Manifest example "${example.sourceFile}" sketch is missing an @title tag.`);
|
|
298
|
-
} else if (titleCheck.kind === 'mismatch') {
|
|
299
|
-
issues.push(
|
|
300
|
-
`Manifest example "${example.sourceFile}" title "${example.title}" must match sketch @title "${titleCheck.actual}".`
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
const manifestFileSet = new Set(manifestFiles);
|
|
306
|
-
for (const include of getTypeDocExampleIncludes(sourceDir, examplesDir, projectRoot)) {
|
|
307
|
-
if (!manifestFileSet.has(include.sourceFile)) {
|
|
308
|
-
issues.push(
|
|
309
|
-
`TypeDoc includeCode in "${include.file}" references "${include.includeTarget}" (${include.sourceFile}), but that sketch is not in ${examplesManifest}.`
|
|
310
|
-
);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
return issues;
|
|
315
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
export function getLineStartOffsets(text) {
|
|
2
|
-
const offsets = [0];
|
|
3
|
-
for (let index = 0; index < text.length; index += 1) {
|
|
4
|
-
if (text[index] === '\n') {
|
|
5
|
-
offsets.push(index + 1);
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
return offsets;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function findJsdocBeforeLine(text, lineStarts, line) {
|
|
12
|
-
const declarationOffset = lineStarts[line - 1] ?? text.length;
|
|
13
|
-
const searchText = text.slice(0, declarationOffset);
|
|
14
|
-
const start = searchText.lastIndexOf('/**');
|
|
15
|
-
const end = searchText.lastIndexOf('*/');
|
|
16
|
-
|
|
17
|
-
if (start === -1 || end === -1 || start > end) {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return { start, end };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function replaceHostedApiSeeLines(commentText, seeLine, apiBaseUrl) {
|
|
25
|
-
const lines = commentText.split('\n');
|
|
26
|
-
let replaced = false;
|
|
27
|
-
const nextLines = [];
|
|
28
|
-
|
|
29
|
-
for (const line of lines) {
|
|
30
|
-
if (line.includes('@see') && line.includes(apiBaseUrl)) {
|
|
31
|
-
if (!replaced) {
|
|
32
|
-
nextLines.push(line.replace(/^(\s*\*\s*).*$/, `$1${seeLine}`));
|
|
33
|
-
replaced = true;
|
|
34
|
-
}
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
nextLines.push(line);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return replaced ? nextLines.join('\n') : undefined;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function upsertSeeLine(text, comment, seeLine, apiBaseUrl) {
|
|
45
|
-
const commentText = text.slice(comment.start, comment.end + 2);
|
|
46
|
-
const replacedComment = replaceHostedApiSeeLines(commentText, seeLine, apiBaseUrl);
|
|
47
|
-
if (replacedComment !== undefined) {
|
|
48
|
-
return `${text.slice(0, comment.start)}${replacedComment}${text.slice(comment.end + 2)}`;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!commentText.includes('\n')) {
|
|
52
|
-
const lineStart = text.lastIndexOf('\n', comment.start) + 1;
|
|
53
|
-
const indent = text.slice(lineStart, comment.start);
|
|
54
|
-
const summary = commentText
|
|
55
|
-
.replace(/^\/\*\*\s?/, '')
|
|
56
|
-
.replace(/\s?\*\/$/, '')
|
|
57
|
-
.trim();
|
|
58
|
-
const replacement = [
|
|
59
|
-
`${indent}/**`,
|
|
60
|
-
summary ? `${indent} * ${summary}` : undefined,
|
|
61
|
-
`${indent} *`,
|
|
62
|
-
`${indent} * ${seeLine}`,
|
|
63
|
-
`${indent} */`,
|
|
64
|
-
]
|
|
65
|
-
.filter(Boolean)
|
|
66
|
-
.join('\n');
|
|
67
|
-
|
|
68
|
-
return `${text.slice(0, lineStart)}${replacement}${text.slice(comment.end + 2)}`;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const lineStart = text.lastIndexOf('\n', comment.end) + 1;
|
|
72
|
-
const closingLine = text.slice(lineStart, comment.end + 2);
|
|
73
|
-
const prefixMatch = closingLine.match(/^(\s*)\*\//);
|
|
74
|
-
const indent = prefixMatch?.[1] ?? '';
|
|
75
|
-
const insertion = `${indent}*\n${indent}* ${seeLine}\n`;
|
|
76
|
-
|
|
77
|
-
return `${text.slice(0, lineStart)}${insertion}${text.slice(lineStart)}`;
|
|
78
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const LABEL_SCHEMA = Object.freeze({
|
|
2
|
-
rowLimit: 40,
|
|
3
|
-
dividerLength: 36,
|
|
4
|
-
panelColor: '6,10,22',
|
|
5
|
-
palette: Object.freeze({
|
|
6
|
-
'120,240,180': 'title color',
|
|
7
|
-
'70,100,140': 'divider color',
|
|
8
|
-
'140,210,255': 'concept color',
|
|
9
|
-
'140,160,190': 'explanation color',
|
|
10
|
-
'140,255,200': 'live value color',
|
|
11
|
-
'255,200,80': 'interaction color',
|
|
12
|
-
}),
|
|
13
|
-
});
|