@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
@@ -18,8 +18,10 @@
18
18
  * @position Public integration-authoring API over private discovery adapters.
19
19
  */
20
20
 
21
+ import path from 'node:path';
21
22
  import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
22
23
  import {
24
+ packageComponentLinkProblems,
23
25
  packageDocsProblems,
24
26
  packageReferenceProblems,
25
27
  } from '../docs/_adapter.mjs';
@@ -29,7 +31,12 @@ import {
29
31
  discoverOwnedComponents,
30
32
  } from '../../foundation/discovery/component-discovery.mjs';
31
33
  import {loadComponentReplacements} from '../component/_adapter.mjs';
32
- import {integrationCopiedPassages, integrationPropDrift} from './_adapter.mjs';
34
+ import {
35
+ integrationCopiedPassages,
36
+ integrationFluff,
37
+ integrationPropDrift,
38
+ integrationStrayPointers,
39
+ } from './_adapter.mjs';
33
40
  import {
34
41
  discoverBuiltinTopics,
35
42
  discoverIntegrationDocs,
@@ -251,6 +258,19 @@ export async function integrationComponentConflicts(pkg, options = {}) {
251
258
  // the project's own compiler; without one the report says it was skipped.
252
259
  const propDrift = await integrationPropDrift(resolved.integration, cwd);
253
260
 
261
+ // A link in a component doc's text reads as the command that opens its doc,
262
+ // as one in a topic does; one that names no doc prints as written, so it is
263
+ // a warning (spec:AST-047 FR9). The package's own topics are linkable.
264
+ const ownDocs = resolved.integration.docs
265
+ ? await discoverIntegrationDocs(resolved.integration)
266
+ : null;
267
+ for (const {severity, message} of await packageComponentLinkProblems(
268
+ resolved.integration,
269
+ ownDocs,
270
+ )) {
271
+ issues.push({code: 'invalid_doc_graph', severity, message});
272
+ }
273
+
254
274
  const coreDir = findCoreDir(cwd);
255
275
  if (!coreDir) {
256
276
  issues.push({
@@ -325,10 +345,45 @@ export async function integrationDocConflicts(pkg, options = {}) {
325
345
 
326
346
  /** @type {import('./authoring-checks.type.mjs').CopiedPassage[]} */
327
347
  const copiedPassages = [];
348
+ /** @type {import('./authoring-checks.type.mjs').DocFluff[]} */
349
+ const fluff = [];
350
+ /** @type {import('./authoring-checks.type.mjs').StrayPointer[]} */
351
+ const strayPointers = [];
352
+ // Like the other findings' `doc`, a fluff or stray-pointer `file` is
353
+ // relative to the package root.
354
+ const packageDir = /** @type {any} */ (resolved.integration)?.__packageDir;
355
+ const fromPackage = (/** @type {string} */ file) =>
356
+ typeof packageDir === 'string'
357
+ ? path.relative(packageDir, file).split(path.sep).join('/')
358
+ : file;
328
359
  if (!resolved.integration?.docs || name == null) {
360
+ // A package that ships components and no topics still has component docs
361
+ // a written pointer can sit in.
362
+ if (name != null && resolved.integration?.components) {
363
+ strayPointers.push(
364
+ ...(
365
+ await integrationStrayPointers(
366
+ {records: [], guides: []},
367
+ resolved.integration,
368
+ )
369
+ ).map(each => ({...each, file: fromPackage(each.file)})),
370
+ );
371
+ for (const {message} of strayPointers) {
372
+ issues.push({code: 'stray_doc_pointer', severity: 'warning', message});
373
+ }
374
+ }
329
375
  return {
330
376
  type: 'integration.doc-conflicts',
331
- data: {validated, name, version, findings: [], copiedPassages, issues},
377
+ data: {
378
+ validated,
379
+ name,
380
+ version,
381
+ findings: [],
382
+ copiedPassages,
383
+ fluff,
384
+ strayPointers,
385
+ issues,
386
+ },
332
387
  };
333
388
  }
334
389
 
@@ -427,10 +482,39 @@ export async function integrationDocConflicts(pkg, options = {}) {
427
482
  for (const {message} of copiedPassages) {
428
483
  issues.push({code: 'copied_passage', severity: 'warning', message});
429
484
  }
485
+ // Docs should be dense: padding phrases and mostly-glue topics, listed
486
+ // and warned about the same way (DEC-8).
487
+ fluff.push(
488
+ ...(await integrationFluff(discovered)).map(each => ({
489
+ ...each,
490
+ file: fromPackage(each.file),
491
+ })),
492
+ );
493
+ for (const {message} of fluff) {
494
+ issues.push({code: 'doc_fluff', severity: 'warning', message});
495
+ }
496
+ // A pointer to a doc is a link, so doctor checks it (DEC-8).
497
+ strayPointers.push(
498
+ ...(await integrationStrayPointers(discovered, resolved.integration)).map(
499
+ each => ({...each, file: fromPackage(each.file)}),
500
+ ),
501
+ );
502
+ for (const {message} of strayPointers) {
503
+ issues.push({code: 'stray_doc_pointer', severity: 'warning', message});
504
+ }
430
505
  }
431
506
 
432
507
  return {
433
508
  type: 'integration.doc-conflicts',
434
- data: {validated, name, version, findings, copiedPassages, issues},
509
+ data: {
510
+ validated,
511
+ name,
512
+ version,
513
+ findings,
514
+ copiedPassages,
515
+ fluff,
516
+ strayPointers,
517
+ issues,
518
+ },
435
519
  };
436
520
  }
@@ -888,3 +888,446 @@ describe('integrationDocConflicts copied passages and extensions', () => {
888
888
  expect(found[0].message).not.toContain('{@link');
889
889
  });
890
890
  });
891
+
892
+ describe('integrationDocConflicts fluff', () => {
893
+ const fluff = (/** @type {any} */ result) => result.data.fluff;
894
+
895
+ it('lists each padding phrase with its line and what to write instead', async () => {
896
+ writeTopics([
897
+ {
898
+ name: 'acme-setup',
899
+ text: 'In order to start, run the setup command once.',
900
+ },
901
+ ]);
902
+
903
+ const result = await integrationDocConflicts(undefined, {cwd: tmpDir});
904
+ const [hit, ...rest] = fluff(result);
905
+
906
+ expect(rest).toEqual([]);
907
+ expect(result.data.issues).toEqual([
908
+ {code: 'doc_fluff', severity: 'warning', message: hit.message},
909
+ ]);
910
+ expect(hit).toMatchObject({
911
+ topic: 'acme-setup',
912
+ kind: 'phrase',
913
+ phrase: 'in order to',
914
+ section: 'Overview',
915
+ file: 'docs/acme-setup.doc.mjs',
916
+ line: 1,
917
+ density: null,
918
+ });
919
+ expect(hit.message).toContain('Write "to" instead.');
920
+ });
921
+
922
+ it('finds each line within its own string, not in code or another field', async () => {
923
+ writeTopics([]);
924
+ fs.writeFileSync(
925
+ path.join(tmpDir, 'docs', 'acme-lines.doc.mjs'),
926
+ [
927
+ 'export default {',
928
+ " type: 'generic',",
929
+ " name: 'acme-lines',",
930
+ " title: 'Fixture',",
931
+ " description: 'Build the package in order to publish it.',",
932
+ " sections: [{title: 'Overview', content: [",
933
+ " {type: 'code', lang: 'text', code: 'in order to build'},",
934
+ " {type: 'prose', text: 'Note that the build runs once per package and writes its output.'},",
935
+ " {type: 'prose', text: 'Run the build in order to refresh the generated files for the docs.'},",
936
+ ' ]}],',
937
+ '};',
938
+ '',
939
+ ].join('\n'),
940
+ );
941
+
942
+ const found = fluff(
943
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
944
+ ).map((/** @type {any} */ each) => [each.phrase, each.line]);
945
+
946
+ expect(found).toEqual([
947
+ ['in order to', 5],
948
+ ['note that', 8],
949
+ ['in order to', 9],
950
+ ]);
951
+ });
952
+
953
+ it('gives each use its own line in multi-line and concatenated strings', async () => {
954
+ writeTopics([]);
955
+ fs.writeFileSync(
956
+ path.join(tmpDir, 'docs', 'acme-multi.doc.mjs'),
957
+ [
958
+ 'export default {',
959
+ " type: 'generic',",
960
+ " name: 'acme-multi',",
961
+ " title: 'Fixture',",
962
+ " description: 'Fixture topic.',",
963
+ " sections: [{title: 'Overview', content: [",
964
+ " {type: 'prose', text: `Build the package first.",
965
+ 'Run the build in order to refresh the files.',
966
+ 'Run it again in order to check them.`},',
967
+ " {type: 'prose', text: 'Publishing reads the built files ' +",
968
+ " 'in order to ship them, so build before you publish.'},",
969
+ ' ]}],',
970
+ '};',
971
+ '',
972
+ ].join('\n'),
973
+ );
974
+
975
+ const found = fluff(
976
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
977
+ ).map((/** @type {any} */ each) => each.line);
978
+
979
+ expect(found).toEqual([8, 9, 11]);
980
+ });
981
+
982
+ it('finds the line of strings that open or end with code, links, quotes or escapes', async () => {
983
+ writeTopics([]);
984
+ fs.writeFileSync(
985
+ path.join(tmpDir, 'docs', 'acme-shapes.doc.mjs'),
986
+ [
987
+ 'export default {',
988
+ " type: 'generic',",
989
+ " name: 'acme-shapes',",
990
+ " title: 'Fixture',",
991
+ " description: 'Fixture topic.',",
992
+ " sections: [{title: 'Overview', content: [",
993
+ " {type: 'prose', text: '`build` runs first, in order to check it.'},",
994
+ " {type: 'prose', text: '{@link generic:acme-shapes} runs it in order to ship.'},",
995
+ " {type: 'prose', text: '\"Build\" is a step you run in order to test (and ship).'},",
996
+ " {type: 'prose', text: '(Build) runs it once in order to publish the app\\'s files.'},",
997
+ " {type: 'prose', text: 'Run the build in order to check the files.'},",
998
+ " {type: 'prose', text: 'Run the build in order to publish the files.'},",
999
+ ' ]}],',
1000
+ '};',
1001
+ '',
1002
+ ].join('\n'),
1003
+ );
1004
+
1005
+ const found = fluff(
1006
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
1007
+ ).map((/** @type {any} */ each) => each.line);
1008
+
1009
+ expect(found).toEqual([7, 8, 9, 10, 11, 12]);
1010
+ });
1011
+
1012
+ it('lists a long topic that is mostly glue, and not a dense one', async () => {
1013
+ const glue = Array.from(
1014
+ {length: 12},
1015
+ () =>
1016
+ 'So that is why it is the one that you would want to use if you can.',
1017
+ ).join(' ');
1018
+ const dense = Array.from(
1019
+ {length: 8},
1020
+ (_, i) =>
1021
+ `Name codemod folder ${i} after the Core version whose upgrade runs it.`,
1022
+ ).join(' ');
1023
+ writeTopics([
1024
+ {name: 'acme-glue', text: glue},
1025
+ {name: 'acme-dense', text: dense},
1026
+ ]);
1027
+
1028
+ const found = fluff(
1029
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
1030
+ );
1031
+
1032
+ expect(found.map((/** @type {any} */ each) => each.topic)).toEqual([
1033
+ 'acme-glue',
1034
+ ]);
1035
+ expect(found[0]).toMatchObject({kind: 'density', phrase: null});
1036
+ expect(found[0].density).toBeLessThan(0.5);
1037
+ expect(found[0].message).toContain("Core's guides have a median of");
1038
+ expect(found[0].message).toContain('under the 50% floor');
1039
+ });
1040
+ });
1041
+
1042
+ describe('integrationDocConflicts stray doc pointers', () => {
1043
+ const stray = (/** @type {any} */ result) => result.data.strayPointers;
1044
+
1045
+ it('lists a pointer to a topic whose name holds an underscore or capitals', async () => {
1046
+ writeTopics([
1047
+ {name: 'acme_setup', text: 'Install it first.'},
1048
+ {name: 'AcmeGuide', text: 'Read on.'},
1049
+ {
1050
+ name: 'acme-menus',
1051
+ text: 'Set it up as `astryx docs acme_setup` says, then `astryx docs AcmeGuide`; flags such as `astryx docs -h` are not pointers.',
1052
+ },
1053
+ ]);
1054
+
1055
+ const found = stray(
1056
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
1057
+ );
1058
+
1059
+ expect(found.map((/** @type {any} */ each) => each.link)).toEqual([
1060
+ '{@link generic:acme_setup}',
1061
+ '{@link generic:AcmeGuide}',
1062
+ ]);
1063
+ });
1064
+
1065
+ it('links a pointer to an extension topic to the page it extends', async () => {
1066
+ writeTopics([
1067
+ {name: 'acme-theme', text: 'Acme colors.', extendsTopic: 'theme'},
1068
+ {name: 'acme-menus', text: 'Colors are in `astryx docs acme-theme`.'},
1069
+ ]);
1070
+
1071
+ const [hit, ...rest] = stray(
1072
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
1073
+ );
1074
+
1075
+ expect(rest).toEqual([]);
1076
+ expect(hit).toMatchObject({
1077
+ topic: 'acme-menus',
1078
+ link: '{@link @astryxdesign/cli:generic:theme}',
1079
+ });
1080
+ });
1081
+
1082
+ it('places a pointer-only list item on its own line, not an earlier summary or code block', async () => {
1083
+ writeTopics([{name: 'acme-menus', text: 'Menus.'}]);
1084
+ fs.writeFileSync(
1085
+ path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
1086
+ [
1087
+ 'export default {',
1088
+ " type: 'generic',",
1089
+ " name: 'acme-setup',",
1090
+ " title: 'Fixture',",
1091
+ " summary: 'See `astryx docs acme-menus`.',",
1092
+ " description: 'Fixture topic.',",
1093
+ " sections: [{title: 'Overview', content: [",
1094
+ " {type: 'code', lang: 'bash', code: 'astryx docs acme-menus'},",
1095
+ " {type: 'list', style: 'unordered', items: ['`astryx docs acme-menus`']},",
1096
+ ' ]}],',
1097
+ '};',
1098
+ '',
1099
+ ].join('\n'),
1100
+ );
1101
+
1102
+ const found = stray(
1103
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
1104
+ ).filter((/** @type {any} */ each) => each.topic === 'acme-setup');
1105
+
1106
+ // The summary's own pointer is listed too, at its line.
1107
+ expect(found.map((/** @type {any} */ each) => each.line)).toEqual([5, 9]);
1108
+ });
1109
+
1110
+ it('lists a written pointer to a doc with the link that replaces it, and warns', async () => {
1111
+ writeTopics([
1112
+ {name: 'acme-setup', text: 'Install it first.'},
1113
+ {
1114
+ name: 'acme-menus',
1115
+ text: 'Set it up as `astryx docs acme-setup` says; the theme is in `astryx docs theme`.',
1116
+ },
1117
+ ]);
1118
+
1119
+ const result = await integrationDocConflicts(undefined, {cwd: tmpDir});
1120
+ const [own, core, ...rest] = stray(result);
1121
+
1122
+ expect(rest).toEqual([]);
1123
+ expect(own).toMatchObject({
1124
+ topic: 'acme-menus',
1125
+ section: 'Overview',
1126
+ file: 'docs/acme-menus.doc.mjs',
1127
+ line: 1,
1128
+ pointer: 'astryx docs acme-setup',
1129
+ link: '{@link generic:acme-setup}',
1130
+ });
1131
+ expect(own.message).toContain(
1132
+ 'Replace `astryx docs acme-setup`, code ticks included, with {@link generic:acme-setup}',
1133
+ );
1134
+ expect(core.link).toBe('{@link @astryxdesign/cli:generic:theme}');
1135
+ expect(result.data.issues).toEqual([
1136
+ {code: 'stray_doc_pointer', severity: 'warning', message: own.message},
1137
+ {code: 'stray_doc_pointer', severity: 'warning', message: core.message},
1138
+ ]);
1139
+ });
1140
+
1141
+ it('names a namespace doc by its kind', async () => {
1142
+ writeTopics([
1143
+ {name: 'acme-setup', text: 'Lay it out as `astryx docs layout` says.'},
1144
+ ]);
1145
+
1146
+ const [hit] = stray(
1147
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
1148
+ );
1149
+
1150
+ expect(hit.link).toBe('{@link @astryxdesign/cli:namespace:layout}');
1151
+ });
1152
+
1153
+ it('finds each line in the string that holds the pointer, not in code', async () => {
1154
+ writeTopics([]);
1155
+ fs.writeFileSync(
1156
+ path.join(tmpDir, 'docs', 'acme-lines.doc.mjs'),
1157
+ [
1158
+ 'export default {',
1159
+ " type: 'generic',",
1160
+ " name: 'acme-lines',",
1161
+ " title: 'Fixture',",
1162
+ " description: 'Read `astryx docs theme` first.',",
1163
+ " sections: [{title: 'Overview', content: [",
1164
+ " {type: 'code', lang: 'bash', code: 'astryx docs theme'},",
1165
+ " {type: 'prose', text: 'The colors your package sets show up in `astryx docs theme` for every app.'},",
1166
+ ' ]}],',
1167
+ '};',
1168
+ '',
1169
+ ].join('\n'),
1170
+ );
1171
+
1172
+ const found = stray(
1173
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
1174
+ );
1175
+
1176
+ // The description resolves links too, so its pointer is its own finding.
1177
+ expect(found.map((/** @type {any} */ each) => each.line)).toEqual([5, 8]);
1178
+ });
1179
+
1180
+ it('leaves a command for a doc that does not exist, and a walkthrough', async () => {
1181
+ writeTopics([
1182
+ {
1183
+ name: 'acme-setup',
1184
+ text: 'Run `astryx docs acme-nothing`, or `astryx docs acme-setup overview`.',
1185
+ },
1186
+ ]);
1187
+
1188
+ expect(
1189
+ stray(await integrationDocConflicts(undefined, {cwd: tmpDir})),
1190
+ ).toEqual([]);
1191
+ });
1192
+ });
1193
+
1194
+ /**
1195
+ * A package with one component doc and, optionally, one topic.
1196
+ * @param {{usage: string, topicDescription?: string}} fixture
1197
+ */
1198
+ function writeLinkedComponent({usage, topicDescription}) {
1199
+ fs.writeFileSync(
1200
+ path.join(tmpDir, 'package.json'),
1201
+ JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
1202
+ );
1203
+ fs.writeFileSync(
1204
+ path.join(tmpDir, 'astryx.integration.mjs'),
1205
+ topicDescription == null
1206
+ ? `export default {components: './components'};\n`
1207
+ : `export default {components: './components', docs: './docs'};\n`,
1208
+ );
1209
+ fs.mkdirSync(path.join(tmpDir, 'components'), {recursive: true});
1210
+ const doc = {
1211
+ type: 'component',
1212
+ name: 'AcmeButton',
1213
+ displayName: 'Acme Button',
1214
+ usage: {description: usage},
1215
+ props: [],
1216
+ };
1217
+ fs.writeFileSync(
1218
+ path.join(tmpDir, 'components', 'AcmeButton.doc.mjs'),
1219
+ `export default ${JSON.stringify(doc, null, 2)};\n`,
1220
+ );
1221
+ fs.writeFileSync(
1222
+ path.join(tmpDir, 'components', 'AcmeButton.tsx'),
1223
+ 'export function AcmeButton() { return null; }\n',
1224
+ );
1225
+ if (topicDescription == null) return;
1226
+ fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
1227
+ const topic = {
1228
+ type: 'generic',
1229
+ name: 'acme-setup',
1230
+ title: 'Fixture',
1231
+ description: topicDescription,
1232
+ sections: [
1233
+ {title: 'Overview', content: [{type: 'prose', text: 'Install it.'}]},
1234
+ ],
1235
+ };
1236
+ fs.writeFileSync(
1237
+ path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
1238
+ `export default ${JSON.stringify(topic, null, 2)};\n`,
1239
+ );
1240
+ }
1241
+
1242
+ describe('links in component docs and topic descriptions', () => {
1243
+ it("warns on a component doc's link that names no doc, and passes one to its own topic", async () => {
1244
+ writeLinkedComponent({
1245
+ usage:
1246
+ 'Set it up as {@link generic:acme-setup} says, theme it with {@link @astryxdesign/cli:generic:theme}, then {@link generic:acme-nothing}.',
1247
+ topicDescription: 'Install Acme.',
1248
+ });
1249
+
1250
+ const {data} = await integrationComponentConflicts(undefined, {
1251
+ cwd: tmpDir,
1252
+ });
1253
+ const links = data.issues.filter(
1254
+ (/** @type {any} */ issue) => issue.code === 'invalid_doc_graph',
1255
+ );
1256
+ expect(links).toEqual([
1257
+ {
1258
+ code: 'invalid_doc_graph',
1259
+ severity: 'warning',
1260
+ message: expect.stringMatching(
1261
+ /^component AcmeButton \(usage\.description\): "generic:acme-nothing" names no doc\./,
1262
+ ),
1263
+ },
1264
+ ]);
1265
+ });
1266
+
1267
+ it("warns on a topic description's link that names no doc", async () => {
1268
+ writeLinkedComponent({
1269
+ usage: 'A button.',
1270
+ topicDescription: 'Install Acme; see {@link generic:acme-nothing}.',
1271
+ });
1272
+
1273
+ const {data} = await integrationDocConflicts(undefined, {cwd: tmpDir});
1274
+ const links = data.issues.filter(
1275
+ (/** @type {any} */ issue) => issue.code === 'invalid_doc_graph',
1276
+ );
1277
+ expect(links).toEqual([
1278
+ {
1279
+ code: 'invalid_doc_graph',
1280
+ severity: 'warning',
1281
+ message: expect.stringMatching(
1282
+ /^acme-setup \(description\): "generic:acme-nothing" names no doc\./,
1283
+ ),
1284
+ },
1285
+ ]);
1286
+ });
1287
+
1288
+ it('lists a written pointer in a component doc, with the link that replaces it', async () => {
1289
+ writeLinkedComponent({usage: 'Theme it as `astryx docs theme` says.'});
1290
+
1291
+ const {data} = await integrationDocConflicts(undefined, {cwd: tmpDir});
1292
+ const [pointer, ...rest] = data.strayPointers;
1293
+
1294
+ expect(rest).toEqual([]);
1295
+ expect(pointer).toMatchObject({
1296
+ topic: 'AcmeButton',
1297
+ kind: 'component',
1298
+ section: null,
1299
+ field: 'usage.description',
1300
+ file: 'components/AcmeButton.doc.mjs',
1301
+ pointer: 'astryx docs theme',
1302
+ link: '{@link @astryxdesign/cli:generic:theme}',
1303
+ });
1304
+ expect(pointer.line).toEqual(expect.any(Number));
1305
+ expect(pointer.message).toBe(
1306
+ `component "AcmeButton" (field usage.description, line ${pointer.line}) points at a doc with the written command \`astryx docs theme\`. ` +
1307
+ 'Replace `astryx docs theme`, code ticks included, with {@link @astryxdesign/cli:generic:theme}: the CLI prints the command that opens the doc, and doctor checks the link.',
1308
+ );
1309
+ expect(data.issues).toContainEqual({
1310
+ code: 'stray_doc_pointer',
1311
+ severity: 'warning',
1312
+ message: pointer.message,
1313
+ });
1314
+ });
1315
+
1316
+ it("lists a written pointer in a topic's description", async () => {
1317
+ writeLinkedComponent({
1318
+ usage: 'A button.',
1319
+ topicDescription: 'Install Acme; theme it as `astryx docs theme` says.',
1320
+ });
1321
+
1322
+ const {data} = await integrationDocConflicts(undefined, {cwd: tmpDir});
1323
+
1324
+ expect(data.strayPointers).toEqual([
1325
+ expect.objectContaining({
1326
+ topic: 'acme-setup',
1327
+ kind: 'topic',
1328
+ field: 'description',
1329
+ link: '{@link @astryxdesign/cli:generic:theme}',
1330
+ }),
1331
+ ]);
1332
+ });
1333
+ });
@@ -81,6 +81,88 @@ export type CopiedPassage = {
81
81
  */
82
82
  message: string;
83
83
  };
84
+ /**
85
+ * Fluff in a topic's prose: a padding phrase (`kind: 'phrase'`, with the
86
+ * phrase, its section, and the file line where it was found), or a topic of
87
+ * 80 or more prose words of which fewer than half are content words
88
+ * (`kind: 'density'`, with the share). Each is also a `doc_fluff` warning, so
89
+ * `integration check --strict` fails on it (architecture:cli-surface DEC-8).
90
+ */
91
+ export type DocFluff = {
92
+ topic: string;
93
+ kind: "phrase" | "density";
94
+ /**
95
+ * the padding phrase, for `kind: 'phrase'`
96
+ */
97
+ phrase: string | null;
98
+ /**
99
+ * the title of the section it is in
100
+ */
101
+ section: string | null;
102
+ /**
103
+ * the doc file, relative to the package root
104
+ */
105
+ file: string;
106
+ /**
107
+ * the file line that holds the phrase, when one line does
108
+ */
109
+ line: number | null;
110
+ /**
111
+ * the share of content words, for `kind: 'density'`
112
+ */
113
+ density: number | null;
114
+ /**
115
+ * what to cut or write instead
116
+ */
117
+ message: string;
118
+ };
119
+ /**
120
+ * A code span in prose that is exactly `astryx docs <name>` for a doc that
121
+ * exists, where the doc's `{@link generic :<name>}` would be checked. Each is
122
+ * also a `stray_doc_pointer` warning, so `integration check --strict` fails on
123
+ * it (architecture:cli-surface DEC-8).
124
+ */
125
+ export type StrayPointer = {
126
+ /**
127
+ * the package topic, or component doc, that has it
128
+ */
129
+ topic: string;
130
+ /**
131
+ * whether it sits in a topic or a
132
+ * component doc
133
+ */
134
+ kind: "topic" | "component";
135
+ /**
136
+ * the title of the section it is in
137
+ */
138
+ section: string | null;
139
+ /**
140
+ * the field it is in outside any section: a
141
+ * topic's `description` or `summary`, or a component doc's field path, such
142
+ * as `usage.bestPractices[0].description`
143
+ */
144
+ field: string | null;
145
+ /**
146
+ * the doc file, relative to the package root
147
+ */
148
+ file: string;
149
+ /**
150
+ * the file line that holds it, when found
151
+ */
152
+ line: number | null;
153
+ /**
154
+ * the written command, `astryx docs <name>`
155
+ */
156
+ pointer: string;
157
+ /**
158
+ * the link that replaces it
159
+ */
160
+ link: string;
161
+ /**
162
+ * the exact replacement
163
+ */
164
+ message: string;
165
+ };
84
166
  /**
85
167
  * Each of the three authoring checks reports `validated`: false means no
86
168
  * integration manifest was found, so nothing was inspected and the empty
@@ -123,6 +205,8 @@ export type IntegrationDocConflictResponse = {
123
205
  version: string | null;
124
206
  findings: IntegrationDocFinding[];
125
207
  copiedPassages: CopiedPassage[];
208
+ fluff: DocFluff[];
209
+ strayPointers: StrayPointer[];
126
210
  issues: import("../../foundation/integrations/issue").AstryxIntegrationIssue[];
127
211
  };
128
212
  };