@astryxdesign/cli 0.7.2-canary.6fddf4f → 0.7.2-canary.72db6f9
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/gap-report/gap-report.d.mts +3 -0
- package/api/gap-report/gap-report.doc.mjs +11 -3
- package/api/gap-report/gap-report.mjs +152 -48
- package/api/gap-report/gap-report.test.mjs +233 -0
- package/api/gap-report/gap-report.type.d.mts +41 -0
- package/api/gap-report/gap-report.type.mjs +18 -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/api/upgrade/_adapter.d.mts +40 -2
- package/api/upgrade/_adapter.mjs +117 -4
- package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
- package/api/upgrade/run/run.mjs +30 -1
- package/api/upgrade/status/status.d.mts +21 -5
- package/api/upgrade/status/status.mjs +45 -8
- package/api/upgrade/upgrade.doc.mjs +5 -3
- package/api/upgrade/upgrade.type.d.mts +23 -0
- package/api/upgrade/upgrade.type.mjs +16 -1
- package/assets/codemods/runner.mjs +7 -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 +25 -5
- 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/gap-report.doc.mjs +14 -2
- package/clients/cli/commands/gap-report.mjs +24 -2
- package/clients/cli/commands/gap-report.test.mjs +79 -0
- package/clients/cli/commands/integration-authoring.test.mjs +46 -0
- package/clients/cli/commands/integration-check.test.mjs +144 -0
- package/clients/cli/commands/integration.mjs +12 -7
- package/clients/cli/commands/json-contract.test.mjs +5 -1
- package/clients/cli/commands/upgrade.doc.mjs +14 -0
- package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
- 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/env/package-manager.d.mts +32 -0
- package/foundation/env/package-manager.mjs +47 -0
- package/foundation/env/package-manager.test.mjs +194 -7
- 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 +10 -9
- package/package.json +11 -11
package/api/docs/_adapter.d.mts
CHANGED
|
@@ -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';
|
package/api/docs/_adapter.mjs
CHANGED
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
import {sortDiagnostics} from '../../foundation/doc-compiler/diagnostics.mjs';
|
|
41
41
|
import {
|
|
42
42
|
linkBlocks,
|
|
43
|
+
linkFields,
|
|
43
44
|
parseLinkTarget,
|
|
44
45
|
} from '../../foundation/doc-compiler/links.mjs';
|
|
45
46
|
import {
|
|
@@ -264,8 +265,16 @@ function linkTopic(catalog, entry, lang) {
|
|
|
264
265
|
problems.push(...linked.problems);
|
|
265
266
|
sections.push({...section, content: linked.content});
|
|
266
267
|
}
|
|
268
|
+
// The topic's own text outside its sections, its description and
|
|
269
|
+
// summary, resolves against the topic's own provider.
|
|
270
|
+
const {resolve} = await linkerFor(providerOf(entry));
|
|
271
|
+
const fields = await linkFields(topicTextFields(raw.doc), resolve);
|
|
272
|
+
problems.push(...fields.problems);
|
|
267
273
|
return {
|
|
268
|
-
node: deepFreeze({
|
|
274
|
+
node: deepFreeze({
|
|
275
|
+
...raw,
|
|
276
|
+
doc: {...raw.doc, ...fields.doc, sections},
|
|
277
|
+
}),
|
|
269
278
|
problems,
|
|
270
279
|
};
|
|
271
280
|
})();
|
|
@@ -274,6 +283,82 @@ function linkTopic(catalog, entry, lang) {
|
|
|
274
283
|
return linked;
|
|
275
284
|
}
|
|
276
285
|
|
|
286
|
+
/**
|
|
287
|
+
* The text fields of a topic outside its sections: its description and
|
|
288
|
+
* summary, those it has.
|
|
289
|
+
* @param {any} doc
|
|
290
|
+
* @returns {{description?: string, summary?: string}}
|
|
291
|
+
*/
|
|
292
|
+
function topicTextFields(doc) {
|
|
293
|
+
/** @type {{description?: string, summary?: string}} */
|
|
294
|
+
const fields = {};
|
|
295
|
+
if (typeof doc?.description === 'string')
|
|
296
|
+
fields.description = doc.description;
|
|
297
|
+
if (typeof doc?.summary === 'string') fields.summary = doc.summary;
|
|
298
|
+
return fields;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* One line of a doc's text, such as a topic's or a tree node's summary, with
|
|
303
|
+
* every inline link resolved against the provider that wrote it (spec:AST-047
|
|
304
|
+
* FR9). A link that names no doc prints as written; doctor names it.
|
|
305
|
+
* @param {DocsCatalog} catalog
|
|
306
|
+
* @param {string} providerId the provider id of the doc the text sits in
|
|
307
|
+
* @param {string} text
|
|
308
|
+
* @returns {Promise<string>}
|
|
309
|
+
*/
|
|
310
|
+
export async function linkDocText(catalog, providerId, text) {
|
|
311
|
+
if (typeof text !== 'string' || !text.includes('{@link')) return text;
|
|
312
|
+
let provider;
|
|
313
|
+
try {
|
|
314
|
+
provider = normalizeProviderId(providerId);
|
|
315
|
+
} catch {
|
|
316
|
+
return text;
|
|
317
|
+
}
|
|
318
|
+
const linked = await linkFields(
|
|
319
|
+
{description: text},
|
|
320
|
+
await linkResolver(catalog, provider),
|
|
321
|
+
);
|
|
322
|
+
return linked.doc.description ?? text;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* A component doc with every inline link in its text fields resolved
|
|
327
|
+
* (spec:AST-047 FR9): its description, usage, best practices, and each prop's
|
|
328
|
+
* and example's description. Code fields are shown as written. A Core
|
|
329
|
+
* component's links resolve against the CLI's own docs provider; an
|
|
330
|
+
* integration's against that integration's.
|
|
331
|
+
* @template T
|
|
332
|
+
* @param {DocsCatalog} catalog
|
|
333
|
+
* @param {string} providerId the provider id the component's links resolve
|
|
334
|
+
* against
|
|
335
|
+
* @param {T} doc
|
|
336
|
+
* @returns {Promise<{doc: T, problems: LinkProblem[]}>}
|
|
337
|
+
*/
|
|
338
|
+
export async function linkComponentDoc(catalog, providerId, doc) {
|
|
339
|
+
if (!JSON.stringify(doc ?? null).includes('{@link')) {
|
|
340
|
+
return {doc, problems: []};
|
|
341
|
+
}
|
|
342
|
+
return linkFields(
|
|
343
|
+
doc,
|
|
344
|
+
await linkResolver(catalog, normalizeProviderId(providerId)),
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* The provider id a component's doc links resolve against: the CLI's own for
|
|
350
|
+
* a Core component, else its owner package's (or the provider id its manifest
|
|
351
|
+
* declares).
|
|
352
|
+
* @param {string} ownerPackage
|
|
353
|
+
* @param {string} [providerId]
|
|
354
|
+
* @returns {string}
|
|
355
|
+
*/
|
|
356
|
+
export function componentLinkProvider(ownerPackage, providerId) {
|
|
357
|
+
return ownerPackage === CORE_PACKAGE
|
|
358
|
+
? CLI_PROVIDER_ID
|
|
359
|
+
: normalizeProviderId(providerId ?? ownerPackage);
|
|
360
|
+
}
|
|
361
|
+
|
|
277
362
|
/** @type {WeakMap<DocsCatalog, Promise<DocsTree>>} */
|
|
278
363
|
const treesByCatalog = new WeakMap();
|
|
279
364
|
|
|
@@ -347,12 +432,50 @@ async function buildProjectTree(catalog, fresh) {
|
|
|
347
432
|
docs: [...cli.docs, ...added.flatMap(each => each.guides)],
|
|
348
433
|
topics: await flatTopicInputs(catalog),
|
|
349
434
|
});
|
|
435
|
+
// A summary is a doc's text too: each link in it reads as the command that
|
|
436
|
+
// opens its doc, wherever the tree's summaries print (spec:AST-047 FR9).
|
|
437
|
+
for (const node of result.nodes.values()) {
|
|
438
|
+
if (typeof node.summary === 'string' && node.summary.includes('{@link')) {
|
|
439
|
+
node.summary = await linkSummary(
|
|
440
|
+
catalog,
|
|
441
|
+
result,
|
|
442
|
+
node.providerId,
|
|
443
|
+
node.summary,
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
350
447
|
return {
|
|
351
448
|
...result,
|
|
352
449
|
diagnostics: sortDiagnostics([...cli.diagnostics, ...result.diagnostics]),
|
|
353
450
|
};
|
|
354
451
|
}
|
|
355
452
|
|
|
453
|
+
/**
|
|
454
|
+
* One summary with each inline link resolved to the command that opens its
|
|
455
|
+
* doc, against the provider that wrote it. A link that names no doc prints as
|
|
456
|
+
* written; doctor names it where it checks the doc's own fields.
|
|
457
|
+
* @param {DocsCatalog} catalog
|
|
458
|
+
* @param {DocsTree} tree
|
|
459
|
+
* @param {string} providerId
|
|
460
|
+
* @param {string} summary
|
|
461
|
+
* @returns {Promise<string>}
|
|
462
|
+
*/
|
|
463
|
+
async function linkSummary(catalog, tree, providerId, summary) {
|
|
464
|
+
if (!summary.includes('{@link')) return summary;
|
|
465
|
+
let provider;
|
|
466
|
+
try {
|
|
467
|
+
provider = normalizeProviderId(providerId);
|
|
468
|
+
} catch {
|
|
469
|
+
return summary;
|
|
470
|
+
}
|
|
471
|
+
const find = docFinderOver(catalog, tree, provider, false);
|
|
472
|
+
const linked = await linkFields({summary}, async target => {
|
|
473
|
+
const found = await find(target);
|
|
474
|
+
return 'problem' in found ? found : found.link;
|
|
475
|
+
});
|
|
476
|
+
return linked.doc.summary;
|
|
477
|
+
}
|
|
478
|
+
|
|
356
479
|
/** @type {WeakMap<DocsTree, Map<string, TreeNode>>} */
|
|
357
480
|
const identitiesByTree = new WeakMap();
|
|
358
481
|
|
|
@@ -430,10 +553,34 @@ async function authoringDoc(catalog, kind, name) {
|
|
|
430
553
|
* @returns {Promise<(target: string) => Promise<FoundDoc | {problem: string}>>}
|
|
431
554
|
*/
|
|
432
555
|
async function docFinder(catalog, fromProvider) {
|
|
433
|
-
|
|
556
|
+
return docFinderOver(catalog, await projectTree(catalog), fromProvider);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* {@link docFinder} over a tree already built, so building the tree can
|
|
561
|
+
* resolve the links in its own summaries.
|
|
562
|
+
* @param {DocsCatalog} catalog
|
|
563
|
+
* @param {DocsTree} tree
|
|
564
|
+
* @param {string} fromProvider
|
|
565
|
+
* @param {boolean} [summaries] resolve the links in a found flat topic's
|
|
566
|
+
* summary; off while a summary is itself being resolved, so two summaries
|
|
567
|
+
* that link each other cannot loop
|
|
568
|
+
* @returns {(target: string) => Promise<FoundDoc | {problem: string}>}
|
|
569
|
+
*/
|
|
570
|
+
function docFinderOver(catalog, tree, fromProvider, summaries = true) {
|
|
571
|
+
const identities = identitiesOf(tree);
|
|
434
572
|
return async target => {
|
|
435
573
|
const parsed = parseLinkTarget(target);
|
|
436
|
-
if ('error' in parsed)
|
|
574
|
+
if ('error' in parsed)
|
|
575
|
+
return {
|
|
576
|
+
problem: bareLinkHint(
|
|
577
|
+
parsed.error,
|
|
578
|
+
target,
|
|
579
|
+
catalog,
|
|
580
|
+
identities,
|
|
581
|
+
fromProvider,
|
|
582
|
+
),
|
|
583
|
+
};
|
|
437
584
|
let provider;
|
|
438
585
|
try {
|
|
439
586
|
provider = normalizeProviderId(parsed.provider ?? fromProvider);
|
|
@@ -442,7 +589,9 @@ async function docFinder(catalog, fromProvider) {
|
|
|
442
589
|
problem: `"${target}" names "${parsed.provider}", which is not a provider id: an npm package name, or the \`providerId\` its manifest declares`,
|
|
443
590
|
};
|
|
444
591
|
}
|
|
445
|
-
const node = identities.get(
|
|
592
|
+
const node = identities.get(
|
|
593
|
+
identityKey(provider, parsed.kind, parsed.name),
|
|
594
|
+
);
|
|
446
595
|
if (node) {
|
|
447
596
|
return {
|
|
448
597
|
link: {
|
|
@@ -491,6 +640,14 @@ async function docFinder(catalog, fromProvider) {
|
|
|
491
640
|
const raw = await lowerRawTopic(catalog, entry);
|
|
492
641
|
title = raw.doc.title ?? title;
|
|
493
642
|
summary = raw.doc.description ?? summary;
|
|
643
|
+
if (summaries) {
|
|
644
|
+
summary = await linkSummary(
|
|
645
|
+
catalog,
|
|
646
|
+
tree,
|
|
647
|
+
providerOf(entry),
|
|
648
|
+
summary,
|
|
649
|
+
);
|
|
650
|
+
}
|
|
494
651
|
} catch {
|
|
495
652
|
// The topic budget check reports a topic that does not load; the
|
|
496
653
|
// link still opens it.
|
|
@@ -516,8 +673,20 @@ async function docFinder(catalog, fromProvider) {
|
|
|
516
673
|
parsed.kind,
|
|
517
674
|
parsed.name,
|
|
518
675
|
);
|
|
519
|
-
if (link)
|
|
676
|
+
if (link) {
|
|
677
|
+
// The summary is the target doc's own text, so its links resolve
|
|
678
|
+
// against the target's provider, never the linking doc's: a Core
|
|
679
|
+
// component's against the CLI's docs, like its other fields.
|
|
680
|
+
if (summaries && link.summary.includes('{@link')) {
|
|
681
|
+
link.summary = await linkSummary(
|
|
682
|
+
catalog,
|
|
683
|
+
tree,
|
|
684
|
+
provider === CORE_COMPONENT_PROVIDER ? CLI_PROVIDER_ID : provider,
|
|
685
|
+
link.summary,
|
|
686
|
+
);
|
|
687
|
+
}
|
|
520
688
|
return {link: {target, ...link}, kind: parsed.kind, typed: null};
|
|
689
|
+
}
|
|
521
690
|
}
|
|
522
691
|
const searchType =
|
|
523
692
|
parsed.kind === 'component'
|
|
@@ -531,6 +700,54 @@ async function docFinder(catalog, fromProvider) {
|
|
|
531
700
|
};
|
|
532
701
|
}
|
|
533
702
|
|
|
703
|
+
/**
|
|
704
|
+
* What a link written as a bare name (`{@link deploying}`) should say
|
|
705
|
+
* instead: the exact target to write when a topic or tree doc has that
|
|
706
|
+
* name, or that none does.
|
|
707
|
+
* @param {string} error the parse error
|
|
708
|
+
* @param {string} target the target as written
|
|
709
|
+
* @param {DocsCatalog} catalog
|
|
710
|
+
* @param {Map<string, any>} identities
|
|
711
|
+
* @param {string} fromProvider
|
|
712
|
+
* @returns {string}
|
|
713
|
+
*/
|
|
714
|
+
function bareLinkHint(error, target, catalog, identities, fromProvider) {
|
|
715
|
+
const name = typeof target === 'string' ? target.trim() : '';
|
|
716
|
+
if (!name || name.includes(':') || /\s/.test(name)) return error;
|
|
717
|
+
/** @param {string} provider */
|
|
718
|
+
const normal = provider => {
|
|
719
|
+
try {
|
|
720
|
+
return normalizeProviderId(provider);
|
|
721
|
+
} catch {
|
|
722
|
+
return provider;
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
const from = normal(fromProvider);
|
|
726
|
+
/** @param {string} provider @param {string} kind @param {string} named */
|
|
727
|
+
const written = (provider, kind, named) =>
|
|
728
|
+
`{@link ${normal(provider) === from ? '' : `${provider}:`}${kind}:${named}}`;
|
|
729
|
+
const entry = catalog.resolve(name);
|
|
730
|
+
if (entry) {
|
|
731
|
+
return `${error}. "${name}" is a topic: write \`${written(entry.providerId ?? entry.package, 'generic', entry.name)}\`.`;
|
|
732
|
+
}
|
|
733
|
+
const node = [...identities.values()].find(
|
|
734
|
+
each => String(each.name).toLowerCase() === name.toLowerCase(),
|
|
735
|
+
);
|
|
736
|
+
if (node) {
|
|
737
|
+
return `${error}. "${name}" is a ${node.kind === 'generic' ? 'topic' : `${node.kind} doc`}: write \`${written(node.providerId, node.kind, node.name)}\`.`;
|
|
738
|
+
}
|
|
739
|
+
return `${error}, and no topic is named "${name}". Link a doc that exists, as \`{@link generic:<topic>}\` (\`astryx docs\` lists the topics), or remove the link.`;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/** The provider Core's components and templates belong to. */
|
|
743
|
+
const CORE_COMPONENT_PROVIDER = (() => {
|
|
744
|
+
try {
|
|
745
|
+
return normalizeProviderId(CORE_PACKAGE);
|
|
746
|
+
} catch {
|
|
747
|
+
return CORE_PACKAGE;
|
|
748
|
+
}
|
|
749
|
+
})();
|
|
750
|
+
|
|
534
751
|
/** The doc kinds no docs tree holds: components and templates. */
|
|
535
752
|
const CONTRIBUTED_KINDS = new Set(['component', 'page', 'block']);
|
|
536
753
|
|
|
@@ -861,7 +1078,7 @@ export async function docsLinkProblems(
|
|
|
861
1078
|
for (const problem of found) {
|
|
862
1079
|
if ((problem.include === true) !== references) continue;
|
|
863
1080
|
problems.push(
|
|
864
|
-
`${where}${problem.section ? ` \u00a7 ${problem.section}` : ''}: ${problem.message}`,
|
|
1081
|
+
`${where}${problem.section ? ` \u00a7 ${problem.section}` : ''}${problem.field ? ` (${problem.field})` : ''}: ${problem.message}`,
|
|
865
1082
|
);
|
|
866
1083
|
}
|
|
867
1084
|
};
|
|
@@ -896,6 +1113,83 @@ export async function docsLinkProblems(
|
|
|
896
1113
|
return problems;
|
|
897
1114
|
}
|
|
898
1115
|
|
|
1116
|
+
/**
|
|
1117
|
+
* The catalog one integration package's docs and links read, as doctor checks
|
|
1118
|
+
* it before any app configures it: the CLI's topics, Core's and the package's
|
|
1119
|
+
* components and templates, and the package's own docs.
|
|
1120
|
+
* @param {any} integration
|
|
1121
|
+
* @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
|
|
1122
|
+
* @returns {DocsCatalog}
|
|
1123
|
+
*/
|
|
1124
|
+
function packageCatalog(integration, discovered) {
|
|
1125
|
+
const catalog = DocsCatalog.fromBuiltins();
|
|
1126
|
+
catalog.setContributions(() => packageContributions(integration));
|
|
1127
|
+
if (discovered) {
|
|
1128
|
+
for (const record of discovered.records) catalog.add(record);
|
|
1129
|
+
catalog.addTreeInputs({
|
|
1130
|
+
namespaces: discovered.namespaces.map(input => ({...input, rank: 1})),
|
|
1131
|
+
guides: discovered.guides.map(input => ({...input, rank: 1})),
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
return catalog;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
/**
|
|
1138
|
+
* What \`astryx doctor integration components\` checks of the links in one
|
|
1139
|
+
* integration's own component docs (spec:AST-047 FR9): each link in a
|
|
1140
|
+
* description, usage, best practice, or prop's or example's description that
|
|
1141
|
+
* names no doc. It prints as written, so each is a warning.
|
|
1142
|
+
* @param {any} integration a loaded integration
|
|
1143
|
+
* @param {Parameters<typeof packageCatalog>[1]} discovered the package's own
|
|
1144
|
+
* docs, which its components' links may name; null when it ships none
|
|
1145
|
+
* @returns {Promise<Array<{severity: 'warning', message: string}>>}
|
|
1146
|
+
*/
|
|
1147
|
+
export async function packageComponentLinkProblems(integration, discovered) {
|
|
1148
|
+
const catalog = packageCatalog(integration, discovered);
|
|
1149
|
+
return (await componentLinkProblems(catalog, integration.name)).map(
|
|
1150
|
+
message => ({severity: /** @type {const} */ ('warning'), message}),
|
|
1151
|
+
);
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
/**
|
|
1155
|
+
* Each link in a package's own component docs that names no doc. A family doc
|
|
1156
|
+
* that documents several components is read once.
|
|
1157
|
+
* @param {DocsCatalog} catalog
|
|
1158
|
+
* @param {string} owner the package whose component docs are read
|
|
1159
|
+
* @returns {Promise<string[]>}
|
|
1160
|
+
*/
|
|
1161
|
+
async function componentLinkProblems(catalog, owner) {
|
|
1162
|
+
const contributions = await catalog.contributions();
|
|
1163
|
+
/** @type {string[]} */
|
|
1164
|
+
const problems = [];
|
|
1165
|
+
const seen = new Set();
|
|
1166
|
+
for (const record of contributions?.components ?? []) {
|
|
1167
|
+
if (record.package !== owner || !record.docPath) continue;
|
|
1168
|
+
if (seen.has(record.docPath)) continue;
|
|
1169
|
+
seen.add(record.docPath);
|
|
1170
|
+
/** @type {any} */
|
|
1171
|
+
let doc;
|
|
1172
|
+
try {
|
|
1173
|
+
doc = await loadComponentDoc(record.docPath);
|
|
1174
|
+
} catch {
|
|
1175
|
+
// The components check reports a doc that does not load.
|
|
1176
|
+
continue;
|
|
1177
|
+
}
|
|
1178
|
+
const linked = await linkComponentDoc(
|
|
1179
|
+
catalog,
|
|
1180
|
+
componentLinkProvider(record.package, record.providerId),
|
|
1181
|
+
doc,
|
|
1182
|
+
);
|
|
1183
|
+
const name = typeof doc?.name === 'string' ? doc.name : record.name;
|
|
1184
|
+
for (const problem of linked.problems) {
|
|
1185
|
+
problems.push(
|
|
1186
|
+
`component ${name}${problem.field ? ` (${problem.field})` : ''}: ${problem.message}`,
|
|
1187
|
+
);
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
return problems;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
899
1193
|
/**
|
|
900
1194
|
* What \`astryx doctor integration docs\` checks in one integration's docs: the
|
|
901
1195
|
* docs tree they build beside the CLI's (namespaces, placements, routes) and
|
|
@@ -907,13 +1201,7 @@ export async function docsLinkProblems(
|
|
|
907
1201
|
* @returns {Promise<Array<{severity: 'error' | 'warning', message: string}>>}
|
|
908
1202
|
*/
|
|
909
1203
|
export async function packageDocsProblems(integration, discovered) {
|
|
910
|
-
const catalog =
|
|
911
|
-
catalog.setContributions(() => packageContributions(integration));
|
|
912
|
-
for (const record of discovered.records) catalog.add(record);
|
|
913
|
-
catalog.addTreeInputs({
|
|
914
|
-
namespaces: discovered.namespaces.map(input => ({...input, rank: 1})),
|
|
915
|
-
guides: discovered.guides.map(input => ({...input, rank: 1})),
|
|
916
|
-
});
|
|
1204
|
+
const catalog = packageCatalog(integration, discovered);
|
|
917
1205
|
const tree = await projectTree(catalog);
|
|
918
1206
|
/** @type {Array<{severity: 'error' | 'warning', message: string}>} */
|
|
919
1207
|
const problems = tree.diagnostics
|
|
@@ -1136,7 +1424,8 @@ export async function topicLinks(catalog, entry) {
|
|
|
1136
1424
|
const tree = await projectTree(catalog);
|
|
1137
1425
|
const node = tree.get(entry.tree ? (entry.route ?? entry.name) : entry.name);
|
|
1138
1426
|
const placed =
|
|
1139
|
-
node &&
|
|
1427
|
+
node &&
|
|
1428
|
+
(entry.tree ? node.kind === 'generic' : node.ref?.flatTopic === entry.name);
|
|
1140
1429
|
return placed ? placeLinks(tree, node) : {up: topicUp(entry)};
|
|
1141
1430
|
}
|
|
1142
1431
|
|
|
@@ -1159,7 +1448,8 @@ export async function resolveDocsArgument(topic, {cwd} = {}) {
|
|
|
1159
1448
|
const tree = await projectTree(catalog);
|
|
1160
1449
|
const owner = nameOwner(tree, catalog, topic);
|
|
1161
1450
|
if (owner == null) return {kind: 'unknown', catalog};
|
|
1162
|
-
if (owner.kind === 'topic')
|
|
1451
|
+
if (owner.kind === 'topic')
|
|
1452
|
+
return {kind: 'topic', catalog, entry: owner.entry};
|
|
1163
1453
|
return treeArgument(catalog, tree, owner.node);
|
|
1164
1454
|
}
|
|
1165
1455
|
|
|
@@ -1359,7 +1649,10 @@ export async function integrationDocTypes(integration, cwd) {
|
|
|
1359
1649
|
if (report.status !== 'checked' || unread.length === 0) return report;
|
|
1360
1650
|
// A root its reader cannot read serves no doc; say so rather than skip it.
|
|
1361
1651
|
const rel = (/** @type {string} */ file) =>
|
|
1362
|
-
path
|
|
1652
|
+
path
|
|
1653
|
+
.relative(packageDir ?? cwd, file)
|
|
1654
|
+
.split(path.sep)
|
|
1655
|
+
.join('/') || '.';
|
|
1363
1656
|
return {
|
|
1364
1657
|
...report,
|
|
1365
1658
|
unchecked: [
|
|
@@ -569,4 +569,26 @@ describe('integration docs in the docs tree', () => {
|
|
|
569
569
|
expect(check.status).toBe('warn');
|
|
570
570
|
expect(check.message).toContain('both have the route "cli"');
|
|
571
571
|
}, SLOW);
|
|
572
|
+
|
|
573
|
+
it('says what to write for a link that names a doc by its bare name, and when no doc has that name', async () => {
|
|
574
|
+
scaffold({
|
|
575
|
+
...kit(),
|
|
576
|
+
'bare.doc.mjs': guide('bare', {
|
|
577
|
+
sections: [
|
|
578
|
+
{
|
|
579
|
+
title: 'Overview',
|
|
580
|
+
content: [{type: 'prose', text: 'Read {@link deploy}, then {@link nosuchtopic}.'}],
|
|
581
|
+
},
|
|
582
|
+
],
|
|
583
|
+
}),
|
|
584
|
+
});
|
|
585
|
+
const result = await integrationDocConflicts('@acme/kit', {cwd: tmpDir});
|
|
586
|
+
const graph = result.data.issues.filter(issue => issue.code === 'invalid_doc_graph').map(issue => issue.message);
|
|
587
|
+
expect(graph).toEqual(
|
|
588
|
+
expect.arrayContaining([
|
|
589
|
+
expect.stringContaining('"deploy" is a topic: write `{@link generic:deploy}`.'),
|
|
590
|
+
expect.stringContaining('no topic is named "nosuchtopic"'),
|
|
591
|
+
]),
|
|
592
|
+
);
|
|
593
|
+
}, SLOW);
|
|
572
594
|
});
|
package/api/docs/list/list.mjs
CHANGED
|
@@ -15,7 +15,12 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import {loadTopicFile} from '../../../foundation/doc-compiler/read.mjs';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
holdsOwnName,
|
|
20
|
+
linkDocText,
|
|
21
|
+
loadDocsCatalog,
|
|
22
|
+
projectTree,
|
|
23
|
+
} from '../_adapter.mjs';
|
|
19
24
|
|
|
20
25
|
/**
|
|
21
26
|
* @param {object} [options]
|
|
@@ -39,7 +44,12 @@ export async function list({cwd} = {}) {
|
|
|
39
44
|
/** @type {import('../docs.type.mjs').DocsListEntry} */
|
|
40
45
|
const listed = {
|
|
41
46
|
topic: entry.name,
|
|
42
|
-
description
|
|
47
|
+
// A link in the description reads as the command that opens its doc.
|
|
48
|
+
description: await linkDocText(
|
|
49
|
+
catalog,
|
|
50
|
+
entry.providerId ?? entry.package,
|
|
51
|
+
description,
|
|
52
|
+
),
|
|
43
53
|
package: entry.package,
|
|
44
54
|
};
|
|
45
55
|
if (entry.replaces != null) listed.replaces = entry.replaces;
|