@astryxdesign/cli 0.7.2-canary.6a3ff0f → 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/_adapter.d.mts +119 -12
- package/api/discover/_adapter.mjs +449 -10
- package/api/discover/_adapter.test.mjs +599 -17
- package/api/discover/_catalog-view.d.mts +16 -5
- package/api/discover/_catalog-view.mjs +32 -8
- package/api/discover/detail/doc/doc.mjs +9 -1
- package/api/discover/discover.d.mts +11 -0
- package/api/discover/discover.doc.mjs +7 -6
- package/api/discover/discover.mjs +107 -19
- package/api/discover/discover.type.d.mts +18 -7
- package/api/discover/discover.type.mjs +15 -7
- package/api/discover/list/list.d.mts +4 -3
- package/api/discover/list/list.mjs +17 -10
- 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/doctor/theme-checks.test.mjs +136 -0
- package/api/integration/_adapter.d.mts +33 -0
- package/api/integration/_adapter.mjs +58 -0
- package/api/integration/authoring-checks.mjs +98 -3
- package/api/integration/authoring-checks.test.mjs +769 -0
- package/api/integration/authoring-checks.type.d.mts +134 -0
- package/api/integration/authoring-checks.type.mjs +60 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +3 -1
- package/api/integration/integrationDocConflicts.doc.mjs +22 -5
- package/api/integration/pack-check.mjs +296 -7
- package/api/integration/pack-check.test.mjs +367 -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/discover/official-packages.json +367 -0
- package/assets/docs/author-a-theme.doc.mjs +2 -2
- package/assets/docs/browser-support.doc.mjs +1 -1
- package/assets/docs/styling-overview.doc.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +3 -3
- package/assets/docs/tree/check-the-props.doc.mjs +7 -2
- package/assets/docs/tree/check-your-docs.doc.mjs +15 -3
- package/assets/docs/tree/checks.doc.mjs +5 -5
- 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/layout-spacing.doc.mjs +2 -3
- package/assets/docs/tree/layout.doc.mjs +6 -6
- package/assets/docs/tree/migration-setup.doc.mjs +2 -2
- package/assets/docs/tree/publishing.doc.mjs +3 -3
- package/assets/docs/tree/quick-start.doc.mjs +2 -2
- package/assets/docs/tree/sections-and-placement.doc.mjs +2 -2
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/troubleshooting.doc.mjs +5 -5
- package/assets/docs/tree/upgrading.doc.mjs +1 -1
- package/authoring/discover/discover.doc.mjs +1 -1
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -0
- package/authoring/doctypes/hook/type.ts +4 -0
- package/clients/cli/commands/discover.broken-integration.test.mjs +4 -1
- package/clients/cli/commands/discover.doc.mjs +1 -1
- package/clients/cli/commands/discover.mjs +144 -93
- package/clients/cli/commands/discover.no-source.test.mjs +447 -33
- package/clients/cli/commands/discover.sources.test.mjs +20 -1
- package/clients/cli/commands/doctor-integration-components.doc.mjs +3 -2
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +19 -5
- package/clients/cli/commands/doctor-integration.test.mjs +48 -1
- package/clients/cli/commands/doctor.mjs +91 -5
- package/clients/cli/commands/integration-authoring.test.mjs +46 -0
- package/clients/cli/commands/integration-check.test.mjs +127 -0
- package/clients/cli/commands/integration.mjs +10 -4
- package/clients/cli/commands/json-contract.test.mjs +5 -1
- package/foundation/discovery/copied-passages.d.mts +216 -0
- package/foundation/discovery/copied-passages.mjs +720 -0
- package/foundation/discovery/copied-passages.test.mjs +124 -0
- 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/docs-discovery.d.mts +7 -0
- package/foundation/discovery/docs-discovery.mjs +26 -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 +16 -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/fs/module-loader.d.mts +2 -1
- package/foundation/fs/module-loader.mjs +60 -4
- package/foundation/fs/module-loader.test.mjs +194 -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 +5 -5
- package/package.json +11 -11
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
installedComponentPackageVersion,
|
|
33
33
|
resolveComponentReplacement,
|
|
34
34
|
unscopedComponentOwners,
|
|
35
|
+
linkComponentResponse,
|
|
35
36
|
} from './_adapter.mjs';
|
|
36
37
|
import {componentList} from './list/list.mjs';
|
|
37
38
|
import {componentDetail} from './detail/detail.mjs';
|
|
@@ -257,6 +258,23 @@ async function componentBatch(selectors, options, coreDir) {
|
|
|
257
258
|
* )>}
|
|
258
259
|
*/
|
|
259
260
|
export async function component(name, options = {}) {
|
|
261
|
+
// Every read resolves the links in the doc text it returns (spec:AST-047
|
|
262
|
+
// FR9); a batch's results are each a read of their own.
|
|
263
|
+
return /** @type {any} */ (
|
|
264
|
+
await linkComponentResponse(
|
|
265
|
+
await componentRead(name, options),
|
|
266
|
+
options.cwd ?? process.cwd(),
|
|
267
|
+
)
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* {@link component}, with each `{@link}` in its doc text as written.
|
|
273
|
+
* @param {string|string[]} [name]
|
|
274
|
+
* @param {Parameters<typeof component>[1]} [options]
|
|
275
|
+
* @returns {ReturnType<typeof component>}
|
|
276
|
+
*/
|
|
277
|
+
async function componentRead(name, options = {}) {
|
|
260
278
|
const {
|
|
261
279
|
cwd = process.cwd(),
|
|
262
280
|
list = false,
|
|
@@ -357,7 +375,7 @@ export async function component(name, options = {}) {
|
|
|
357
375
|
requireInstalledSelectorVersion(target, coreDir, loadedIntegrations);
|
|
358
376
|
}
|
|
359
377
|
if (target.name !== name || target.package !== packageScope) {
|
|
360
|
-
return
|
|
378
|
+
return componentRead(target.name, {...options, package: target.package});
|
|
361
379
|
}
|
|
362
380
|
name = target.name;
|
|
363
381
|
}
|
|
@@ -396,7 +414,10 @@ export async function component(name, options = {}) {
|
|
|
396
414
|
dirName,
|
|
397
415
|
);
|
|
398
416
|
if (replacement?.package === packageScope) {
|
|
399
|
-
return
|
|
417
|
+
return componentRead(replacement.name, {
|
|
418
|
+
...options,
|
|
419
|
+
package: packageScope,
|
|
420
|
+
});
|
|
400
421
|
}
|
|
401
422
|
}
|
|
402
423
|
const scoped = classifyScope(packageScope, {
|
|
@@ -424,8 +445,17 @@ export async function component(name, options = {}) {
|
|
|
424
445
|
// a showcase, so skip discovery entirely.
|
|
425
446
|
if (showcase) {
|
|
426
447
|
return scoped.kind === 'core'
|
|
427
|
-
? componentDetailShowcase(dirName, {
|
|
428
|
-
|
|
448
|
+
? componentDetailShowcase(dirName, {
|
|
449
|
+
cwd,
|
|
450
|
+
name,
|
|
451
|
+
ownerPackage: owner.package,
|
|
452
|
+
})
|
|
453
|
+
: componentDetailShowcase(dirName, {
|
|
454
|
+
cwd,
|
|
455
|
+
name,
|
|
456
|
+
resolve: false,
|
|
457
|
+
ownerPackage: owner.package,
|
|
458
|
+
});
|
|
429
459
|
}
|
|
430
460
|
if (blocks) {
|
|
431
461
|
return componentDetailBlocks(dirName, cwd, owner.package);
|
|
@@ -443,7 +473,12 @@ export async function component(name, options = {}) {
|
|
|
443
473
|
|
|
444
474
|
// Legacy `pkg.astryx.docs` external package.
|
|
445
475
|
if (showcase) {
|
|
446
|
-
return componentDetailShowcase(dirName, {
|
|
476
|
+
return componentDetailShowcase(dirName, {
|
|
477
|
+
cwd,
|
|
478
|
+
name,
|
|
479
|
+
packageScope,
|
|
480
|
+
ownerPackage: packageScope,
|
|
481
|
+
});
|
|
447
482
|
}
|
|
448
483
|
const extDocPath = resolveLegacyExternalDoc(scoped.ext, dirName);
|
|
449
484
|
if (extDocPath) {
|
|
@@ -484,7 +519,7 @@ export async function component(name, options = {}) {
|
|
|
484
519
|
dirName,
|
|
485
520
|
);
|
|
486
521
|
if (replacement) {
|
|
487
|
-
return
|
|
522
|
+
return componentRead(replacement.name, {
|
|
488
523
|
...options,
|
|
489
524
|
package: replacement.package,
|
|
490
525
|
});
|
|
@@ -526,11 +561,19 @@ export async function component(name, options = {}) {
|
|
|
526
561
|
) {
|
|
527
562
|
const owner = effectiveOwners[0];
|
|
528
563
|
if (source) {
|
|
529
|
-
return componentDetailSource(dirName, owner.sourcePath, {
|
|
564
|
+
return componentDetailSource(dirName, owner.sourcePath, {
|
|
565
|
+
name,
|
|
566
|
+
ownerPackage: owner.package,
|
|
567
|
+
});
|
|
530
568
|
}
|
|
531
569
|
if (showcase) {
|
|
532
570
|
// Integration components don't carry showcases — fail without scanning.
|
|
533
|
-
return componentDetailShowcase(dirName, {
|
|
571
|
+
return componentDetailShowcase(dirName, {
|
|
572
|
+
cwd,
|
|
573
|
+
name,
|
|
574
|
+
resolve: false,
|
|
575
|
+
ownerPackage: owner.package,
|
|
576
|
+
});
|
|
534
577
|
}
|
|
535
578
|
const loaded = await loadComponentDoc(owner.docPath, docOpts);
|
|
536
579
|
const docs = scopeIntegrationMember(loaded, owner, dirName);
|
|
@@ -548,7 +591,11 @@ export async function component(name, options = {}) {
|
|
|
548
591
|
);
|
|
549
592
|
}
|
|
550
593
|
if (showcase) {
|
|
551
|
-
return componentDetailShowcase(dirName, {
|
|
594
|
+
return componentDetailShowcase(dirName, {
|
|
595
|
+
cwd,
|
|
596
|
+
name,
|
|
597
|
+
ownerPackage: CORE_PACKAGE,
|
|
598
|
+
});
|
|
552
599
|
}
|
|
553
600
|
|
|
554
601
|
const resolved = await resolveUnscopedDoc(dirName, {coreDir, cwd, name});
|
|
@@ -565,7 +612,10 @@ export async function component(name, options = {}) {
|
|
|
565
612
|
const sub = scopeSubComponent(docs, dirName, coreDir);
|
|
566
613
|
if (sub) {
|
|
567
614
|
if (props)
|
|
568
|
-
return componentDetailProps(
|
|
615
|
+
return componentDetailProps(
|
|
616
|
+
{props: sub.matchingComponent.props},
|
|
617
|
+
resolved.resolvedOwnerPackage,
|
|
618
|
+
);
|
|
569
619
|
return componentDetail(
|
|
570
620
|
sub.scoped,
|
|
571
621
|
{
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Links in a component doc's text and a topic's description
|
|
5
|
+
* (spec:AST-047 FR9): a read resolves each `{@link <target>}` to the command
|
|
6
|
+
* that opens its doc, in text and JSON, the way a topic section's links read.
|
|
7
|
+
* Code fields and code ticks show the syntax as written.
|
|
8
|
+
*
|
|
9
|
+
* Fixtures live under a repo-local temp dir, not /tmp, because Vite refuses to
|
|
10
|
+
* dynamically import a module from outside the project root.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import * as fs from 'node:fs';
|
|
14
|
+
import * as path from 'node:path';
|
|
15
|
+
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
16
|
+
import {component} from './component.mjs';
|
|
17
|
+
import {CORE_PACKAGE, linkComponentResponse} from './_adapter.mjs';
|
|
18
|
+
import {docs} from '../docs/docs.mjs';
|
|
19
|
+
import {search} from '../search/search.mjs';
|
|
20
|
+
import {runCli} from '../../test-utils/run-cli.mjs';
|
|
21
|
+
|
|
22
|
+
const SLOW = 60_000;
|
|
23
|
+
|
|
24
|
+
let tmpDir;
|
|
25
|
+
|
|
26
|
+
const ACME_BUTTON = {
|
|
27
|
+
type: 'component',
|
|
28
|
+
name: 'AcmeButton',
|
|
29
|
+
displayName: 'Acme Button',
|
|
30
|
+
usage: {
|
|
31
|
+
description:
|
|
32
|
+
'A button. Set it up as {@link generic:acme-setup} says; theme it with {@link @astryxdesign/cli:generic:theme}.',
|
|
33
|
+
bestPractices: [
|
|
34
|
+
{
|
|
35
|
+
guidance: true,
|
|
36
|
+
description: 'Pair it with {@link component:AcmeButton}.',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
props: [
|
|
41
|
+
{
|
|
42
|
+
name: 'tone',
|
|
43
|
+
type: 'string',
|
|
44
|
+
description:
|
|
45
|
+
'Read {@link generic:acme-setup}; write `{@link generic:acme-setup}` to link.',
|
|
46
|
+
default: "'{@link generic:acme-setup}'",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
examples: [
|
|
50
|
+
{
|
|
51
|
+
label: 'As {@link generic:acme-setup} shows',
|
|
52
|
+
code: '// {@link generic:acme-setup}',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const ACME_SETUP = {
|
|
58
|
+
type: 'generic',
|
|
59
|
+
name: 'acme-setup',
|
|
60
|
+
title: 'Acme setup',
|
|
61
|
+
description:
|
|
62
|
+
'Set up Acme, then theme it as {@link @astryxdesign/cli:generic:theme} says.',
|
|
63
|
+
sections: [
|
|
64
|
+
{title: 'Overview', content: [{type: 'prose', text: 'Install it.'}]},
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
function scaffold() {
|
|
69
|
+
fs.writeFileSync(
|
|
70
|
+
path.join(tmpDir, 'package.json'),
|
|
71
|
+
JSON.stringify({name: 'consumer'}),
|
|
72
|
+
);
|
|
73
|
+
fs.writeFileSync(
|
|
74
|
+
path.join(tmpDir, 'astryx.config.mjs'),
|
|
75
|
+
"export default {integrations: ['@acme/widgets']};\n",
|
|
76
|
+
);
|
|
77
|
+
const pkgDir = path.join(tmpDir, 'node_modules', '@acme', 'widgets');
|
|
78
|
+
fs.mkdirSync(path.join(pkgDir, 'components'), {recursive: true});
|
|
79
|
+
fs.mkdirSync(path.join(pkgDir, 'docs'), {recursive: true});
|
|
80
|
+
fs.writeFileSync(
|
|
81
|
+
path.join(pkgDir, 'package.json'),
|
|
82
|
+
JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
|
|
83
|
+
);
|
|
84
|
+
fs.writeFileSync(
|
|
85
|
+
path.join(pkgDir, 'astryx.integration.mjs'),
|
|
86
|
+
"export default {components: './components', docs: './docs'};\n",
|
|
87
|
+
);
|
|
88
|
+
fs.writeFileSync(
|
|
89
|
+
path.join(pkgDir, 'components', 'AcmeButton.doc.mjs'),
|
|
90
|
+
`export default ${JSON.stringify(ACME_BUTTON, null, 2)};\n`,
|
|
91
|
+
);
|
|
92
|
+
fs.writeFileSync(
|
|
93
|
+
path.join(pkgDir, 'components', 'AcmeButton.tsx'),
|
|
94
|
+
'export function AcmeButton() { return null; }\n',
|
|
95
|
+
);
|
|
96
|
+
fs.writeFileSync(
|
|
97
|
+
path.join(pkgDir, 'docs', 'acme-setup.doc.mjs'),
|
|
98
|
+
`export default ${JSON.stringify(ACME_SETUP, null, 2)};\n`,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
beforeEach(() => {
|
|
103
|
+
tmpDir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-component-links-'));
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
afterEach(() => {
|
|
107
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe("a link in a component doc's text", () => {
|
|
111
|
+
it(
|
|
112
|
+
"reads as the command that opens its doc, against the integration's own docs",
|
|
113
|
+
async () => {
|
|
114
|
+
scaffold();
|
|
115
|
+
const read = /** @type {any} */ (
|
|
116
|
+
await component('AcmeButton', {cwd: tmpDir})
|
|
117
|
+
);
|
|
118
|
+
expect(read.type).toBe('component.detail');
|
|
119
|
+
expect(read.data.usage.description).toBe(
|
|
120
|
+
'A button. Set it up as `astryx docs acme-setup` says; theme it with `astryx docs theme`.',
|
|
121
|
+
);
|
|
122
|
+
expect(read.data.usage.bestPractices[0].description).toBe(
|
|
123
|
+
'Pair it with `astryx component AcmeButton --package @acme/widgets`.',
|
|
124
|
+
);
|
|
125
|
+
// Code ticks and code fields show the syntax as written.
|
|
126
|
+
expect(read.data.props[0].description).toBe(
|
|
127
|
+
'Read `astryx docs acme-setup`; write `{@link generic:acme-setup}` to link.',
|
|
128
|
+
);
|
|
129
|
+
expect(read.data.props[0].default).toBe("'{@link generic:acme-setup}'");
|
|
130
|
+
expect(read.data.examples[0]).toEqual({
|
|
131
|
+
label: 'As `astryx docs acme-setup` shows',
|
|
132
|
+
code: '// {@link generic:acme-setup}',
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
SLOW,
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
it(
|
|
139
|
+
'reads the same in `astryx discover <package>/<Component>`',
|
|
140
|
+
async () => {
|
|
141
|
+
scaffold();
|
|
142
|
+
const json = await runCli(
|
|
143
|
+
['--json', 'discover', '@acme/widgets/AcmeButton'],
|
|
144
|
+
tmpDir,
|
|
145
|
+
);
|
|
146
|
+
expect(json.status).toBe(0);
|
|
147
|
+
expect(JSON.parse(json.stdout).data.usage.description).toBe(
|
|
148
|
+
'A button. Set it up as `astryx docs acme-setup` says; theme it with `astryx docs theme`.',
|
|
149
|
+
);
|
|
150
|
+
},
|
|
151
|
+
SLOW,
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
it(
|
|
155
|
+
"reads the same in a search hit's description",
|
|
156
|
+
async () => {
|
|
157
|
+
scaffold();
|
|
158
|
+
const found = /** @type {any} */ (
|
|
159
|
+
await search('AcmeButton', {cwd: tmpDir, type: 'component'})
|
|
160
|
+
);
|
|
161
|
+
const hit = found.data.results.find(
|
|
162
|
+
(/** @type {any} */ result) => result.name === 'AcmeButton',
|
|
163
|
+
);
|
|
164
|
+
expect(hit.description).toBe(
|
|
165
|
+
'A button. Set it up as `astryx docs acme-setup` says; theme it with `astryx docs theme`.',
|
|
166
|
+
);
|
|
167
|
+
},
|
|
168
|
+
SLOW,
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
it(
|
|
172
|
+
'reads the same in the props projection, in JSON, and in text',
|
|
173
|
+
async () => {
|
|
174
|
+
scaffold();
|
|
175
|
+
const props = /** @type {any} */ (
|
|
176
|
+
await component('AcmeButton', {cwd: tmpDir, props: true})
|
|
177
|
+
);
|
|
178
|
+
expect(props.data[0].description).toBe(
|
|
179
|
+
'Read `astryx docs acme-setup`; write `{@link generic:acme-setup}` to link.',
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
const json = await runCli(['--json', 'component', 'AcmeButton'], tmpDir);
|
|
183
|
+
expect(json.status).toBe(0);
|
|
184
|
+
expect(JSON.parse(json.stdout).data.usage.description).toContain(
|
|
185
|
+
'`astryx docs acme-setup`',
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const text = await runCli(['component', 'AcmeButton'], tmpDir);
|
|
189
|
+
expect(text.status).toBe(0);
|
|
190
|
+
expect(text.stdout).toContain('`astryx docs acme-setup`');
|
|
191
|
+
expect(text.stdout).not.toContain('{@link generic:acme-setup} says');
|
|
192
|
+
},
|
|
193
|
+
SLOW,
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
it("resolves a Core component's links against the CLI's own docs", async () => {
|
|
197
|
+
const read = await linkComponentResponse(
|
|
198
|
+
{
|
|
199
|
+
type: 'component.detail',
|
|
200
|
+
package: CORE_PACKAGE,
|
|
201
|
+
data: {
|
|
202
|
+
usage: {description: 'Theme it with {@link generic:theme}.'},
|
|
203
|
+
props: [
|
|
204
|
+
{
|
|
205
|
+
name: 'x',
|
|
206
|
+
type: 'string',
|
|
207
|
+
description: 'See {@link generic:nope}.',
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
tmpDir,
|
|
213
|
+
);
|
|
214
|
+
expect(read.data.usage.description).toBe(
|
|
215
|
+
'Theme it with `astryx docs theme`.',
|
|
216
|
+
);
|
|
217
|
+
// A link that names no doc prints as written.
|
|
218
|
+
expect(read.data.props[0].description).toBe('See {@link generic:nope}.');
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
describe("a link in a topic's description", () => {
|
|
223
|
+
it(
|
|
224
|
+
'reads as the command that opens its doc, in the detail and the list',
|
|
225
|
+
async () => {
|
|
226
|
+
scaffold();
|
|
227
|
+
const detail = /** @type {any} */ (
|
|
228
|
+
await docs('acme-setup', undefined, {cwd: tmpDir, full: true})
|
|
229
|
+
);
|
|
230
|
+
expect(detail.data.description).toBe(
|
|
231
|
+
'Set up Acme, then theme it as `astryx docs theme` says.',
|
|
232
|
+
);
|
|
233
|
+
const listed = /** @type {any} */ (
|
|
234
|
+
await docs(undefined, undefined, {cwd: tmpDir})
|
|
235
|
+
);
|
|
236
|
+
expect(
|
|
237
|
+
listed.data.find((/** @type {any} */ t) => t.topic === 'acme-setup')
|
|
238
|
+
.description,
|
|
239
|
+
).toBe('Set up Acme, then theme it as `astryx docs theme` says.');
|
|
240
|
+
},
|
|
241
|
+
SLOW,
|
|
242
|
+
);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
describe("a link in a guide's description, as the docs tree shows it", () => {
|
|
246
|
+
it(
|
|
247
|
+
'reads as the command that opens its doc in the guide and its namespace',
|
|
248
|
+
async () => {
|
|
249
|
+
const expected =
|
|
250
|
+
'Document a theme by extending the core theme topic, so an app reads it in `astryx docs theme`.';
|
|
251
|
+
const guide = /** @type {any} */ (
|
|
252
|
+
await docs(
|
|
253
|
+
'cli/integrations/building-blocks/themes/document-the-theme',
|
|
254
|
+
undefined,
|
|
255
|
+
{cwd: tmpDir, full: true},
|
|
256
|
+
)
|
|
257
|
+
);
|
|
258
|
+
expect(guide.data.description).toBe(expected);
|
|
259
|
+
const namespace = /** @type {any} */ (
|
|
260
|
+
await docs('cli/integrations/building-blocks/themes', undefined, {
|
|
261
|
+
cwd: tmpDir,
|
|
262
|
+
})
|
|
263
|
+
);
|
|
264
|
+
const child = namespace.data.slots
|
|
265
|
+
.flatMap((/** @type {any} */ slot) => slot.children)
|
|
266
|
+
.find((/** @type {any} */ each) => each.name === 'document-the-theme');
|
|
267
|
+
expect(child.summary).toBe(expected);
|
|
268
|
+
},
|
|
269
|
+
SLOW,
|
|
270
|
+
);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
describe("a reference block's summary of another package's component", () => {
|
|
274
|
+
it(
|
|
275
|
+
"resolves the summary's links against the component's own package",
|
|
276
|
+
async () => {
|
|
277
|
+
const write = (
|
|
278
|
+
/** @type {string} */ file,
|
|
279
|
+
/** @type {string} */ text,
|
|
280
|
+
) => {
|
|
281
|
+
fs.mkdirSync(path.dirname(path.join(tmpDir, file)), {recursive: true});
|
|
282
|
+
fs.writeFileSync(path.join(tmpDir, file), text);
|
|
283
|
+
};
|
|
284
|
+
const doc = (/** @type {object} */ value) =>
|
|
285
|
+
`export default ${JSON.stringify(value)};\n`;
|
|
286
|
+
write('package.json', JSON.stringify({name: 'consumer'}));
|
|
287
|
+
write(
|
|
288
|
+
'astryx.config.mjs',
|
|
289
|
+
"export default {integrations: ['@acme/widgets', '@acme/other']};\n",
|
|
290
|
+
);
|
|
291
|
+
const widgets = 'node_modules/@acme/widgets';
|
|
292
|
+
write(
|
|
293
|
+
`${widgets}/package.json`,
|
|
294
|
+
JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
|
|
295
|
+
);
|
|
296
|
+
write(
|
|
297
|
+
`${widgets}/astryx.integration.mjs`,
|
|
298
|
+
"export default {docs: './docs'};\n",
|
|
299
|
+
);
|
|
300
|
+
write(
|
|
301
|
+
`${widgets}/docs/acme-ref.doc.mjs`,
|
|
302
|
+
doc({
|
|
303
|
+
type: 'generic',
|
|
304
|
+
name: 'acme-ref',
|
|
305
|
+
title: 'Acme ref',
|
|
306
|
+
description: 'Where the card is documented.',
|
|
307
|
+
sections: [
|
|
308
|
+
{
|
|
309
|
+
title: 'Overview',
|
|
310
|
+
content: [
|
|
311
|
+
{
|
|
312
|
+
type: 'reference',
|
|
313
|
+
target: '@acme/other:component:OtherCardBody',
|
|
314
|
+
},
|
|
315
|
+
],
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
}),
|
|
319
|
+
);
|
|
320
|
+
const other = 'node_modules/@acme/other';
|
|
321
|
+
write(
|
|
322
|
+
`${other}/package.json`,
|
|
323
|
+
JSON.stringify({name: '@acme/other', version: '1.0.0'}),
|
|
324
|
+
);
|
|
325
|
+
write(
|
|
326
|
+
`${other}/astryx.integration.mjs`,
|
|
327
|
+
"export default {components: './components', docs: './docs'};\n",
|
|
328
|
+
);
|
|
329
|
+
write(
|
|
330
|
+
`${other}/docs/other-setup.doc.mjs`,
|
|
331
|
+
doc({
|
|
332
|
+
type: 'generic',
|
|
333
|
+
name: 'other-setup',
|
|
334
|
+
title: 'Other setup',
|
|
335
|
+
description: 'Set up Other.',
|
|
336
|
+
sections: [
|
|
337
|
+
{
|
|
338
|
+
title: 'Overview',
|
|
339
|
+
content: [{type: 'prose', text: 'Install it.'}],
|
|
340
|
+
},
|
|
341
|
+
],
|
|
342
|
+
}),
|
|
343
|
+
);
|
|
344
|
+
write(
|
|
345
|
+
`${other}/components/OtherCard.doc.mjs`,
|
|
346
|
+
doc({
|
|
347
|
+
type: 'component',
|
|
348
|
+
name: 'OtherCard',
|
|
349
|
+
displayName: 'Other Card',
|
|
350
|
+
usage: {description: 'A card.'},
|
|
351
|
+
props: [],
|
|
352
|
+
}),
|
|
353
|
+
);
|
|
354
|
+
write(
|
|
355
|
+
`${other}/components/OtherCard.tsx`,
|
|
356
|
+
'export function OtherCard() { return null; }\n',
|
|
357
|
+
);
|
|
358
|
+
write(
|
|
359
|
+
`${other}/components/OtherCardBody.doc.mjs`,
|
|
360
|
+
doc({
|
|
361
|
+
type: 'component',
|
|
362
|
+
name: 'OtherCardBody',
|
|
363
|
+
displayName: 'Other Card Body',
|
|
364
|
+
subComponentOf: 'OtherCard',
|
|
365
|
+
description: 'Its body, set up as {@link generic:other-setup} says.',
|
|
366
|
+
props: [],
|
|
367
|
+
}),
|
|
368
|
+
);
|
|
369
|
+
write(
|
|
370
|
+
`${other}/components/OtherCardBody.tsx`,
|
|
371
|
+
'export function OtherCardBody() { return null; }\n',
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
const read = /** @type {any} */ (
|
|
375
|
+
await docs('acme-ref', undefined, {cwd: tmpDir, full: true})
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
// `other-setup` is @acme/other's topic: from @acme/widgets, the
|
|
379
|
+
// linking package, the same link names no doc.
|
|
380
|
+
expect(read.data.sections[0].content[0].text).toContain(
|
|
381
|
+
'Its body, set up as `astryx docs other-setup` says.',
|
|
382
|
+
);
|
|
383
|
+
},
|
|
384
|
+
SLOW,
|
|
385
|
+
);
|
|
386
|
+
});
|