@astryxdesign/cli 0.6.3-canary.e59d786 → 0.6.3-canary.e7723cd
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 +19 -17
- 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 +209 -28
- package/api/docs/_adapter.mjs +667 -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 +35 -15
- package/api/docs/docs.mjs +44 -8
- package/api/docs/docs.test.mjs +158 -4
- package/api/docs/docs.type.d.mts +165 -2
- package/api/docs/docs.type.mjs +101 -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 +547 -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/doctor/doctor.d.mts +30 -2
- package/api/doctor/doctor.mjs +147 -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 +125 -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 +26 -1
- package/api/search/search.doc.mjs +4 -3
- package/api/search/search.mjs +308 -29
- 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/template-integration.test.mjs +1022 -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/codemods/transforms/next/__tests__/migrate-native-picker-to-presentation.test.mjs +63 -0
- package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +4 -0
- package/assets/codemods/transforms/next/index.mjs +8 -0
- package/assets/codemods/transforms/next/migrate-native-picker-to-presentation.mjs +148 -0
- package/assets/docs/getting-started.doc.mjs +2 -2
- package/assets/docs/principles.doc.mjs +6 -6
- package/assets/docs/styling-libraries.doc.mjs +2 -2
- package/assets/docs/styling.doc.mjs +4 -4
- package/assets/docs/theme.doc.mjs +3 -3
- 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/templates/blocks/components/DateInput/DateInputDateRange.tsx +1 -1
- package/assets/templates/blocks/components/TimeInput/TimeInputConstrained.tsx +1 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +71 -141
- package/authoring/doctypes/_schema.mjs +29 -2
- 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 +1 -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 +6 -4
- package/authoring/doctypes/reference/type.ts +10 -8
- 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 +11 -45
- package/clients/cli/commands/build.mjs +5 -2
- 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 +182 -68
- 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/commands/text-json-parity.test.mjs +719 -0
- package/clients/cli/commands/theme-targets.behavior.test.mjs +4 -3
- package/clients/cli/commands/upgrade.mjs +26 -7
- package/clients/cli/formatters/index.mjs +2 -0
- package/clients/cli/formatters/index.test.mjs +6 -0
- package/clients/cli/index.mjs +8 -0
- package/clients/cli/lib/manifest.mjs +9 -2
- package/foundation/agent-docs/agent-docs.mjs +1 -0
- package/foundation/agent-docs/agent-docs.test.mjs +10 -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.test.mjs +20 -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 +105 -8
- package/foundation/discovery/docs-discovery.mjs +183 -18
- package/foundation/discovery/docs-discovery.test.mjs +63 -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 +3 -2
- package/foundation/doc-compiler/lenses.mjs +2 -1
- package/foundation/doc-compiler/links.d.mts +135 -0
- package/foundation/doc-compiler/links.mjs +253 -0
- package/foundation/doc-compiler/links.test.mjs +139 -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 +109 -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 +18 -9
- 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
|
@@ -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
|
}
|