@astryxdesign/cli 0.7.2-canary.64e1dde → 0.7.2-canary.6c792d8
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/README.md +62 -62
- package/api/component/_adapter.d.mts +31 -0
- package/api/component/_adapter.mjs +116 -0
- package/api/component/component.mjs +60 -10
- package/api/component/doc-links.test.mjs +386 -0
- package/api/discover/detail/doc/doc.mjs +9 -1
- package/api/docs/_adapter.d.mts +63 -0
- package/api/docs/_adapter.mjs +309 -16
- package/api/docs/integration-tree.test.mjs +22 -0
- package/api/docs/list/list.mjs +12 -2
- package/api/integration/_adapter.d.mts +23 -0
- package/api/integration/_adapter.mjs +45 -0
- package/api/integration/authoring-checks.mjs +87 -3
- package/api/integration/authoring-checks.test.mjs +443 -0
- package/api/integration/authoring-checks.type.d.mts +84 -0
- package/api/integration/authoring-checks.type.mjs +40 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +3 -1
- package/api/integration/integrationDocConflicts.doc.mjs +7 -2
- package/api/integration/pack-check.mjs +4 -0
- package/api/integration/pack-check.test.mjs +26 -0
- package/api/integration/validate-integration-fixes.test.mjs +67 -0
- package/api/integration/validate-integration.mjs +28 -3
- package/api/integration/validate-integration.test.mjs +77 -8
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/search.mjs +2 -1
- package/assets/docs/browser-support.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +2 -2
- package/assets/docs/tree/check-the-props.doc.mjs +5 -0
- package/assets/docs/tree/check-your-docs.doc.mjs +10 -2
- package/assets/docs/tree/checks.doc.mjs +4 -4
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +7 -7
- package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
- package/assets/docs/tree/publishing.doc.mjs +2 -2
- package/assets/docs/tree/sections-and-placement.doc.mjs +2 -2
- package/authoring/doctypes/component/type.ts +8 -0
- package/authoring/doctypes/hook/type.ts +4 -0
- package/clients/cli/commands/doctor-integration-components.doc.mjs +3 -2
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +3 -1
- package/clients/cli/commands/doctor-integration.test.mjs +48 -1
- package/clients/cli/commands/doctor.mjs +60 -5
- package/clients/cli/commands/integration-authoring.test.mjs +46 -0
- package/clients/cli/commands/integration-check.test.mjs +79 -0
- package/clients/cli/commands/integration.mjs +10 -4
- package/foundation/discovery/copied-passages.d.mts +8 -0
- package/foundation/discovery/copied-passages.mjs +2 -2
- package/foundation/discovery/doc-consistency.d.mts +34 -0
- package/foundation/discovery/doc-consistency.mjs +513 -0
- package/foundation/discovery/doc-consistency.test.mjs +347 -0
- package/foundation/discovery/doc-fluff.d.mts +112 -0
- package/foundation/discovery/doc-fluff.mjs +328 -0
- package/foundation/discovery/doc-fluff.test.mjs +142 -0
- package/foundation/discovery/doc-types.mjs +12 -5
- package/foundation/discovery/doc-types.test.mjs +46 -2
- package/foundation/discovery/prop-drift.d.mts +25 -6
- package/foundation/discovery/prop-drift.mjs +171 -6
- package/foundation/discovery/prop-drift.test.mjs +65 -0
- package/foundation/discovery/stray-pointers.d.mts +52 -0
- package/foundation/discovery/stray-pointers.mjs +293 -0
- package/foundation/discovery/stray-pointers.test.mjs +86 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +12 -0
- package/foundation/doc-compiler/links.d.mts +32 -0
- package/foundation/doc-compiler/links.mjs +163 -26
- package/foundation/doc-compiler/links.test.mjs +97 -4
- package/foundation/doc-compiler/tree.mjs +30 -1
- package/foundation/doc-compiler/tree.test.mjs +7 -0
- package/foundation/integrations/contribution-inventory.d.mts +11 -0
- package/foundation/integrations/contribution-inventory.mjs +50 -2
- package/foundation/integrations/issue.ts +6 -0
- package/foundation/integrations/validate-contributions.mjs +30 -1
- package/foundation/response/response-types.doc.mjs +4 -4
- package/package.json +9 -9
|
@@ -13,7 +13,7 @@ export const docs = {
|
|
|
13
13
|
title: 'Document the theme',
|
|
14
14
|
category: 'guide',
|
|
15
15
|
description:
|
|
16
|
-
'Document a theme by extending the core theme topic, so an app reads it in
|
|
16
|
+
'Document a theme by extending the core theme topic, so an app reads it in {@link generic:theme}.',
|
|
17
17
|
sections: [
|
|
18
18
|
{
|
|
19
19
|
id: 'extend-the-theme-topic',
|
|
@@ -21,7 +21,7 @@ export const docs = {
|
|
|
21
21
|
content: [
|
|
22
22
|
{
|
|
23
23
|
type: 'prose',
|
|
24
|
-
text: "Give your theme a doc topic that extends the core `theme` topic, so an app that lists your package sees your theme at the end of
|
|
24
|
+
text: "Give your theme a doc topic that extends the core `theme` topic, so an app that lists your package sees your theme at the end of {@link generic:theme}. Add it with `extends: 'theme'` ({@link generic:extend-or-replace}).",
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
type: 'code',
|
|
@@ -14,7 +14,7 @@ export const docs = {
|
|
|
14
14
|
category: 'guide',
|
|
15
15
|
keywords: ['publish an integration', 'npm publish', 'release'],
|
|
16
16
|
description:
|
|
17
|
-
'Publish your package to npm under the right release tag,
|
|
17
|
+
'Publish your package to npm under the right release tag, checking it before and after.',
|
|
18
18
|
sections: [
|
|
19
19
|
{
|
|
20
20
|
id: 'check-before-you-publish',
|
|
@@ -79,7 +79,7 @@ export const docs = {
|
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
81
|
type: 'prose',
|
|
82
|
-
text: 'To let apps try a release first, publish it under `next`, then point `latest` at it
|
|
82
|
+
text: 'To let apps try a release first, publish it under `next`, then point `latest` at it once ready.',
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
type: 'code',
|
|
@@ -95,8 +95,8 @@ export const docs = {
|
|
|
95
95
|
type: 'list',
|
|
96
96
|
style: 'unordered',
|
|
97
97
|
items: [
|
|
98
|
-
'A `parent`
|
|
99
|
-
'A `slot`
|
|
98
|
+
'A `parent` your package does not ship, such as `namespace:cli`, "names no namespace".',
|
|
99
|
+
'A `slot` the namespace does not declare "is not a slot of namespace"; the message lists the declared slots.',
|
|
100
100
|
'The check exits 1; see {@link generic:check-your-docs}.',
|
|
101
101
|
],
|
|
102
102
|
},
|
|
@@ -273,6 +273,14 @@ export interface ComponentRef {
|
|
|
273
273
|
* Used by both `docsZh` (Chinese translation) and `docsDense` (compressed format).
|
|
274
274
|
*/
|
|
275
275
|
export interface ComponentTranslationDoc {
|
|
276
|
+
/** Optional exact name from the base doc. Allowed so an overlay can say
|
|
277
|
+
* which component it translates; the overlay renders through the base
|
|
278
|
+
* doc, so this field is ignored at render time. */
|
|
279
|
+
name?: string;
|
|
280
|
+
/** Optional translated displayName. Allowed so the displayName backfill
|
|
281
|
+
* codemod (which adds `displayName` next to every `name:` field) does not
|
|
282
|
+
* break translation overlays. Ignored at render time. */
|
|
283
|
+
displayName?: string;
|
|
276
284
|
/** Compressed/translated component description. */
|
|
277
285
|
description?: string;
|
|
278
286
|
/** Prop descriptions keyed by prop name. Only include props that have descriptions. */
|
|
@@ -68,6 +68,10 @@ export interface HookDoc extends AuthoredDocGraphFields {
|
|
|
68
68
|
* Translation overlay for hook documentation.
|
|
69
69
|
*/
|
|
70
70
|
export interface HookTranslationDoc {
|
|
71
|
+
/** Optional exact name from the base doc. Ignored at render time. */
|
|
72
|
+
name?: string;
|
|
73
|
+
/** Optional translated displayName. Ignored at render time. */
|
|
74
|
+
displayName?: string;
|
|
71
75
|
/** Compressed/translated description. */
|
|
72
76
|
description?: string;
|
|
73
77
|
/** Param descriptions keyed by param name. */
|
|
@@ -27,7 +27,8 @@ export const doc = {
|
|
|
27
27
|
'`required`, and a type that does not match where both sides read exactly ' +
|
|
28
28
|
'(it lists every other documented type as not compared, with the reason). ' +
|
|
29
29
|
'Without TypeScript it prints one ' +
|
|
30
|
-
'line saying the comparison was skipped.'
|
|
30
|
+
'line saying the comparison was skipped. It also warns on each `{@link}` in ' +
|
|
31
|
+
"a component doc's text that names no doc.",
|
|
31
32
|
fn: 'integrationComponentConflicts',
|
|
32
33
|
args: [
|
|
33
34
|
{
|
|
@@ -51,7 +52,7 @@ export const doc = {
|
|
|
51
52
|
exitCodes: [
|
|
52
53
|
{
|
|
53
54
|
code: 0,
|
|
54
|
-
when: 'the check completed; component name conflicts, replaces findings for a package without the CLI range,
|
|
55
|
+
when: 'the check completed; component name conflicts, replaces findings for a package without the CLI range, props that differ from the code, and links that name no doc are warnings',
|
|
55
56
|
},
|
|
56
57
|
{
|
|
57
58
|
code: 1,
|
|
@@ -16,7 +16,9 @@ export const doc = {
|
|
|
16
16
|
'A same-name topic without `replaces` or `extends` is an accidental conflict ' +
|
|
17
17
|
'and fails until the author declares the relationship or renames it. ' +
|
|
18
18
|
'It also lists each pair of topics (two of the package, or one of them and a Core topic other than the one it replaces) ' +
|
|
19
|
-
'that repeat 10 or more words of prose word for word,
|
|
19
|
+
'that repeat 10 or more words of prose word for word, each padding phrase and low-density topic, ' +
|
|
20
|
+
'and each written `astryx docs <name>` that should be a link, ' +
|
|
21
|
+
'each as a warning (`copied_passage`, `doc_fluff`, `stray_doc_pointer`; exit 0, and `integration check --strict` fails on it). See {@link generic:check-your-docs}.',
|
|
20
22
|
fn: 'integrationDocConflicts',
|
|
21
23
|
args: [
|
|
22
24
|
{
|
|
@@ -210,6 +210,51 @@ describe('doctor integration — command', () => {
|
|
|
210
210
|
expect(process.exitCode).toBeUndefined();
|
|
211
211
|
});
|
|
212
212
|
|
|
213
|
+
it('validate prints the fix and the file an issue carries, and JSON carries the same issue', async () => {
|
|
214
|
+
writeDocIntegration({name: 'deploying'});
|
|
215
|
+
fs.writeFileSync(
|
|
216
|
+
path.join(tmpDir, 'docs', 'ghost.doc.zh.mjs'),
|
|
217
|
+
"export default {title: 'ghost'};\n",
|
|
218
|
+
);
|
|
219
|
+
process.chdir(tmpDir);
|
|
220
|
+
|
|
221
|
+
await createProgram().parseAsync([
|
|
222
|
+
'node',
|
|
223
|
+
'astryx',
|
|
224
|
+
'doctor',
|
|
225
|
+
'integration',
|
|
226
|
+
'validate',
|
|
227
|
+
]);
|
|
228
|
+
const output = logCalls.join('\n');
|
|
229
|
+
expect(output).toContain('orphan_doc_overlay');
|
|
230
|
+
expect(output).toMatch(
|
|
231
|
+
/fix:\s+Delete docs\/ghost\.doc\.zh\.mjs, or add the topic it translates/,
|
|
232
|
+
);
|
|
233
|
+
expect(output).toMatch(/file:\s+docs\/ghost\.doc\.zh\.mjs/);
|
|
234
|
+
expect(output).toMatch(/line:\s+1\b/);
|
|
235
|
+
|
|
236
|
+
logCalls = [];
|
|
237
|
+
await createProgram().parseAsync([
|
|
238
|
+
'node',
|
|
239
|
+
'astryx',
|
|
240
|
+
'--json',
|
|
241
|
+
'doctor',
|
|
242
|
+
'integration',
|
|
243
|
+
'validate',
|
|
244
|
+
]);
|
|
245
|
+
const parsed = JSON.parse(logCalls.join('\n'));
|
|
246
|
+
expect(parsed.data.issues).toEqual([
|
|
247
|
+
{
|
|
248
|
+
code: 'orphan_doc_overlay',
|
|
249
|
+
severity: 'warning',
|
|
250
|
+
message: expect.stringContaining('docs/ghost.doc.zh.mjs'),
|
|
251
|
+
fix: expect.stringContaining('Delete docs/ghost.doc.zh.mjs'),
|
|
252
|
+
file: 'docs/ghost.doc.zh.mjs',
|
|
253
|
+
line: 1,
|
|
254
|
+
},
|
|
255
|
+
]);
|
|
256
|
+
});
|
|
257
|
+
|
|
213
258
|
it('validate warns about each doc field that does not match its authoring type, and still exits 0', async () => {
|
|
214
259
|
writeIntegration({id: 'hero', name: 'Hero', type: 'block'});
|
|
215
260
|
process.chdir(tmpDir);
|
|
@@ -1060,12 +1105,13 @@ describe('doctor integration — command', () => {
|
|
|
1060
1105
|
"{name: 'elevation', type: 'number', description: 'Shadow.'}",
|
|
1061
1106
|
"{name: 'size', type: 'string', description: 'Size.'}",
|
|
1062
1107
|
"{name: 'meta', type: '{id: string; extra?: number}', description: 'Data.'}",
|
|
1108
|
+
"{name: 'gap', type: 'number', description: 'Gap.', default: '8'}",
|
|
1063
1109
|
].join(', ')}]};\n`,
|
|
1064
1110
|
);
|
|
1065
1111
|
// `key` is a prop a doc never needs, though the component declares it.
|
|
1066
1112
|
fs.writeFileSync(
|
|
1067
1113
|
path.join(tmpDir, 'components', 'AcmeBadge.tsx'),
|
|
1068
|
-
"export function AcmeBadge(
|
|
1114
|
+
"export function AcmeBadge({gap = 4}: {label: string; tone?: 'neutral' | 'info'; size?: number; meta?: {id: string}; gap?: number; key?: string}) { return null; }\n",
|
|
1069
1115
|
);
|
|
1070
1116
|
fs.writeFileSync(
|
|
1071
1117
|
path.join(tmpDir, 'components', 'AcmeLonely.doc.mjs'),
|
|
@@ -1094,6 +1140,7 @@ describe('doctor integration — command', () => {
|
|
|
1094
1140
|
|
|
1095
1141
|
expect(report.findings.map(f => `${f.prop} ${f.kind}`)).toEqual([
|
|
1096
1142
|
'elevation not_in_code',
|
|
1143
|
+
'gap default_mismatch',
|
|
1097
1144
|
'label required_mismatch',
|
|
1098
1145
|
'size type_mismatch',
|
|
1099
1146
|
'tone not_in_doc',
|
|
@@ -92,7 +92,7 @@ function issueBlocks(issues) {
|
|
|
92
92
|
return [
|
|
93
93
|
section('Integration issues'),
|
|
94
94
|
records(issues, {
|
|
95
|
-
fields: ['severity', 'code', 'message'],
|
|
95
|
+
fields: ['severity', 'code', 'message', 'fix', 'file', 'line'],
|
|
96
96
|
format: {severity: statusToken},
|
|
97
97
|
}),
|
|
98
98
|
];
|
|
@@ -189,7 +189,7 @@ function printIntegrationValidation(data) {
|
|
|
189
189
|
...(data.issues.length > 0
|
|
190
190
|
? [
|
|
191
191
|
records(data.issues, {
|
|
192
|
-
fields: ['severity', 'code', 'message'],
|
|
192
|
+
fields: ['severity', 'code', 'message', 'fix', 'file', 'line'],
|
|
193
193
|
format: {severity: statusToken},
|
|
194
194
|
}),
|
|
195
195
|
]
|
|
@@ -287,6 +287,9 @@ function propDriftBlocks(report, failed) {
|
|
|
287
287
|
'codeType',
|
|
288
288
|
'docRequired',
|
|
289
289
|
'codeRequired',
|
|
290
|
+
'docDefault',
|
|
291
|
+
'codeDefault',
|
|
292
|
+
'fix',
|
|
290
293
|
],
|
|
291
294
|
format: {severity: statusToken},
|
|
292
295
|
}),
|
|
@@ -390,10 +393,15 @@ function printDocConflicts(data) {
|
|
|
390
393
|
section(
|
|
391
394
|
`Checking integration docs: ${integrationLabel(data) ?? '(local package)'}`,
|
|
392
395
|
),
|
|
393
|
-
// A copied passage is listed below with its
|
|
394
|
-
// printed twice.
|
|
396
|
+
// A copied passage or fluff is listed below with its detail, so its
|
|
397
|
+
// issue is not printed twice.
|
|
395
398
|
...issueBlocks(
|
|
396
|
-
data.issues.filter(
|
|
399
|
+
data.issues.filter(
|
|
400
|
+
issue =>
|
|
401
|
+
issue.code !== 'copied_passage' &&
|
|
402
|
+
issue.code !== 'doc_fluff' &&
|
|
403
|
+
issue.code !== 'stray_doc_pointer',
|
|
404
|
+
),
|
|
397
405
|
),
|
|
398
406
|
];
|
|
399
407
|
if (
|
|
@@ -443,6 +451,53 @@ function printDocConflicts(data) {
|
|
|
443
451
|
}),
|
|
444
452
|
);
|
|
445
453
|
}
|
|
454
|
+
const fluff = data.fluff ?? [];
|
|
455
|
+
if (fluff.length === 0) {
|
|
456
|
+
if (!data.issues.some(issue => issue.severity === 'error')) {
|
|
457
|
+
output.push(text('[ok] No filler phrases or low-density topics.'));
|
|
458
|
+
}
|
|
459
|
+
} else {
|
|
460
|
+
output.push(
|
|
461
|
+
text(
|
|
462
|
+
`[warn] ${fluff.length} fluff finding(s) (doc_fluff): words that add length, not meaning. Cut each one.`,
|
|
463
|
+
),
|
|
464
|
+
records(fluff, {
|
|
465
|
+
fields: [
|
|
466
|
+
'topic',
|
|
467
|
+
'kind',
|
|
468
|
+
'phrase',
|
|
469
|
+
'section',
|
|
470
|
+
'file',
|
|
471
|
+
'line',
|
|
472
|
+
'density',
|
|
473
|
+
'message',
|
|
474
|
+
],
|
|
475
|
+
}),
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
const stray = data.strayPointers ?? [];
|
|
479
|
+
if (stray.length === 0) {
|
|
480
|
+
if (!data.issues.some(issue => issue.severity === 'error')) {
|
|
481
|
+
output.push(text('[ok] Every pointer to a doc is a link.'));
|
|
482
|
+
}
|
|
483
|
+
} else {
|
|
484
|
+
output.push(
|
|
485
|
+
text(
|
|
486
|
+
`[warn] ${stray.length} stray doc pointer(s) (stray_doc_pointer): a written \`astryx docs <name>\` where a link would be checked. Replace each with the link shown.`,
|
|
487
|
+
),
|
|
488
|
+
records(stray, {
|
|
489
|
+
fields: [
|
|
490
|
+
'topic',
|
|
491
|
+
'section',
|
|
492
|
+
'file',
|
|
493
|
+
'line',
|
|
494
|
+
'pointer',
|
|
495
|
+
'link',
|
|
496
|
+
'message',
|
|
497
|
+
],
|
|
498
|
+
}),
|
|
499
|
+
);
|
|
500
|
+
}
|
|
446
501
|
emit(...output);
|
|
447
502
|
}
|
|
448
503
|
|
|
@@ -147,6 +147,52 @@ describe('integration authoring CLI', () => {
|
|
|
147
147
|
);
|
|
148
148
|
});
|
|
149
149
|
|
|
150
|
+
it("verify carries each issue's fix, file, and line in JSON and prints them in text", async () => {
|
|
151
|
+
fs.writeFileSync(
|
|
152
|
+
path.join(tmpDir, 'package.json'),
|
|
153
|
+
`${JSON.stringify({
|
|
154
|
+
name: '@acme/widgets',
|
|
155
|
+
version: '1.0.0',
|
|
156
|
+
files: ['astryx.integration.mjs', 'docs'],
|
|
157
|
+
})}\n`,
|
|
158
|
+
);
|
|
159
|
+
fs.writeFileSync(
|
|
160
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
161
|
+
"export default {docs: './docs'};\n",
|
|
162
|
+
);
|
|
163
|
+
fs.mkdirSync(path.join(tmpDir, 'docs'));
|
|
164
|
+
fs.writeFileSync(
|
|
165
|
+
path.join(tmpDir, 'docs', 'deploying.doc.mjs'),
|
|
166
|
+
"export const docs = {type: 'generic', name: 'deploying', title: 'Deploying', description: 'How to deploy.', sections: [{title: 'Overview', content: [{type: 'prose', text: 'Ship it.'}]}]};\n",
|
|
167
|
+
);
|
|
168
|
+
fs.writeFileSync(
|
|
169
|
+
path.join(tmpDir, 'docs', 'ghost.doc.zh.mjs'),
|
|
170
|
+
"export default {title: 'ghost'};\n",
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const json = parseEnvelope(
|
|
174
|
+
(await runCli(['integration', 'verify', '--json'], tmpDir)).stdout,
|
|
175
|
+
);
|
|
176
|
+
const orphans = json.data.issues.filter(issue =>
|
|
177
|
+
issue.code.endsWith('orphan_doc_overlay'),
|
|
178
|
+
);
|
|
179
|
+
expect(orphans.map(issue => issue.code).sort()).toEqual([
|
|
180
|
+
'orphan_doc_overlay',
|
|
181
|
+
'packed_orphan_doc_overlay',
|
|
182
|
+
]);
|
|
183
|
+
for (const issue of orphans) {
|
|
184
|
+
expect(issue).toMatchObject({
|
|
185
|
+
file: 'docs/ghost.doc.zh.mjs',
|
|
186
|
+
line: 1,
|
|
187
|
+
fix: expect.stringContaining('Delete docs/ghost.doc.zh.mjs'),
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const text = (await runCli(['integration', 'verify'], tmpDir)).stdout;
|
|
192
|
+
expect(text).toContain('file: docs/ghost.doc.zh.mjs:1');
|
|
193
|
+
expect(text).toContain(`fix: ${orphans[0].fix}`);
|
|
194
|
+
});
|
|
195
|
+
|
|
150
196
|
it('keeps `integration pack --check` as a deprecated alias of `integration verify`', async () => {
|
|
151
197
|
// The old spelling runs the same check: the same JSON, the same exit code.
|
|
152
198
|
const verify = await runCli(['integration', 'verify', '--json'], tmpDir);
|
|
@@ -330,3 +330,82 @@ describe('a copied passage', () => {
|
|
|
330
330
|
expect(strict.stdout).toContain('copied_passage');
|
|
331
331
|
});
|
|
332
332
|
});
|
|
333
|
+
|
|
334
|
+
describe('a padding phrase', () => {
|
|
335
|
+
it('keeps doctor integration docs at exit 0, and fails integration check --strict', async () => {
|
|
336
|
+
fs.writeFileSync(
|
|
337
|
+
path.join(tmpDir, 'package.json'),
|
|
338
|
+
JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
|
|
339
|
+
);
|
|
340
|
+
fs.writeFileSync(
|
|
341
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
342
|
+
`export default {docs: './docs'};\n`,
|
|
343
|
+
);
|
|
344
|
+
fs.mkdirSync(path.join(tmpDir, 'docs'));
|
|
345
|
+
const doc = {
|
|
346
|
+
type: 'generic',
|
|
347
|
+
name: 'acme-setup',
|
|
348
|
+
title: 'Fixture',
|
|
349
|
+
description: 'Fixture topic.',
|
|
350
|
+
sections: [
|
|
351
|
+
{
|
|
352
|
+
title: 'Overview',
|
|
353
|
+
content: [{type: 'prose', text: 'In order to start, run the setup.'}],
|
|
354
|
+
},
|
|
355
|
+
],
|
|
356
|
+
};
|
|
357
|
+
fs.writeFileSync(
|
|
358
|
+
path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
|
|
359
|
+
`export default ${JSON.stringify(doc)};\n`,
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
const doctor = await runCli(['doctor', 'integration', 'docs'], tmpDir);
|
|
363
|
+
expect(doctor.status).toBe(0);
|
|
364
|
+
expect(doctor.stdout).toContain('1 fluff finding(s)');
|
|
365
|
+
|
|
366
|
+
const strict = await runCli(['integration', 'check', '--strict'], tmpDir);
|
|
367
|
+
expect(strict.status).toBe(1);
|
|
368
|
+
expect(strict.stdout).toContain('doc_fluff');
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
describe('a stray doc pointer', () => {
|
|
373
|
+
it('keeps doctor integration docs at exit 0, and fails integration check --strict', async () => {
|
|
374
|
+
fs.writeFileSync(
|
|
375
|
+
path.join(tmpDir, 'package.json'),
|
|
376
|
+
JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
|
|
377
|
+
);
|
|
378
|
+
fs.writeFileSync(
|
|
379
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
380
|
+
`export default {docs: './docs'};\n`,
|
|
381
|
+
);
|
|
382
|
+
fs.mkdirSync(path.join(tmpDir, 'docs'));
|
|
383
|
+
const doc = {
|
|
384
|
+
type: 'generic',
|
|
385
|
+
name: 'acme-setup',
|
|
386
|
+
title: 'Fixture',
|
|
387
|
+
description: 'Fixture topic.',
|
|
388
|
+
sections: [
|
|
389
|
+
{
|
|
390
|
+
title: 'Overview',
|
|
391
|
+
content: [
|
|
392
|
+
{type: 'prose', text: 'The theme is in `astryx docs theme`.'},
|
|
393
|
+
],
|
|
394
|
+
},
|
|
395
|
+
],
|
|
396
|
+
};
|
|
397
|
+
fs.writeFileSync(
|
|
398
|
+
path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
|
|
399
|
+
`export default ${JSON.stringify(doc)};\n`,
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
const doctor = await runCli(['doctor', 'integration', 'docs'], tmpDir);
|
|
403
|
+
expect(doctor.status).toBe(0);
|
|
404
|
+
expect(doctor.stdout).toContain('1 stray doc pointer(s)');
|
|
405
|
+
expect(doctor.stdout).toContain('{@link @astryxdesign/cli:generic:theme}');
|
|
406
|
+
|
|
407
|
+
const strict = await runCli(['integration', 'check', '--strict'], tmpDir);
|
|
408
|
+
expect(strict.status).toBe(1);
|
|
409
|
+
expect(strict.stdout).toContain('stray_doc_pointer');
|
|
410
|
+
});
|
|
411
|
+
});
|
|
@@ -79,10 +79,16 @@ async function verifyPackage(program) {
|
|
|
79
79
|
if (issues.length > 0) {
|
|
80
80
|
blocks.push(
|
|
81
81
|
list(
|
|
82
|
-
issues.map(
|
|
83
|
-
issue
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
issues.map(issue => [
|
|
83
|
+
`[${issue.severity === 'error' ? 'fail' : 'warn'}] ${issue.message}`,
|
|
84
|
+
// Every field the JSON issue carries.
|
|
85
|
+
...(issue.file != null
|
|
86
|
+
? [
|
|
87
|
+
`file: ${issue.file}${issue.line != null ? `:${issue.line}` : ''}`,
|
|
88
|
+
]
|
|
89
|
+
: []),
|
|
90
|
+
...(issue.fix != null ? [`fix: ${issue.fix}`] : []),
|
|
91
|
+
]),
|
|
86
92
|
),
|
|
87
93
|
);
|
|
88
94
|
}
|
|
@@ -149,6 +149,14 @@ export function sharedPassages(mine: {
|
|
|
149
149
|
start: number;
|
|
150
150
|
length: number;
|
|
151
151
|
}[];
|
|
152
|
+
/**
|
|
153
|
+
* @param {string} file
|
|
154
|
+
* @returns {Promise<any>} the doc, or null for one that does not load (the
|
|
155
|
+
* load problem is reported elsewhere)
|
|
156
|
+
*/
|
|
157
|
+
export function loadQuietly(file: string): Promise<any>;
|
|
158
|
+
/** @returns {Promise<IndexedGuides>} the CLI's own guides, read and indexed once */
|
|
159
|
+
export function loadCoreGuides(): Promise<IndexedGuides>;
|
|
152
160
|
/**
|
|
153
161
|
* One entry for each pair of topics that repeat a passage word for word: two
|
|
154
162
|
* of the package's own topics, or one of them and a Core topic, except the
|
|
@@ -424,7 +424,7 @@ let coreGuides = null;
|
|
|
424
424
|
* @returns {Promise<any>} the doc, or null for one that does not load (the
|
|
425
425
|
* load problem is reported elsewhere)
|
|
426
426
|
*/
|
|
427
|
-
async function loadQuietly(file) {
|
|
427
|
+
export async function loadQuietly(file) {
|
|
428
428
|
try {
|
|
429
429
|
return await loadTopicModule(file);
|
|
430
430
|
} catch {
|
|
@@ -433,7 +433,7 @@ async function loadQuietly(file) {
|
|
|
433
433
|
}
|
|
434
434
|
|
|
435
435
|
/** @returns {Promise<IndexedGuides>} the CLI's own guides, read and indexed once */
|
|
436
|
-
function loadCoreGuides() {
|
|
436
|
+
export function loadCoreGuides() {
|
|
437
437
|
coreGuides ??= (async () => {
|
|
438
438
|
/** @type {GuideWords[]} */
|
|
439
439
|
const guides = [];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Problems in one component doc module.
|
|
6
|
+
* @param {Record<string, any>} mod
|
|
7
|
+
* @param {string} file relative to the package
|
|
8
|
+
* @param {string} [text] the file's source, to locate each finding's line
|
|
9
|
+
* @returns {Issue[]}
|
|
10
|
+
*/
|
|
11
|
+
export function componentDocProblems(mod: Record<string, any>, file: string, text?: string): Issue[];
|
|
12
|
+
/**
|
|
13
|
+
* Problems in one topic doc.
|
|
14
|
+
* @param {any} doc
|
|
15
|
+
* @param {string} file relative to the package
|
|
16
|
+
* @param {string} [text] the file's source, to locate each finding's line
|
|
17
|
+
* @returns {Issue[]}
|
|
18
|
+
*/
|
|
19
|
+
export function topicDocProblems(doc: any, file: string, text?: string): Issue[];
|
|
20
|
+
/**
|
|
21
|
+
* Check an integration's component docs and topics.
|
|
22
|
+
* @param {{components?: string, docs?: string}} integration absolute roots
|
|
23
|
+
* @param {string} packageDir
|
|
24
|
+
* @returns {Promise<Issue[]>}
|
|
25
|
+
*/
|
|
26
|
+
export function integrationDocConsistency(integration: {
|
|
27
|
+
components?: string;
|
|
28
|
+
docs?: string;
|
|
29
|
+
}, packageDir: string): Promise<Issue[]>;
|
|
30
|
+
export type Issue = import("../integrations/issue").AstryxIntegrationIssue;
|
|
31
|
+
/**
|
|
32
|
+
* The codes this check raises.
|
|
33
|
+
*/
|
|
34
|
+
export type DocConsistencyProblem = "duplicate_prop" | "unknown_translated_prop" | "empty_section" | "duplicate_section_key" | "orphan_doc_overlay";
|