@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.
Files changed (71) hide show
  1. package/README.md +62 -62
  2. package/api/component/_adapter.d.mts +31 -0
  3. package/api/component/_adapter.mjs +116 -0
  4. package/api/component/component.mjs +60 -10
  5. package/api/component/doc-links.test.mjs +386 -0
  6. package/api/discover/detail/doc/doc.mjs +9 -1
  7. package/api/docs/_adapter.d.mts +63 -0
  8. package/api/docs/_adapter.mjs +309 -16
  9. package/api/docs/integration-tree.test.mjs +22 -0
  10. package/api/docs/list/list.mjs +12 -2
  11. package/api/integration/_adapter.d.mts +23 -0
  12. package/api/integration/_adapter.mjs +45 -0
  13. package/api/integration/authoring-checks.mjs +87 -3
  14. package/api/integration/authoring-checks.test.mjs +443 -0
  15. package/api/integration/authoring-checks.type.d.mts +84 -0
  16. package/api/integration/authoring-checks.type.mjs +40 -1
  17. package/api/integration/integrationComponentConflicts.doc.mjs +3 -1
  18. package/api/integration/integrationDocConflicts.doc.mjs +7 -2
  19. package/api/integration/pack-check.mjs +4 -0
  20. package/api/integration/pack-check.test.mjs +26 -0
  21. package/api/integration/validate-integration-fixes.test.mjs +67 -0
  22. package/api/integration/validate-integration.mjs +28 -3
  23. package/api/integration/validate-integration.test.mjs +77 -8
  24. package/api/integration/validateIntegration.doc.mjs +1 -1
  25. package/api/search/search.mjs +2 -1
  26. package/assets/docs/browser-support.doc.mjs +1 -1
  27. package/assets/docs/tree/add-a-topic.doc.mjs +2 -2
  28. package/assets/docs/tree/check-the-props.doc.mjs +5 -0
  29. package/assets/docs/tree/check-your-docs.doc.mjs +10 -2
  30. package/assets/docs/tree/checks.doc.mjs +4 -4
  31. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +7 -7
  32. package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
  33. package/assets/docs/tree/publishing.doc.mjs +2 -2
  34. package/assets/docs/tree/sections-and-placement.doc.mjs +2 -2
  35. package/authoring/doctypes/component/type.ts +8 -0
  36. package/authoring/doctypes/hook/type.ts +4 -0
  37. package/clients/cli/commands/doctor-integration-components.doc.mjs +3 -2
  38. package/clients/cli/commands/doctor-integration-docs.doc.mjs +3 -1
  39. package/clients/cli/commands/doctor-integration.test.mjs +48 -1
  40. package/clients/cli/commands/doctor.mjs +60 -5
  41. package/clients/cli/commands/integration-authoring.test.mjs +46 -0
  42. package/clients/cli/commands/integration-check.test.mjs +79 -0
  43. package/clients/cli/commands/integration.mjs +10 -4
  44. package/foundation/discovery/copied-passages.d.mts +8 -0
  45. package/foundation/discovery/copied-passages.mjs +2 -2
  46. package/foundation/discovery/doc-consistency.d.mts +34 -0
  47. package/foundation/discovery/doc-consistency.mjs +513 -0
  48. package/foundation/discovery/doc-consistency.test.mjs +347 -0
  49. package/foundation/discovery/doc-fluff.d.mts +112 -0
  50. package/foundation/discovery/doc-fluff.mjs +328 -0
  51. package/foundation/discovery/doc-fluff.test.mjs +142 -0
  52. package/foundation/discovery/doc-types.mjs +12 -5
  53. package/foundation/discovery/doc-types.test.mjs +46 -2
  54. package/foundation/discovery/prop-drift.d.mts +25 -6
  55. package/foundation/discovery/prop-drift.mjs +171 -6
  56. package/foundation/discovery/prop-drift.test.mjs +65 -0
  57. package/foundation/discovery/stray-pointers.d.mts +52 -0
  58. package/foundation/discovery/stray-pointers.mjs +293 -0
  59. package/foundation/discovery/stray-pointers.test.mjs +86 -0
  60. package/foundation/doc-compiler/doc-loads.test.mjs +12 -0
  61. package/foundation/doc-compiler/links.d.mts +32 -0
  62. package/foundation/doc-compiler/links.mjs +163 -26
  63. package/foundation/doc-compiler/links.test.mjs +97 -4
  64. package/foundation/doc-compiler/tree.mjs +30 -1
  65. package/foundation/doc-compiler/tree.test.mjs +7 -0
  66. package/foundation/integrations/contribution-inventory.d.mts +11 -0
  67. package/foundation/integrations/contribution-inventory.mjs +50 -2
  68. package/foundation/integrations/issue.ts +6 -0
  69. package/foundation/integrations/validate-contributions.mjs +30 -1
  70. package/foundation/response/response-types.doc.mjs +4 -4
  71. package/package.json +9 -9
