@astryxdesign/cli 0.6.3-canary.7ada42e → 0.6.3-canary.7ec7be0
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 +21 -19
- package/api/build/_adapter.d.mts +50 -0
- package/api/build/_adapter.mjs +60 -0
- package/api/build/build.doc.mjs +13 -7
- package/api/build/build.test.mjs +184 -6
- package/api/build/build.type.d.mts +57 -2
- package/api/build/build.type.mjs +30 -7
- package/api/build/help/help.d.mts +4 -0
- package/api/build/help/help.mjs +24 -11
- package/api/build/kit/kit.d.mts +4 -1
- package/api/build/kit/kit.mjs +165 -49
- package/api/build/kit/rank.d.mts +44 -0
- package/api/build/kit/rank.mjs +432 -0
- package/api/build/kit/rank.test.mjs +196 -0
- package/api/component/_adapter.d.mts +6 -12
- package/api/component/_adapter.mjs +20 -10
- package/api/component/component.mjs +60 -12
- package/api/component/list/list.mjs +3 -2
- package/api/docs/_adapter.d.mts +251 -28
- package/api/docs/_adapter.mjs +918 -35
- package/api/docs/detail/detail.mjs +11 -3
- package/api/docs/detail/section/section.mjs +24 -13
- package/api/docs/detail/section/section.test.mjs +15 -6
- package/api/docs/docs.d.mts +5 -3
- package/api/docs/docs.doc.mjs +38 -17
- package/api/docs/docs.mjs +44 -8
- package/api/docs/docs.test.mjs +158 -4
- package/api/docs/docs.type.d.mts +181 -2
- package/api/docs/docs.type.mjs +117 -3
- package/api/docs/index/index.mjs +11 -3
- package/api/docs/index/index.test.mjs +1 -1
- package/api/docs/integration-tree.test.mjs +555 -0
- package/api/docs/integrationDocs.test.mjs +14 -14
- package/api/docs/list/list.mjs +25 -5
- package/api/docs/node/node.d.mts +43 -0
- package/api/docs/node/node.mjs +192 -0
- package/api/docs/reference-blocks.test.mjs +406 -0
- package/api/doctor/doctor.d.mts +30 -2
- package/api/doctor/doctor.mjs +151 -8
- package/api/doctor/doctor.test.mjs +95 -7
- package/api/index.d.mts +1 -1
- package/api/index.mjs +1 -0
- package/api/init/init.doc.mjs +1 -1
- package/api/integration/add-contribution.d.mts +2 -1
- package/api/integration/add-contribution.mjs +107 -5
- package/api/integration/add-contribution.test.mjs +137 -0
- package/api/integration/authoring-checks.mjs +138 -28
- package/api/integration/authoring-checks.test.mjs +171 -3
- package/api/integration/authoring-checks.type.mjs +6 -1
- package/api/integration/integration-authoring.type.d.mts +2 -0
- package/api/integration/integration-authoring.type.mjs +2 -0
- package/api/integration/integrationAdd.doc.mjs +6 -0
- package/api/integration/integrationAddDoc.doc.mjs +7 -1
- package/api/integration/integrationDocConflicts.doc.mjs +1 -1
- package/api/integration/integrationPackCheck.doc.mjs +1 -1
- package/api/integration/integrationTemplateConflicts.doc.d.mts +3 -0
- package/api/integration/integrationTemplateConflicts.doc.mjs +3 -0
- package/api/integration/pack-check.mjs +34 -0
- package/api/integration/pack-check.test.mjs +121 -0
- package/api/integration/pack-check.type.d.mts +26 -2
- package/api/integration/pack-check.type.mjs +14 -1
- package/api/integration/template-conflict-compatibility.test.mjs +73 -0
- package/api/integration/validate-integration.test.mjs +3 -3
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/json/index.ts +2 -0
- package/api/layout/_adapter.mjs +20 -5
- package/api/search/search.d.mts +59 -1
- package/api/search/search.doc.mjs +4 -3
- package/api/search/search.mjs +442 -71
- package/api/search/search.test.mjs +91 -2
- package/api/search/search.type.d.mts +13 -1
- package/api/search/search.type.mjs +4 -1
- package/api/template/list/list.mjs +1 -0
- package/api/template/table-floating-bulk-actions.test.mjs +66 -0
- package/api/template/template-integration.test.mjs +1072 -3
- package/api/template/template.doc.mjs +27 -7
- package/api/template/template.mjs +45 -8
- package/api/template/template.type.d.mts +6 -8
- package/api/template/template.type.mjs +3 -2
- package/api/theme/template/template.test.mjs +5 -0
- package/api/theme/themeTemplate.doc.mjs +1 -1
- package/assets/docs/getting-started.doc.mjs +2 -2
- package/assets/docs/layout.doc.dense.mjs +2 -2
- package/assets/docs/layout.doc.mjs +1 -1
- package/assets/docs/principles.doc.mjs +6 -6
- package/assets/docs/styling-libraries.doc.mjs +3 -3
- package/assets/docs/styling.doc.mjs +4 -4
- package/assets/docs/theme.doc.mjs +4 -4
- package/assets/docs/tokens.doc.mjs +1 -1
- package/assets/docs/tree/api.doc.mjs +30 -0
- package/assets/docs/tree/cli.doc.mjs +23 -0
- package/assets/docs/tree/commands.doc.mjs +25 -0
- package/assets/docs/{cli-integrations.doc.mjs → tree/integrations.doc.mjs} +37 -9
- package/assets/docs/tree/integrations.test.mjs +62 -0
- package/assets/docs/tree/writing-docs.doc.mjs +286 -0
- package/assets/docs/working-with-ai.doc.mjs +3 -3
- package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
- package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
- package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
- package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +119 -117
- package/authoring/doctypes/_schema.mjs +54 -3
- package/authoring/doctypes/base/graph-fields.doc.mjs +7 -5
- package/authoring/doctypes/base/type.ts +6 -5
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/command/type.ts +2 -2
- package/authoring/doctypes/enum/enum.doc.mjs +1 -1
- package/authoring/doctypes/enum/type.ts +1 -1
- package/authoring/doctypes/function/function.doc.mjs +3 -2
- package/authoring/doctypes/function/type.ts +3 -2
- package/authoring/doctypes/load-contract.test.mjs +26 -1
- package/authoring/doctypes/namespace/namespace.doc.mjs +6 -10
- package/authoring/doctypes/namespace/parse.test.mjs +23 -25
- package/authoring/doctypes/namespace/type.ts +5 -2
- package/authoring/doctypes/parse.mjs +3 -2
- package/authoring/doctypes/reference/reference.doc.mjs +34 -5
- package/authoring/doctypes/reference/type.ts +28 -11
- package/authoring/doctypes/schema/schema.doc.mjs +1 -1
- package/authoring/doctypes/schema/type.ts +1 -1
- package/authoring/doctypes/template/parse.d.mts +2 -0
- package/authoring/doctypes/template/parse.mjs +4 -0
- package/authoring/doctypes/template/parse.test.mjs +18 -0
- package/authoring/doctypes/template/template.doc.mjs +6 -0
- package/authoring/doctypes/template/type.ts +8 -0
- package/authoring/identity/identity.doc.mjs +2 -2
- package/authoring/index.d.ts +1 -0
- package/authoring/integration/type.ts +1 -1
- package/clients/cli/commands/build-theme.adaptations.test.mjs +100 -1
- package/clients/cli/commands/build-theme.mjs +1 -1
- package/clients/cli/commands/build.doc.mjs +11 -6
- package/clients/cli/commands/build.mjs +105 -67
- package/clients/cli/commands/build.text-fields.test.mjs +41 -0
- package/clients/cli/commands/component/index.mjs +1 -1
- package/clients/cli/commands/component-ownership.test.mjs +3 -3
- package/clients/cli/commands/discover.broken-integration.test.mjs +7 -8
- package/clients/cli/commands/discover.mjs +1 -1
- package/clients/cli/commands/docs.doc.mjs +20 -8
- package/clients/cli/commands/docs.mjs +183 -69
- package/clients/cli/commands/docs.test.mjs +120 -16
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +2 -2
- package/clients/cli/commands/doctor-integration-templates.doc.mjs +14 -7
- package/clients/cli/commands/doctor-integration.test.mjs +75 -1
- package/clients/cli/commands/doctor.mjs +53 -16
- package/clients/cli/commands/integration-add.doc.mjs +10 -0
- package/clients/cli/commands/integration.mjs +1 -0
- package/clients/cli/commands/search.mjs +11 -2
- package/clients/cli/commands/setup-nudge.test.mjs +6 -0
- package/clients/cli/commands/template.doc.mjs +23 -6
- package/clients/cli/commands/template.mjs +4 -91
- package/clients/cli/index.mjs +8 -0
- package/clients/cli/lib/manifest.mjs +9 -2
- package/foundation/agent-docs/agent-docs.d.mts +3 -2
- package/foundation/agent-docs/agent-docs.mjs +13 -9
- package/foundation/agent-docs/agent-docs.test.mjs +19 -1
- package/foundation/config/project.d.mts +12 -11
- package/foundation/config/project.mjs +73 -59
- package/foundation/config/project.test.mjs +141 -5
- package/foundation/discovery/authoring-self-docs.d.mts +12 -0
- package/foundation/discovery/authoring-self-docs.mjs +20 -8
- package/foundation/discovery/authoring-self-docs.test.mjs +25 -9
- package/foundation/discovery/cli-self-docs.d.mts +40 -34
- package/foundation/discovery/cli-self-docs.mjs +91 -115
- package/foundation/discovery/cli-self-docs.test.mjs +104 -166
- package/foundation/discovery/component-discovery.d.mts +38 -0
- package/foundation/discovery/component-discovery.mjs +48 -0
- package/foundation/discovery/docs-discovery.d.mts +109 -9
- package/foundation/discovery/docs-discovery.mjs +223 -24
- package/foundation/discovery/docs-discovery.test.mjs +103 -27
- package/foundation/discovery/docs-output-budget.d.mts +2 -2
- package/foundation/discovery/docs-output-budget.mjs +1 -1
- package/foundation/discovery/docs-section-key.d.mts +28 -10
- package/foundation/discovery/docs-section-key.mjs +134 -33
- package/foundation/discovery/docs-section-key.test.mjs +41 -19
- package/foundation/discovery/template-adapter.d.mts +92 -6
- package/foundation/discovery/template-adapter.mjs +453 -17
- package/foundation/discovery/template-adapter.test.mjs +42 -0
- package/foundation/discovery/template-conflict-release.d.mts +13 -0
- package/foundation/discovery/template-conflict-release.mjs +40 -0
- package/foundation/discovery/template-conflict-release.test.mjs +40 -0
- package/foundation/doc-compiler/bundle.mjs +61 -1
- package/foundation/doc-compiler/bundle.test.mjs +21 -10
- package/foundation/doc-compiler/compile.d.mts +113 -132
- package/foundation/doc-compiler/compile.mjs +57 -10
- package/foundation/doc-compiler/diagnostics.mjs +28 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
- package/foundation/doc-compiler/inputs.d.mts +2 -2
- package/foundation/doc-compiler/inputs.mjs +6 -1
- package/foundation/doc-compiler/ir.mjs +7 -0
- package/foundation/doc-compiler/lenses.d.mts +8 -5
- package/foundation/doc-compiler/lenses.mjs +50 -4
- package/foundation/doc-compiler/links.d.mts +162 -0
- package/foundation/doc-compiler/links.mjs +294 -0
- package/foundation/doc-compiler/links.test.mjs +192 -0
- package/foundation/doc-compiler/lower-doc.test.mjs +5 -2
- package/foundation/doc-compiler/read.d.mts +3 -2
- package/foundation/doc-compiler/read.mjs +6 -1
- package/foundation/doc-compiler/tree.d.mts +288 -0
- package/foundation/doc-compiler/tree.mjs +876 -0
- package/foundation/doc-compiler/tree.test.mjs +598 -0
- package/foundation/integrations/autolink.test.mjs +1 -1
- package/foundation/integrations/cli-requirement.d.mts +45 -0
- package/foundation/integrations/cli-requirement.mjs +154 -0
- package/foundation/integrations/cli-requirement.test.mjs +84 -0
- package/foundation/integrations/contribution-inventory.d.mts +2 -1
- package/foundation/integrations/contribution-inventory.mjs +10 -4
- package/foundation/integrations/contribution-inventory.test.mjs +19 -0
- package/foundation/integrations/integration-warnings.d.mts +9 -2
- package/foundation/integrations/integration-warnings.mjs +51 -26
- package/foundation/integrations/integration-warnings.test.mjs +74 -1
- package/foundation/integrations/validate-contributions.mjs +25 -27
- package/foundation/response/response-types.doc.d.mts +5 -1
- package/foundation/response/response-types.doc.mjs +19 -10
- package/foundation/text/string-utils.d.mts +8 -0
- package/foundation/text/string-utils.mjs +18 -0
- package/foundation/xle/expand.mjs +1 -1
- package/foundation/xle/xle.test.mjs +13 -0
- package/package.json +9 -9
- package/assets/docs/cli.doc.mjs +0 -15
|
@@ -60,32 +60,48 @@ describe('authoring self-docs', () => {
|
|
|
60
60
|
);
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
describe('what the authoring docs say about the
|
|
64
|
-
it('marks exactly the fields
|
|
63
|
+
describe('what the authoring docs say about the docs tree', () => {
|
|
64
|
+
it('marks exactly the fields the docs tree does not read yet', () => {
|
|
65
65
|
const notReadYet = graphFieldsDoc.fields
|
|
66
66
|
.filter(field => /Not read yet/.test(field.description))
|
|
67
67
|
.map(field => field.name);
|
|
68
|
-
|
|
68
|
+
// The tree reads `placement` for every guide (spec:AST-046); the other
|
|
69
|
+
// graph fields are still refused by every topic reader.
|
|
70
|
+
expect(notReadYet.sort()).toEqual(
|
|
71
|
+
GRAPH_ONLY_FIELDS.filter(field => field !== 'placement').sort(),
|
|
72
|
+
);
|
|
69
73
|
for (const field of graphFieldsDoc.fields) {
|
|
70
|
-
if (
|
|
74
|
+
if (GRAPH_ONLY_FIELDS.includes(field.name)) {
|
|
71
75
|
expect(field.description).toMatch(/fails to load/);
|
|
72
76
|
}
|
|
73
77
|
}
|
|
78
|
+
const placement = graphFieldsDoc.fields.find(f => f.name === 'placement');
|
|
79
|
+
expect(placement.description).toMatch(
|
|
80
|
+
/Read for every guide, the CLI's and each integration's/,
|
|
81
|
+
);
|
|
74
82
|
expect(graphFieldsDoc.description).toMatch(/not built yet/);
|
|
75
83
|
});
|
|
76
84
|
|
|
77
|
-
it('
|
|
85
|
+
it('keeps graph blocks behind the separate GraphContentBlock type, and a section takes a reference block', () => {
|
|
78
86
|
const content = referenceDoc.fields
|
|
79
87
|
.flatMap(field => [field, ...(field.fields ?? [])])
|
|
80
88
|
.find(field => field.name === 'sections[].content');
|
|
89
|
+
expect(content.type).toBe('(ReferenceContentBlock | ReferenceDocBlock)[]');
|
|
90
|
+
expect(content.description).toContain('GraphContentBlock');
|
|
81
91
|
for (const type of GRAPH_BLOCK_TYPES) {
|
|
82
92
|
expect(content.description).toContain(type);
|
|
83
93
|
}
|
|
84
|
-
|
|
94
|
+
// A section's reference block reads as the doc it includes.
|
|
95
|
+
expect(GRAPH_BLOCK_TYPES.has('reference')).toBe(false);
|
|
96
|
+
expect(content.description).toMatch(
|
|
97
|
+
/A `reference` block .* includes another doc/,
|
|
98
|
+
);
|
|
85
99
|
});
|
|
86
100
|
|
|
87
|
-
it('says namespace docs
|
|
88
|
-
expect(namespaceDoc.description).toMatch(
|
|
101
|
+
it('says where namespace docs live: the CLI tree, and each integration', () => {
|
|
102
|
+
expect(namespaceDoc.description).toMatch(
|
|
103
|
+
/an integration ships its own in its docs directory/,
|
|
104
|
+
);
|
|
89
105
|
expect(
|
|
90
106
|
problemsInTopic({
|
|
91
107
|
...namespaceDoc.examples?.[0],
|
|
@@ -93,7 +109,7 @@ describe('what the authoring docs say about the unbuilt docs graph', () => {
|
|
|
93
109
|
name: 'x',
|
|
94
110
|
}),
|
|
95
111
|
).toEqual([
|
|
96
|
-
'"x" is a namespace doc
|
|
112
|
+
'"x" is a namespace doc, which the docs tree reads, not the topic list. The CLI keeps its own in assets/docs/tree; an integration ships its namespace docs in its docs directory.',
|
|
97
113
|
]);
|
|
98
114
|
});
|
|
99
115
|
});
|
|
@@ -27,46 +27,45 @@ export function loadCliSelfDocs(sources?: string[], root?: string): Promise<{
|
|
|
27
27
|
}[];
|
|
28
28
|
}>;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
33
|
-
* @
|
|
30
|
+
* What cross-links need: the loaded function docs by name, the command names,
|
|
31
|
+
* and the route the docs tree gave a doc, if it gave one.
|
|
32
|
+
* @typedef {object} CliDocIndex
|
|
33
|
+
* @property {Map<string, any>} functions
|
|
34
|
+
* @property {Set<string>} commands
|
|
35
|
+
* @property {(kind: string, name: string) => string | null} route
|
|
34
36
|
*/
|
|
35
|
-
export function keySegment(name: string): string;
|
|
36
37
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
40
|
-
* @returns {string | null}
|
|
41
|
-
*/
|
|
42
|
-
export function cliSectionKey(doc: any): string | null;
|
|
43
|
-
/**
|
|
44
|
-
* The `cli` topic: one section per doc whose namespace is `cli/…`.
|
|
45
|
-
* @param {any[]} docs every loaded CLI doc; the ones in other namespaces are
|
|
46
|
-
* left out
|
|
47
|
-
* @returns {import('../../authoring/doctypes/reference/type').ReferenceDoc}
|
|
38
|
+
* @param {any[]} docs every loaded CLI typed doc
|
|
39
|
+
* @param {(kind: string, name: string) => string | null} [route]
|
|
40
|
+
* @returns {CliDocIndex}
|
|
48
41
|
*/
|
|
49
|
-
export function
|
|
42
|
+
export function cliDocIndex(docs: any[], route?: (kind: string, name: string) => string | null): CliDocIndex;
|
|
50
43
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @
|
|
44
|
+
* What `astryx docs <route>` prints for one CLI typed doc: its title and the
|
|
45
|
+
* blocks of its content, with cross-links to the routes the tree gave.
|
|
46
|
+
* @param {any} doc
|
|
47
|
+
* @param {CliDocIndex} index
|
|
48
|
+
* @returns {{id: string, title: string, content: any[]}}
|
|
54
49
|
*/
|
|
55
|
-
export function
|
|
50
|
+
export function cliDocSection(doc: any, index: CliDocIndex): {
|
|
51
|
+
id: string;
|
|
52
|
+
title: string;
|
|
53
|
+
content: any[];
|
|
54
|
+
};
|
|
56
55
|
/**
|
|
57
|
-
* What stands between a CLI doc and a reader: a missing namespace, one
|
|
58
|
-
*
|
|
59
|
-
*
|
|
56
|
+
* What stands between a CLI doc and a reader: a missing namespace, one nothing
|
|
57
|
+
* reads, one that disagrees with the authoring topic's list, a doc that fails
|
|
58
|
+
* to load, and a tree leaf too large for one read. Whether the tree gives
|
|
59
|
+
* every `cli/...` doc a route is the docs-tree check's job.
|
|
60
60
|
* @param {{root?: string, sources?: string[], budget?: number, authoringSources?: string[]}} [options]
|
|
61
61
|
* @returns {Promise<{
|
|
62
62
|
* docs: number,
|
|
63
|
-
*
|
|
63
|
+
* tree: number,
|
|
64
64
|
* authoring: number,
|
|
65
65
|
* missing: string[],
|
|
66
66
|
* unknown: {source: string, namespace: string}[],
|
|
67
67
|
* misfiled: {source: string, message: string}[],
|
|
68
68
|
* failed: {source: string, error: string}[],
|
|
69
|
-
* keyProblems: string[],
|
|
70
69
|
* oversized: {key: string, title: string, bytes: number}[],
|
|
71
70
|
* }>}
|
|
72
71
|
*/
|
|
@@ -77,7 +76,7 @@ export function auditCliSelfDocs({ root, sources, budget, authoringSources, }?:
|
|
|
77
76
|
authoringSources?: string[];
|
|
78
77
|
}): Promise<{
|
|
79
78
|
docs: number;
|
|
80
|
-
|
|
79
|
+
tree: number;
|
|
81
80
|
authoring: number;
|
|
82
81
|
missing: string[];
|
|
83
82
|
unknown: {
|
|
@@ -92,7 +91,6 @@ export function auditCliSelfDocs({ root, sources, budget, authoringSources, }?:
|
|
|
92
91
|
source: string;
|
|
93
92
|
error: string;
|
|
94
93
|
}[];
|
|
95
|
-
keyProblems: string[];
|
|
96
94
|
oversized: {
|
|
97
95
|
key: string;
|
|
98
96
|
title: string;
|
|
@@ -102,12 +100,20 @@ export function auditCliSelfDocs({ root, sources, budget, authoringSources, }?:
|
|
|
102
100
|
/** The directories, relative to the CLI root, that hold the CLI's own docs. */
|
|
103
101
|
export const CLI_SELF_DOC_DIRS: string[];
|
|
104
102
|
/**
|
|
105
|
-
* Every namespace a CLI doc may declare, and
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* @type {Record<string, {
|
|
103
|
+
* Every namespace a CLI doc may declare, and what reads it. The docs tree
|
|
104
|
+
* adopts `cli/commands` (under `cli/commands`) and `cli/api` (under
|
|
105
|
+
* `cli/api/<kind>s`); `astryx docs authoring` reads `authoring` from its list.
|
|
106
|
+
* @type {Record<string, {reader: 'tree' | 'authoring'}>}
|
|
109
107
|
*/
|
|
110
108
|
export const CLI_DOC_NAMESPACES: Record<string, {
|
|
111
|
-
|
|
112
|
-
keyPrefix?: string;
|
|
109
|
+
reader: "tree" | "authoring";
|
|
113
110
|
}>;
|
|
111
|
+
/**
|
|
112
|
+
* What cross-links need: the loaded function docs by name, the command names,
|
|
113
|
+
* and the route the docs tree gave a doc, if it gave one.
|
|
114
|
+
*/
|
|
115
|
+
export type CliDocIndex = {
|
|
116
|
+
functions: Map<string, any>;
|
|
117
|
+
commands: Set<string>;
|
|
118
|
+
route: (kind: string, name: string) => string | null;
|
|
119
|
+
};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file The CLI's own docs, read by their `namespace`: every command,
|
|
5
|
-
* function, schema, and enum doc the CLI ships
|
|
6
|
-
*
|
|
4
|
+
* @file The CLI's own typed docs, read by their `namespace`: every command,
|
|
5
|
+
* API function, schema, and enum doc the CLI ships names the group that reads
|
|
6
|
+
* it. The docs tree adopts `cli/commands` and `cli/api` (spec:AST-046); the
|
|
7
|
+
* authoring topic reads `authoring` from its own list.
|
|
7
8
|
*
|
|
8
9
|
* @input The command, function, schema, and enum docs under
|
|
9
10
|
* clients/cli/commands, api, authoring, and foundation.
|
|
10
|
-
* @output {@link
|
|
11
|
+
* @output {@link loadCliSelfDocs} for the docs tree, {@link cliDocSection} for
|
|
12
|
+
* what `astryx docs <route>` prints for one of them, and
|
|
11
13
|
* {@link auditCliSelfDocs}, which `astryx doctor` runs.
|
|
12
|
-
* @position foundation/discovery
|
|
13
|
-
*
|
|
14
|
-
* own list (authoring-self-docs.mjs).
|
|
14
|
+
* @position foundation/discovery. The tree (doc-compiler/tree.mjs) gives each
|
|
15
|
+
* doc its route; this module only loads the docs and renders one.
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
import * as fs from 'node:fs';
|
|
@@ -23,7 +24,7 @@ import {
|
|
|
23
24
|
DOC_OUTPUT_BUDGET_BYTES,
|
|
24
25
|
oversizedDocSections,
|
|
25
26
|
} from './docs-output-budget.mjs';
|
|
26
|
-
import {
|
|
27
|
+
import {routeSegment} from './docs-section-key.mjs';
|
|
27
28
|
|
|
28
29
|
/** The directories, relative to the CLI root, that hold the CLI's own docs. */
|
|
29
30
|
export const CLI_SELF_DOC_DIRS = [
|
|
@@ -37,23 +38,20 @@ export const CLI_SELF_DOC_DIRS = [
|
|
|
37
38
|
const NAMESPACED_KINDS = new Set(['command', 'function', 'schema', 'enum']);
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
|
-
* Every namespace a CLI doc may declare, and
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @type {Record<string, {
|
|
41
|
+
* Every namespace a CLI doc may declare, and what reads it. The docs tree
|
|
42
|
+
* adopts `cli/commands` (under `cli/commands`) and `cli/api` (under
|
|
43
|
+
* `cli/api/<kind>s`); `astryx docs authoring` reads `authoring` from its list.
|
|
44
|
+
* @type {Record<string, {reader: 'tree' | 'authoring'}>}
|
|
44
45
|
*/
|
|
45
46
|
export const CLI_DOC_NAMESPACES = {
|
|
46
|
-
'cli/commands': {
|
|
47
|
-
'cli/api': {
|
|
48
|
-
authoring: {
|
|
47
|
+
'cli/commands': {reader: 'tree'},
|
|
48
|
+
'cli/api': {reader: 'tree'},
|
|
49
|
+
authoring: {reader: 'authoring'},
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
/** Blocks a doc's notes may carry that a topic section can render. */
|
|
52
53
|
const TOPIC_BLOCKS = new Set(['prose', 'list', 'code', 'heading', 'table']);
|
|
53
54
|
|
|
54
|
-
/** Section order within the `cli` topic: commands, then the API by kind. */
|
|
55
|
-
const KIND_ORDER = ['command', 'function', 'schema', 'enum'];
|
|
56
|
-
|
|
57
55
|
/**
|
|
58
56
|
* Every `*.doc.mjs` under the CLI's doc directories, relative to `root` and
|
|
59
57
|
* sorted. Fixture, test, and dependency directories are skipped.
|
|
@@ -121,29 +119,27 @@ export async function loadCliSelfDocs(
|
|
|
121
119
|
}
|
|
122
120
|
|
|
123
121
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* @
|
|
127
|
-
* @
|
|
122
|
+
* What cross-links need: the loaded function docs by name, the command names,
|
|
123
|
+
* and the route the docs tree gave a doc, if it gave one.
|
|
124
|
+
* @typedef {object} CliDocIndex
|
|
125
|
+
* @property {Map<string, any>} functions
|
|
126
|
+
* @property {Set<string>} commands
|
|
127
|
+
* @property {(kind: string, name: string) => string | null} route
|
|
128
128
|
*/
|
|
129
|
-
export function keySegment(name) {
|
|
130
|
-
return name
|
|
131
|
-
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
132
|
-
.toLowerCase()
|
|
133
|
-
.replace(/[^a-z0-9]+/g, '-')
|
|
134
|
-
.replace(/^-+|-+$/g, '');
|
|
135
|
-
}
|
|
136
129
|
|
|
137
130
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* @
|
|
141
|
-
* @returns {string | null}
|
|
131
|
+
* @param {any[]} docs every loaded CLI typed doc
|
|
132
|
+
* @param {(kind: string, name: string) => string | null} [route]
|
|
133
|
+
* @returns {CliDocIndex}
|
|
142
134
|
*/
|
|
143
|
-
export function
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
135
|
+
export function cliDocIndex(docs, route = () => null) {
|
|
136
|
+
return {
|
|
137
|
+
functions: new Map(
|
|
138
|
+
docs.filter(d => d.type === 'function').map(d => [d.name, d]),
|
|
139
|
+
),
|
|
140
|
+
commands: new Set(docs.filter(d => d.type === 'command').map(d => d.name)),
|
|
141
|
+
route,
|
|
142
|
+
};
|
|
147
143
|
}
|
|
148
144
|
|
|
149
145
|
/** @param {unknown} value */
|
|
@@ -197,9 +193,9 @@ function noteBlocks(notes) {
|
|
|
197
193
|
}
|
|
198
194
|
|
|
199
195
|
/**
|
|
200
|
-
*
|
|
196
|
+
* What `astryx docs <route>` prints for one command doc.
|
|
201
197
|
* @param {any} cmd
|
|
202
|
-
* @param {
|
|
198
|
+
* @param {CliDocIndex} index
|
|
203
199
|
*/
|
|
204
200
|
function commandSection(cmd, index) {
|
|
205
201
|
const fn = cmd.fn == null ? undefined : index.functions.get(cmd.fn);
|
|
@@ -255,6 +251,8 @@ function commandSection(cmd, index) {
|
|
|
255
251
|
rows: exitCodes.map((/** @type {any} */ e) => [String(e.code), e.when]),
|
|
256
252
|
});
|
|
257
253
|
}
|
|
254
|
+
// Links name docs by identity; the route in each command is derived when
|
|
255
|
+
// the doc is read (spec:AST-047 FR9).
|
|
258
256
|
const subcommands = (cmd.subcommands ?? []).filter(
|
|
259
257
|
(/** @type {string} */ sub) => index.commands.has(`${cmd.name} ${sub}`),
|
|
260
258
|
);
|
|
@@ -264,28 +262,44 @@ function commandSection(cmd, index) {
|
|
|
264
262
|
style: 'unordered',
|
|
265
263
|
items: subcommands.map(
|
|
266
264
|
(/** @type {string} */ sub) =>
|
|
267
|
-
`\`astryx ${cmd.name} ${sub}\`:
|
|
265
|
+
`\`astryx ${cmd.name} ${sub}\`: {@link command:${cmd.name} ${sub}}`,
|
|
268
266
|
),
|
|
269
267
|
});
|
|
270
268
|
}
|
|
271
269
|
if (fn != null) {
|
|
272
270
|
content.push({
|
|
273
271
|
type: 'prose',
|
|
274
|
-
text: `It runs \`${fn.name}()\` from \`${fn.importPath}\`. Read it with
|
|
272
|
+
text: `It runs \`${fn.name}()\` from \`${fn.importPath}\`. Read it with {@link function:${fn.name}}.`,
|
|
275
273
|
});
|
|
276
274
|
}
|
|
277
275
|
content.push(...noteBlocks(cmd.notes));
|
|
278
276
|
return {
|
|
279
|
-
id:
|
|
277
|
+
id: routeSegment(cmd.name),
|
|
280
278
|
title: cmd.displayName ?? `astryx ${cmd.name}`,
|
|
281
279
|
content,
|
|
282
280
|
};
|
|
283
281
|
}
|
|
284
282
|
|
|
285
283
|
/**
|
|
286
|
-
*
|
|
284
|
+
* The command doc a command line belongs to: its longest leading words that
|
|
285
|
+
* name one (`integration add theme` is the `integration add` command).
|
|
286
|
+
* @param {string} line
|
|
287
|
+
* @param {Set<string>} commands
|
|
288
|
+
* @returns {string | null}
|
|
289
|
+
*/
|
|
290
|
+
function commandDocName(line, commands) {
|
|
291
|
+
const words = line.trim().split(/\s+/);
|
|
292
|
+
for (let n = words.length; n > 0; n--) {
|
|
293
|
+
const name = words.slice(0, n).join(' ');
|
|
294
|
+
if (commands.has(name)) return name;
|
|
295
|
+
}
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* What `astryx docs <route>` prints for one API function doc.
|
|
287
301
|
* @param {any} fn
|
|
288
|
-
* @param {
|
|
302
|
+
* @param {CliDocIndex} index
|
|
289
303
|
*/
|
|
290
304
|
function functionSection(fn, index) {
|
|
291
305
|
/** @type {any[]} */
|
|
@@ -341,26 +355,28 @@ function functionSection(fn, index) {
|
|
|
341
355
|
code: example.code,
|
|
342
356
|
});
|
|
343
357
|
}
|
|
344
|
-
|
|
358
|
+
const commandDoc =
|
|
359
|
+
fn.command == null ? null : commandDocName(fn.command, index.commands);
|
|
360
|
+
if (commandDoc != null) {
|
|
345
361
|
content.push({
|
|
346
362
|
type: 'prose',
|
|
347
|
-
text: `\`astryx ${fn.command}\` runs it. Read it with
|
|
363
|
+
text: `\`astryx ${fn.command}\` runs it. Read it with {@link command:${commandDoc}}.`,
|
|
348
364
|
});
|
|
349
365
|
}
|
|
350
366
|
return {
|
|
351
|
-
id:
|
|
367
|
+
id: routeSegment(fn.name),
|
|
352
368
|
title: fn.displayName ?? `${fn.name}()`,
|
|
353
369
|
content,
|
|
354
370
|
};
|
|
355
371
|
}
|
|
356
372
|
|
|
357
373
|
/**
|
|
358
|
-
*
|
|
374
|
+
* What `astryx docs <route>` prints for one enum doc.
|
|
359
375
|
* @param {any} doc
|
|
360
376
|
*/
|
|
361
377
|
function enumSection(doc) {
|
|
362
378
|
return {
|
|
363
|
-
id:
|
|
379
|
+
id: routeSegment(doc.name),
|
|
364
380
|
title: doc.displayName ?? doc.name,
|
|
365
381
|
content: [
|
|
366
382
|
{type: 'prose', text: doc.description},
|
|
@@ -379,79 +395,33 @@ function enumSection(doc) {
|
|
|
379
395
|
}
|
|
380
396
|
|
|
381
397
|
/**
|
|
382
|
-
*
|
|
383
|
-
*
|
|
384
|
-
* @param {any
|
|
385
|
-
* @
|
|
386
|
-
|
|
387
|
-
function cliDocsInOrder(docs) {
|
|
388
|
-
return docs
|
|
389
|
-
.filter(doc => CLI_DOC_NAMESPACES[doc.namespace]?.topic === 'cli')
|
|
390
|
-
.sort(
|
|
391
|
-
(a, b) =>
|
|
392
|
-
KIND_ORDER.indexOf(a.type) - KIND_ORDER.indexOf(b.type) ||
|
|
393
|
-
(a.name < b.name ? -1 : a.name > b.name ? 1 : 0),
|
|
394
|
-
);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* The `cli` topic: one section per doc whose namespace is `cli/…`.
|
|
399
|
-
* @param {any[]} docs every loaded CLI doc; the ones in other namespaces are
|
|
400
|
-
* left out
|
|
401
|
-
* @returns {import('../../authoring/doctypes/reference/type').ReferenceDoc}
|
|
402
|
-
*/
|
|
403
|
-
export function buildCliReferenceDoc(docs) {
|
|
404
|
-
const ordered = cliDocsInOrder(docs);
|
|
405
|
-
const index = {
|
|
406
|
-
functions: new Map(
|
|
407
|
-
ordered.filter(d => d.type === 'function').map(d => [d.name, d]),
|
|
408
|
-
),
|
|
409
|
-
commands: new Set(
|
|
410
|
-
ordered.filter(d => d.type === 'command').map(d => d.name),
|
|
411
|
-
),
|
|
412
|
-
};
|
|
413
|
-
return /** @type {any} */ ({
|
|
414
|
-
name: 'cli',
|
|
415
|
-
title: 'CLI Reference',
|
|
416
|
-
category: 'guide',
|
|
417
|
-
description:
|
|
418
|
-
'Every command and API function of the CLI, with the JSON output envelope, error codes, and response types, read from the docs the CLI ships.',
|
|
419
|
-
sections: ordered.map(doc =>
|
|
420
|
-
doc.type === 'command'
|
|
421
|
-
? commandSection(doc, index)
|
|
422
|
-
: doc.type === 'function'
|
|
423
|
-
? functionSection(doc, index)
|
|
424
|
-
: doc.type === 'enum'
|
|
425
|
-
? enumSection(doc)
|
|
426
|
-
: {...selfDocSection(doc), id: cliSectionKey(doc)},
|
|
427
|
-
),
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* The `cli` topic from every CLI doc that loads. One that fails is left out
|
|
433
|
-
* here and reported by {@link auditCliSelfDocs}.
|
|
434
|
-
* @returns {Promise<import('../../authoring/doctypes/reference/type').ReferenceDoc>}
|
|
398
|
+
* What `astryx docs <route>` prints for one CLI typed doc: its title and the
|
|
399
|
+
* blocks of its content, with cross-links to the routes the tree gave.
|
|
400
|
+
* @param {any} doc
|
|
401
|
+
* @param {CliDocIndex} index
|
|
402
|
+
* @returns {{id: string, title: string, content: any[]}}
|
|
435
403
|
*/
|
|
436
|
-
export
|
|
437
|
-
|
|
438
|
-
|
|
404
|
+
export function cliDocSection(doc, index) {
|
|
405
|
+
if (doc.type === 'command') return commandSection(doc, index);
|
|
406
|
+
if (doc.type === 'function') return functionSection(doc, index);
|
|
407
|
+
if (doc.type === 'enum') return enumSection(doc);
|
|
408
|
+
return {...selfDocSection(doc), id: routeSegment(doc.name)};
|
|
439
409
|
}
|
|
440
410
|
|
|
441
411
|
/**
|
|
442
|
-
* What stands between a CLI doc and a reader: a missing namespace, one
|
|
443
|
-
*
|
|
444
|
-
*
|
|
412
|
+
* What stands between a CLI doc and a reader: a missing namespace, one nothing
|
|
413
|
+
* reads, one that disagrees with the authoring topic's list, a doc that fails
|
|
414
|
+
* to load, and a tree leaf too large for one read. Whether the tree gives
|
|
415
|
+
* every `cli/...` doc a route is the docs-tree check's job.
|
|
445
416
|
* @param {{root?: string, sources?: string[], budget?: number, authoringSources?: string[]}} [options]
|
|
446
417
|
* @returns {Promise<{
|
|
447
418
|
* docs: number,
|
|
448
|
-
*
|
|
419
|
+
* tree: number,
|
|
449
420
|
* authoring: number,
|
|
450
421
|
* missing: string[],
|
|
451
422
|
* unknown: {source: string, namespace: string}[],
|
|
452
423
|
* misfiled: {source: string, message: string}[],
|
|
453
424
|
* failed: {source: string, error: string}[],
|
|
454
|
-
* keyProblems: string[],
|
|
455
425
|
* oversized: {key: string, title: string, bytes: number}[],
|
|
456
426
|
* }>}
|
|
457
427
|
*/
|
|
@@ -472,6 +442,8 @@ export async function auditCliSelfDocs({
|
|
|
472
442
|
const unknown = [];
|
|
473
443
|
/** @type {{source: string, message: string}[]} */
|
|
474
444
|
const misfiled = [];
|
|
445
|
+
/** @type {any[]} */
|
|
446
|
+
const treeDocs = [];
|
|
475
447
|
let authoring = 0;
|
|
476
448
|
for (const {source, doc} of loaded) {
|
|
477
449
|
const namespace = doc.namespace;
|
|
@@ -484,7 +456,7 @@ export async function auditCliSelfDocs({
|
|
|
484
456
|
continue;
|
|
485
457
|
}
|
|
486
458
|
const inAuthoring = listed.has(source);
|
|
487
|
-
if (namespace === 'authoring') {
|
|
459
|
+
if (CLI_DOC_NAMESPACES[namespace].reader === 'authoring') {
|
|
488
460
|
if (inAuthoring) authoring++;
|
|
489
461
|
else {
|
|
490
462
|
misfiled.push({
|
|
@@ -497,18 +469,22 @@ export async function auditCliSelfDocs({
|
|
|
497
469
|
source,
|
|
498
470
|
message: `${source} is read in \`astryx docs authoring\`, but its namespace is "${namespace}"`,
|
|
499
471
|
});
|
|
472
|
+
} else {
|
|
473
|
+
treeDocs.push(doc);
|
|
500
474
|
}
|
|
501
475
|
}
|
|
502
|
-
const
|
|
476
|
+
const index = cliDocIndex(loaded.map(entry => entry.doc));
|
|
503
477
|
return {
|
|
504
478
|
docs: loaded.length,
|
|
505
|
-
|
|
479
|
+
tree: treeDocs.length,
|
|
506
480
|
authoring,
|
|
507
481
|
missing,
|
|
508
482
|
unknown,
|
|
509
483
|
misfiled,
|
|
510
484
|
failed,
|
|
511
|
-
|
|
512
|
-
|
|
485
|
+
oversized: oversizedDocSections(
|
|
486
|
+
treeDocs.map(doc => cliDocSection(doc, index)),
|
|
487
|
+
budget,
|
|
488
|
+
),
|
|
513
489
|
};
|
|
514
490
|
}
|