@@ -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 component(target.name, {...options, package: target.package});
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 component(replacement.name, {...options, package: packageScope});
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, {cwd, name, ownerPackage: owner.package})
428
- : componentDetailShowcase(dirName, {cwd, name, resolve: false, ownerPackage: owner.package});
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, {cwd, name, packageScope, ownerPackage: packageScope});
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 component(replacement.name, {
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, {name, ownerPackage: owner.package});
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, {cwd, name, resolve: false, ownerPackage: owner.package});
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, {cwd, name, ownerPackage: CORE_PACKAGE});
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({props: sub.matchingComponent.props}, resolved.resolvedOwnerPackage);
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
+ });
@@ -14,6 +14,7 @@
14
14
  */
15
15
 
16
16
  import {findComponent, loadValidatedDoc} from '../../_adapter.mjs';
17
+ import {linkComponentResponse} from '../../../component/_adapter.mjs';
17
18
  import {levenshteinDistance} from '../../../../foundation/text/string-utils.mjs';
18
19
  import {AstryxError} from '../../../error.mjs';
19
20
  import {ERROR_CODES} from '../../../../foundation/response/error-codes.mjs';
@@ -27,7 +28,14 @@ import {ERROR_CODES} from '../../../../foundation/response/error-codes.mjs';
27
28
  * @returns {Promise<import('../../discover.type.mjs').DiscoverDetailDocResponse>}
28
29
  */
29
30
  export async function docFromResult(result, opts) {
30
- return {type: 'discover.detail.doc', data: await loadValidatedDoc(result, opts)};
31
+ const data = await loadValidatedDoc(result, opts);
32
+ // Its `{@link}`s read as the commands that open their docs, as
33
+ // `astryx component` prints them (spec:AST-047 FR9).
34
+ const linked = await linkComponentResponse(
35
+ {type: 'component.detail', package: result.pkg.name, data},
36
+ process.cwd(),
37
+ );
38
+ return {type: 'discover.detail.doc', data: linked.data};
31
39
  }
32
40
 
33
41
  /**
@@ -50,6 +50,42 @@ export function lowerTopic(catalog: DocsCatalog, entry: DocsTopicEntry, lang?: s
50
50
  * @returns {Promise<LinkProblem[]>}
51
51
  */
52
52
  export function topicLinkProblems(catalog: DocsCatalog, entry: DocsTopicEntry): Promise<LinkProblem[]>;
53
+ /**
54
+ * One line of a doc's text, such as a topic's or a tree node's summary, with
55
+ * every inline link resolved against the provider that wrote it (spec:AST-047
56
+ * FR9). A link that names no doc prints as written; doctor names it.
57
+ * @param {DocsCatalog} catalog
58
+ * @param {string} providerId the provider id of the doc the text sits in
59
+ * @param {string} text
60
+ * @returns {Promise<string>}
61
+ */
62
+ export function linkDocText(catalog: DocsCatalog, providerId: string, text: string): Promise<string>;
63
+ /**
64
+ * A component doc with every inline link in its text fields resolved
65
+ * (spec:AST-047 FR9): its description, usage, best practices, and each prop's
66
+ * and example's description. Code fields are shown as written. A Core
67
+ * component's links resolve against the CLI's own docs provider; an
68
+ * integration's against that integration's.
69
+ * @template T
70
+ * @param {DocsCatalog} catalog
71
+ * @param {string} providerId the provider id the component's links resolve
72
+ * against
73
+ * @param {T} doc
74
+ * @returns {Promise<{doc: T, problems: LinkProblem[]}>}
75
+ */
76
+ export function linkComponentDoc<T>(catalog: DocsCatalog, providerId: string, doc: T): Promise<{
77
+ doc: T;
78
+ problems: LinkProblem[];
79
+ }>;
80
+ /**
81
+ * The provider id a component's doc links resolve against: the CLI's own for
82
+ * a Core component, else its owner package's (or the provider id its manifest
83
+ * declares).
84
+ * @param {string} ownerPackage
85
+ * @param {string} [providerId]
86
+ * @returns {string}
87
+ */
88
+ export function componentLinkProvider(ownerPackage: string, providerId?: string): string;
53
89
  /**
54
90
  * The project's docs tree: the CLI's own docs plus the namespace docs and
55
91
  * placed guides the configured integrations ship (spec:AST-046), built once
@@ -85,6 +121,20 @@ export function docsLinkProblems(catalog: DocsCatalog, tree: DocsTree, { owner,
85
121
  owner?: string;
86
122
  references?: boolean;
87
123
  }): Promise<string[]>;
124
+ /**
125
+ * What \`astryx doctor integration components\` checks of the links in one
126
+ * integration's own component docs (spec:AST-047 FR9): each link in a
127
+ * description, usage, best practice, or prop's or example's description that
128
+ * names no doc. It prints as written, so each is a warning.
129
+ * @param {any} integration a loaded integration
130
+ * @param {Parameters<typeof packageCatalog>[1]} discovered the package's own
131
+ * docs, which its components' links may name; null when it ships none
132
+ * @returns {Promise<Array<{severity: 'warning', message: string}>>}
133
+ */
134
+ export function packageComponentLinkProblems(integration: any, discovered: Parameters<typeof packageCatalog>[1]): Promise<Array<{
135
+ severity: "warning";
136
+ message: string;
137
+ }>>;
88
138
  /**
89
139
  * What \`astryx doctor integration docs\` checks in one integration's docs: the
90
140
  * docs tree they build beside the CLI's (namespaces, placements, routes) and
@@ -320,6 +370,19 @@ export type LinkResolver = import("../../foundation/doc-compiler/links.mjs").Lin
320
370
  export type DocIncluder = import("../../foundation/doc-compiler/links.mjs").DocIncluder;
321
371
  export type DocsTopicEntry = import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry;
322
372
  import { DocsCatalog } from '../../foundation/discovery/docs-discovery.mjs';
373
+ /**
374
+ * The catalog one integration package's docs and links read, as doctor checks
375
+ * it before any app configures it: the CLI's topics, Core's and the package's
376
+ * components and templates, and the package's own docs.
377
+ * @param {any} integration
378
+ * @param {{records: import('../../foundation/discovery/docs-discovery.mjs').DocsTopicRecord[], namespaces: import('../../foundation/doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../../foundation/doc-compiler/tree.mjs').TreeDocInput[]} | null} discovered
379
+ * @returns {DocsCatalog}
380
+ */
381
+ declare function packageCatalog(integration: any, discovered: {
382
+ records: import("../../foundation/discovery/docs-discovery.mjs").DocsTopicRecord[];
383
+ namespaces: import("../../foundation/doc-compiler/tree.mjs").TreeNamespaceInput[];
384
+ guides: import("../../foundation/doc-compiler/tree.mjs").TreeDocInput[];
385
+ } | null): DocsCatalog;
323
386
  import { AstryxError } from '../error.mjs';
324
387
  import { OVERLAY_LANGUAGES } from '../../foundation/doc-compiler/read.mjs';
325
388
  import { overlayLanguages } from '../../foundation/doc-compiler/read.mjs';