@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
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* @typedef {object} DocsTopicRecord A doc file discovered under a docs root.
|
|
6
6
|
* @property {string} name
|
|
7
7
|
* @property {string} package owner package
|
|
8
|
+
* @property {string} [providerId] the owner's ProviderId, when it differs from
|
|
9
|
+
* the package name
|
|
8
10
|
* @property {string} path absolute path to the doc file
|
|
9
11
|
* @property {string} [title]
|
|
10
12
|
* @property {string} [description]
|
|
@@ -16,13 +18,21 @@
|
|
|
16
18
|
* @typedef {object} DocsTopicEntry A resolved topic in the catalog.
|
|
17
19
|
* @property {string} name
|
|
18
20
|
* @property {string} package owner package
|
|
21
|
+
* @property {string} [providerId] the owner's ProviderId; the package name when
|
|
22
|
+
* absent. Links in the topic resolve against it.
|
|
19
23
|
* @property {string} path absolute path to the doc file
|
|
20
24
|
* @property {string} [title]
|
|
21
25
|
* @property {string} [description]
|
|
22
26
|
* @property {string|null} [category]
|
|
23
27
|
* @property {string} [replaces] the topic this one took the place of
|
|
24
|
-
* @property {Array<{package: string, path: string}>} extensions
|
|
25
|
-
* merge onto the base doc, in the order their integrations were
|
|
28
|
+
* @property {Array<{package: string, path: string, providerId?: string}>} extensions
|
|
29
|
+
* overlays to merge onto the base doc, in the order their integrations were
|
|
30
|
+
* configured; each section an extension adds resolves its links against the
|
|
31
|
+
* extension's provider id (its package name when absent)
|
|
32
|
+
* @property {string} [parent] the route of the namespace a tree guide sits in
|
|
33
|
+
* @property {string} [route] a tree guide's route
|
|
34
|
+
* @property {boolean} [tree] a guide that only the docs tree reads, by its
|
|
35
|
+
* route; never a flat topic
|
|
26
36
|
*/
|
|
27
37
|
/**
|
|
28
38
|
* Discover the CLI's own topics.
|
|
@@ -48,9 +58,19 @@ export function loadTopicModule(file: string): Promise<unknown>;
|
|
|
48
58
|
* where the file that needs fixing can be named.
|
|
49
59
|
*
|
|
50
60
|
* @param {any} doc a parsed doc
|
|
61
|
+
* @param {{placement?: boolean}} [options] `placement`: the doc is a guide the
|
|
62
|
+
* docs tree places, so its `placement` field is read, not rejected
|
|
51
63
|
* @returns {string[]} problems, each already pointed at a place in the doc
|
|
52
64
|
*/
|
|
53
|
-
export function problemsInTopic(doc: any
|
|
65
|
+
export function problemsInTopic(doc: any, { placement }?: {
|
|
66
|
+
placement?: boolean;
|
|
67
|
+
}): string[];
|
|
68
|
+
/**
|
|
69
|
+
* The fields the docs tree reads from a namespace doc an integration ships.
|
|
70
|
+
* @param {any} doc
|
|
71
|
+
* @returns {string[]}
|
|
72
|
+
*/
|
|
73
|
+
export function problemsInNamespace(doc: any): string[];
|
|
54
74
|
/**
|
|
55
75
|
* Discover the topics contributed by a single loaded integration. Mirrors
|
|
56
76
|
* `discoverIntegrationComponents`: walk the resolved root, take every
|
|
@@ -58,18 +78,25 @@ export function problemsInTopic(doc: any): string[];
|
|
|
58
78
|
* discovery this loads each doc, because a topic's name and its relationship
|
|
59
79
|
* to an existing topic are fields inside the file.
|
|
60
80
|
*
|
|
81
|
+
* A namespace doc and a guide with `placement` go to the docs tree instead of
|
|
82
|
+
* the topic list (spec:AST-046): they come back in `namespaces` and `guides`,
|
|
83
|
+
* named by the integration's provider id.
|
|
84
|
+
*
|
|
61
85
|
* Errors are returned, not thrown: one unusable doc is reported as an issue
|
|
62
86
|
* against its package while the rest of the CLI keeps working.
|
|
63
87
|
*
|
|
64
|
-
* @param {{name: string, docs?: string}} integration a loaded integration
|
|
65
|
-
* @returns {Promise<{records: DocsTopicRecord[], errors: Error[]}>}
|
|
88
|
+
* @param {{name: string, docs?: string, providerId?: string}} integration a loaded integration
|
|
89
|
+
* @returns {Promise<{records: DocsTopicRecord[], errors: Error[], namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}>}
|
|
66
90
|
*/
|
|
67
91
|
export function discoverIntegrationDocs(integration: {
|
|
68
92
|
name: string;
|
|
69
93
|
docs?: string;
|
|
94
|
+
providerId?: string;
|
|
70
95
|
}): Promise<{
|
|
71
96
|
records: DocsTopicRecord[];
|
|
72
97
|
errors: Error[];
|
|
98
|
+
namespaces: import("../doc-compiler/tree.mjs").TreeNamespaceInput[];
|
|
99
|
+
guides: import("../doc-compiler/tree.mjs").TreeDocInput[];
|
|
73
100
|
}>;
|
|
74
101
|
/**
|
|
75
102
|
* Merge an extension onto a base topic: a section with a stable `id` replaces
|
|
@@ -97,7 +124,10 @@ export { withSourceTitle };
|
|
|
97
124
|
export const BUILTIN_DOCS_PACKAGE: import("../../authoring/index.js").ProviderId;
|
|
98
125
|
/** Blocks that are valid authoring but require the compiled graph renderer. */
|
|
99
126
|
export const GRAPH_BLOCK_TYPES: Set<string>;
|
|
100
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* Doc fields only the docs tree reads. A flat topic that sets one fails to
|
|
129
|
+
* load; a guide the tree places may set `placement` (spec:AST-046).
|
|
130
|
+
*/
|
|
101
131
|
export const GRAPH_ONLY_FIELDS: string[];
|
|
102
132
|
/**
|
|
103
133
|
* Every topic a project can read, and the relationships between them.
|
|
@@ -114,6 +144,40 @@ export class DocsCatalog {
|
|
|
114
144
|
* @returns {DocsCatalog}
|
|
115
145
|
*/
|
|
116
146
|
static fromBuiltins(builtins?: Record<string, string>): DocsCatalog;
|
|
147
|
+
/**
|
|
148
|
+
* Record a doc file a package ships that did not load. Its package's docs
|
|
149
|
+
* are withdrawn; readers name the package so an author knows where to look.
|
|
150
|
+
* @param {{package: string, message: string}} issue
|
|
151
|
+
*/
|
|
152
|
+
addIssue(issue: {
|
|
153
|
+
package: string;
|
|
154
|
+
message: string;
|
|
155
|
+
}): void;
|
|
156
|
+
/**
|
|
157
|
+
* The doc files that did not load, by package.
|
|
158
|
+
* @returns {ReadonlyArray<{package: string, message: string}>}
|
|
159
|
+
*/
|
|
160
|
+
get issues(): ReadonlyArray<{
|
|
161
|
+
package: string;
|
|
162
|
+
message: string;
|
|
163
|
+
}>;
|
|
164
|
+
/**
|
|
165
|
+
* Add the namespace docs and placed guides one integration ships to the
|
|
166
|
+
* docs tree (spec:AST-046).
|
|
167
|
+
* @param {{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}} inputs
|
|
168
|
+
*/
|
|
169
|
+
addTreeInputs(inputs: {
|
|
170
|
+
namespaces: import("../doc-compiler/tree.mjs").TreeNamespaceInput[];
|
|
171
|
+
guides: import("../doc-compiler/tree.mjs").TreeDocInput[];
|
|
172
|
+
}): void;
|
|
173
|
+
/**
|
|
174
|
+
* What the integrations add to the docs tree, in configured order.
|
|
175
|
+
* @returns {ReadonlyArray<{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}>}
|
|
176
|
+
*/
|
|
177
|
+
get treeInputs(): ReadonlyArray<{
|
|
178
|
+
namespaces: import("../doc-compiler/tree.mjs").TreeNamespaceInput[];
|
|
179
|
+
guides: import("../doc-compiler/tree.mjs").TreeDocInput[];
|
|
180
|
+
}>;
|
|
117
181
|
/**
|
|
118
182
|
* Add one integration-contributed doc, honoring what it declares. Returns
|
|
119
183
|
* the issue it caused, or null when it applied cleanly — the caller owns
|
|
@@ -123,6 +187,14 @@ export class DocsCatalog {
|
|
|
123
187
|
* @returns {import('../integrations/issue').AstryxIntegrationIssue | null}
|
|
124
188
|
*/
|
|
125
189
|
add(record: DocsTopicRecord): import("../integrations/issue").AstryxIntegrationIssue | null;
|
|
190
|
+
/**
|
|
191
|
+
* Every other name a topic answers to, lowercased: the names of the topics
|
|
192
|
+
* it replaced, directly or through a chain of replacements. `resolve` finds
|
|
193
|
+
* the topic by each of them.
|
|
194
|
+
* @param {DocsTopicEntry} entry
|
|
195
|
+
* @returns {string[]}
|
|
196
|
+
*/
|
|
197
|
+
aliasesOf(entry: DocsTopicEntry): string[];
|
|
126
198
|
/**
|
|
127
199
|
* Look a topic up by name, case-insensitively, following the alias a renamed
|
|
128
200
|
* replacement left behind.
|
|
@@ -145,6 +217,11 @@ export type DocsTopicRecord = {
|
|
|
145
217
|
* owner package
|
|
146
218
|
*/
|
|
147
219
|
package: string;
|
|
220
|
+
/**
|
|
221
|
+
* the owner's ProviderId, when it differs from
|
|
222
|
+
* the package name
|
|
223
|
+
*/
|
|
224
|
+
providerId?: string | undefined;
|
|
148
225
|
/**
|
|
149
226
|
* absolute path to the doc file
|
|
150
227
|
*/
|
|
@@ -170,6 +247,11 @@ export type DocsTopicEntry = {
|
|
|
170
247
|
* owner package
|
|
171
248
|
*/
|
|
172
249
|
package: string;
|
|
250
|
+
/**
|
|
251
|
+
* the owner's ProviderId; the package name when
|
|
252
|
+
* absent. Links in the topic resolve against it.
|
|
253
|
+
*/
|
|
254
|
+
providerId?: string | undefined;
|
|
173
255
|
/**
|
|
174
256
|
* absolute path to the doc file
|
|
175
257
|
*/
|
|
@@ -182,12 +264,27 @@ export type DocsTopicEntry = {
|
|
|
182
264
|
*/
|
|
183
265
|
replaces?: string | undefined;
|
|
184
266
|
/**
|
|
185
|
-
*
|
|
186
|
-
*
|
|
267
|
+
* overlays to merge onto the base doc, in the order their integrations were
|
|
268
|
+
* configured; each section an extension adds resolves its links against the
|
|
269
|
+
* extension's provider id (its package name when absent)
|
|
187
270
|
*/
|
|
188
271
|
extensions: Array<{
|
|
189
272
|
package: string;
|
|
190
273
|
path: string;
|
|
274
|
+
providerId?: string;
|
|
191
275
|
}>;
|
|
276
|
+
/**
|
|
277
|
+
* the route of the namespace a tree guide sits in
|
|
278
|
+
*/
|
|
279
|
+
parent?: string | undefined;
|
|
280
|
+
/**
|
|
281
|
+
* a tree guide's route
|
|
282
|
+
*/
|
|
283
|
+
route?: string | undefined;
|
|
284
|
+
/**
|
|
285
|
+
* a guide that only the docs tree reads, by its
|
|
286
|
+
* route; never a flat topic
|
|
287
|
+
*/
|
|
288
|
+
tree?: boolean | undefined;
|
|
192
289
|
};
|
|
193
290
|
import { withSourceTitle } from './docs-section-key.mjs';
|
|
@@ -37,7 +37,7 @@ import {CLI_PROVIDER_ID} from '../identity/providers.mjs';
|
|
|
37
37
|
import {parseReadableDoc} from '../doc-compiler/parse-readable.mjs';
|
|
38
38
|
import {
|
|
39
39
|
sectionKey,
|
|
40
|
-
|
|
40
|
+
sectionKeyErrors,
|
|
41
41
|
sourceTitle,
|
|
42
42
|
withSourceTitle,
|
|
43
43
|
} from './docs-section-key.mjs';
|
|
@@ -71,6 +71,8 @@ const TOPIC_NAME_RE = /^[\w-]+$/;
|
|
|
71
71
|
* @typedef {object} DocsTopicRecord A doc file discovered under a docs root.
|
|
72
72
|
* @property {string} name
|
|
73
73
|
* @property {string} package owner package
|
|
74
|
+
* @property {string} [providerId] the owner's ProviderId, when it differs from
|
|
75
|
+
* the package name
|
|
74
76
|
* @property {string} path absolute path to the doc file
|
|
75
77
|
* @property {string} [title]
|
|
76
78
|
* @property {string} [description]
|
|
@@ -83,13 +85,21 @@ const TOPIC_NAME_RE = /^[\w-]+$/;
|
|
|
83
85
|
* @typedef {object} DocsTopicEntry A resolved topic in the catalog.
|
|
84
86
|
* @property {string} name
|
|
85
87
|
* @property {string} package owner package
|
|
88
|
+
* @property {string} [providerId] the owner's ProviderId; the package name when
|
|
89
|
+
* absent. Links in the topic resolve against it.
|
|
86
90
|
* @property {string} path absolute path to the doc file
|
|
87
91
|
* @property {string} [title]
|
|
88
92
|
* @property {string} [description]
|
|
89
93
|
* @property {string|null} [category]
|
|
90
94
|
* @property {string} [replaces] the topic this one took the place of
|
|
91
|
-
* @property {Array<{package: string, path: string}>} extensions
|
|
92
|
-
* merge onto the base doc, in the order their integrations were
|
|
95
|
+
* @property {Array<{package: string, path: string, providerId?: string}>} extensions
|
|
96
|
+
* overlays to merge onto the base doc, in the order their integrations were
|
|
97
|
+
* configured; each section an extension adds resolves its links against the
|
|
98
|
+
* extension's provider id (its package name when absent)
|
|
99
|
+
* @property {string} [parent] the route of the namespace a tree guide sits in
|
|
100
|
+
* @property {string} [route] a tree guide's route
|
|
101
|
+
* @property {boolean} [tree] a guide that only the docs tree reads, by its
|
|
102
|
+
* route; never a flat topic
|
|
93
103
|
*/
|
|
94
104
|
|
|
95
105
|
/**
|
|
@@ -144,7 +154,10 @@ export const GRAPH_BLOCK_TYPES = new Set([
|
|
|
144
154
|
'reference',
|
|
145
155
|
]);
|
|
146
156
|
|
|
147
|
-
/**
|
|
157
|
+
/**
|
|
158
|
+
* Doc fields only the docs tree reads. A flat topic that sets one fails to
|
|
159
|
+
* load; a guide the tree places may set `placement` (spec:AST-046).
|
|
160
|
+
*/
|
|
148
161
|
export const GRAPH_ONLY_FIELDS = ['placement', 'aliases', 'audience'];
|
|
149
162
|
|
|
150
163
|
/**
|
|
@@ -180,14 +193,16 @@ const SECTION_FIELDS = ['id', 'title', 'category', 'content', 'previewType'];
|
|
|
180
193
|
* where the file that needs fixing can be named.
|
|
181
194
|
*
|
|
182
195
|
* @param {any} doc a parsed doc
|
|
196
|
+
* @param {{placement?: boolean}} [options] `placement`: the doc is a guide the
|
|
197
|
+
* docs tree places, so its `placement` field is read, not rejected
|
|
183
198
|
* @returns {string[]} problems, each already pointed at a place in the doc
|
|
184
199
|
*/
|
|
185
|
-
export function problemsInTopic(doc) {
|
|
186
|
-
// A namespace doc is valid authoring that only the docs
|
|
200
|
+
export function problemsInTopic(doc, {placement = false} = {}) {
|
|
201
|
+
// A namespace doc is valid authoring that only the docs tree reads. Said
|
|
187
202
|
// plainly, instead of as the topic fields it does not have.
|
|
188
203
|
if (doc?.type === 'namespace') {
|
|
189
204
|
return [
|
|
190
|
-
`"${doc.name}" is a namespace doc
|
|
205
|
+
`"${doc.name}" 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.`,
|
|
191
206
|
];
|
|
192
207
|
}
|
|
193
208
|
/** @type {string[]} */
|
|
@@ -203,6 +218,8 @@ export function problemsInTopic(doc) {
|
|
|
203
218
|
);
|
|
204
219
|
}
|
|
205
220
|
for (const field of GRAPH_ONLY_FIELDS) {
|
|
221
|
+
// A guide the docs tree places carries `placement`; the tree reads it.
|
|
222
|
+
if (field === 'placement' && placement) continue;
|
|
206
223
|
if (doc?.[field] != null) {
|
|
207
224
|
problems.push(
|
|
208
225
|
`${field}: requires the compiled graph reader and is not supported by legacy topic readers`,
|
|
@@ -312,9 +329,39 @@ export function problemsInTopic(doc) {
|
|
|
312
329
|
);
|
|
313
330
|
},
|
|
314
331
|
);
|
|
315
|
-
//
|
|
316
|
-
//
|
|
317
|
-
|
|
332
|
+
// Explicit authored IDs are a new opt-in contract and remain strict. Topics
|
|
333
|
+
// that relied on 0.6.x title-only sections keep loading; the compiler assigns
|
|
334
|
+
// deterministic fallback/suffixed keys for the additive index API.
|
|
335
|
+
problems.push(...sectionKeyErrors(doc.sections));
|
|
336
|
+
return problems;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* The fields the docs tree reads from a namespace doc an integration ships.
|
|
341
|
+
* @param {any} doc
|
|
342
|
+
* @returns {string[]}
|
|
343
|
+
*/
|
|
344
|
+
export function problemsInNamespace(doc) {
|
|
345
|
+
/** @type {string[]} */
|
|
346
|
+
const problems = [];
|
|
347
|
+
for (const field of ['name', 'title', 'summary']) {
|
|
348
|
+
if (typeof doc?.[field] !== 'string' || doc[field] === '') {
|
|
349
|
+
problems.push(`${field}: expected a non-empty string`);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const slots = doc?.slots;
|
|
353
|
+
if (slots == null || typeof slots !== 'object' || Object.keys(slots).length === 0) {
|
|
354
|
+
problems.push('slots: expected at least one slot');
|
|
355
|
+
return problems;
|
|
356
|
+
}
|
|
357
|
+
for (const [name, slot] of Object.entries(slots)) {
|
|
358
|
+
if (typeof slot?.title !== 'string' || slot.title === '') {
|
|
359
|
+
problems.push(`slots.${name}.title: expected a non-empty string`);
|
|
360
|
+
}
|
|
361
|
+
if (!Array.isArray(slot?.accepts?.kinds) || slot.accepts.kinds.length === 0) {
|
|
362
|
+
problems.push(`slots.${name}.accepts.kinds: expected at least one kind`);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
318
365
|
return problems;
|
|
319
366
|
}
|
|
320
367
|
|
|
@@ -325,11 +372,15 @@ export function problemsInTopic(doc) {
|
|
|
325
372
|
* discovery this loads each doc, because a topic's name and its relationship
|
|
326
373
|
* to an existing topic are fields inside the file.
|
|
327
374
|
*
|
|
375
|
+
* A namespace doc and a guide with `placement` go to the docs tree instead of
|
|
376
|
+
* the topic list (spec:AST-046): they come back in `namespaces` and `guides`,
|
|
377
|
+
* named by the integration's provider id.
|
|
378
|
+
*
|
|
328
379
|
* Errors are returned, not thrown: one unusable doc is reported as an issue
|
|
329
380
|
* against its package while the rest of the CLI keeps working.
|
|
330
381
|
*
|
|
331
|
-
* @param {{name: string, docs?: string}} integration a loaded integration
|
|
332
|
-
* @returns {Promise<{records: DocsTopicRecord[], errors: Error[]}>}
|
|
382
|
+
* @param {{name: string, docs?: string, providerId?: string}} integration a loaded integration
|
|
383
|
+
* @returns {Promise<{records: DocsTopicRecord[], errors: Error[], namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}>}
|
|
333
384
|
*/
|
|
334
385
|
export async function discoverIntegrationDocs(integration) {
|
|
335
386
|
const docsDir = integration?.docs;
|
|
@@ -337,7 +388,14 @@ export async function discoverIntegrationDocs(integration) {
|
|
|
337
388
|
const records = [];
|
|
338
389
|
/** @type {Error[]} */
|
|
339
390
|
const errors = [];
|
|
340
|
-
|
|
391
|
+
/** @type {import('../doc-compiler/tree.mjs').TreeNamespaceInput[]} */
|
|
392
|
+
const namespaces = [];
|
|
393
|
+
/** @type {import('../doc-compiler/tree.mjs').TreeDocInput[]} */
|
|
394
|
+
const guides = [];
|
|
395
|
+
if (!docsDir || !fs.existsSync(docsDir)) {
|
|
396
|
+
return {records, errors, namespaces, guides};
|
|
397
|
+
}
|
|
398
|
+
const providerId = integration.providerId ?? integration.name;
|
|
341
399
|
|
|
342
400
|
/** @type {string[]} */
|
|
343
401
|
const files = [];
|
|
@@ -372,11 +430,34 @@ export async function discoverIntegrationDocs(integration) {
|
|
|
372
430
|
);
|
|
373
431
|
continue;
|
|
374
432
|
}
|
|
375
|
-
const
|
|
433
|
+
const relative = path.relative(docsDir, file);
|
|
434
|
+
const source = `${integration.name}/${relative.split(path.sep).join('/')}`;
|
|
435
|
+
if (/** @type {any} */ (doc)?.type === 'namespace') {
|
|
436
|
+
const problems = problemsInNamespace(doc);
|
|
437
|
+
if (problems.length > 0) {
|
|
438
|
+
errors.push(
|
|
439
|
+
new Error(
|
|
440
|
+
`${relative} is not a usable namespace doc:\n${problems
|
|
441
|
+
.map(problem => ` ${problem}`)
|
|
442
|
+
.join('\n')}`,
|
|
443
|
+
),
|
|
444
|
+
);
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
namespaces.push({
|
|
448
|
+
provider: integration.name,
|
|
449
|
+
providerId,
|
|
450
|
+
source,
|
|
451
|
+
doc: /** @type {any} */ (doc),
|
|
452
|
+
});
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
const placed = /** @type {any} */ (doc)?.placement != null;
|
|
456
|
+
const problems = problemsInTopic(doc, {placement: placed});
|
|
376
457
|
if (problems.length > 0) {
|
|
377
458
|
errors.push(
|
|
378
459
|
new Error(
|
|
379
|
-
`${
|
|
460
|
+
`${relative} is not a usable topic:\n${problems
|
|
380
461
|
.map(problem => ` ${problem}`)
|
|
381
462
|
.join('\n')}`,
|
|
382
463
|
),
|
|
@@ -397,6 +478,29 @@ export async function discoverIntegrationDocs(integration) {
|
|
|
397
478
|
continue;
|
|
398
479
|
}
|
|
399
480
|
seen.set(topicKey, path.relative(docsDir, file));
|
|
481
|
+
if (placed) {
|
|
482
|
+
if (parsed.replaces != null || parsed.extends != null) {
|
|
483
|
+
errors.push(
|
|
484
|
+
new Error(
|
|
485
|
+
`${relative} is placed in the docs tree and also declares \`${parsed.replaces != null ? 'replaces' : 'extends'}\`. A placed guide has its own route; only a flat topic takes over or extends another.`,
|
|
486
|
+
),
|
|
487
|
+
);
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
guides.push({
|
|
491
|
+
provider: integration.name,
|
|
492
|
+
providerId,
|
|
493
|
+
source,
|
|
494
|
+
kind: 'generic',
|
|
495
|
+
name: parsed.name,
|
|
496
|
+
title: parsed.title,
|
|
497
|
+
summary: parsed.description,
|
|
498
|
+
group: null,
|
|
499
|
+
placement: parsed.placement,
|
|
500
|
+
ref: {topicFile: file},
|
|
501
|
+
});
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
400
504
|
if (parsed.replaces != null && parsed.extends != null) {
|
|
401
505
|
errors.push(
|
|
402
506
|
new Error(
|
|
@@ -414,10 +518,11 @@ export async function discoverIntegrationDocs(integration) {
|
|
|
414
518
|
category: parsed.category ?? null,
|
|
415
519
|
replaces: parsed.replaces,
|
|
416
520
|
extendsTopic: parsed.extends,
|
|
521
|
+
...(providerId === integration.name ? {} : {providerId}),
|
|
417
522
|
});
|
|
418
523
|
}
|
|
419
524
|
|
|
420
|
-
return {records, errors};
|
|
525
|
+
return {records, errors, namespaces, guides};
|
|
421
526
|
}
|
|
422
527
|
|
|
423
528
|
/**
|
|
@@ -487,7 +592,7 @@ function findMergeTarget(sections, section) {
|
|
|
487
592
|
const sameTitle = sections.findIndex(
|
|
488
593
|
candidate => sourceTitle(candidate) === title,
|
|
489
594
|
);
|
|
490
|
-
return sameTitle
|
|
595
|
+
return sameTitle;
|
|
491
596
|
}
|
|
492
597
|
|
|
493
598
|
/**
|
|
@@ -503,6 +608,46 @@ export class DocsCatalog {
|
|
|
503
608
|
#topics = new Map();
|
|
504
609
|
/** @type {Map<string, string>} old topic name → the name that replaced it */
|
|
505
610
|
#aliases = new Map();
|
|
611
|
+
/** @type {Array<{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}>} */
|
|
612
|
+
#treeInputs = [];
|
|
613
|
+
/** @type {Array<{package: string, message: string}>} */
|
|
614
|
+
#issues = [];
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Record a doc file a package ships that did not load. Its package's docs
|
|
618
|
+
* are withdrawn; readers name the package so an author knows where to look.
|
|
619
|
+
* @param {{package: string, message: string}} issue
|
|
620
|
+
*/
|
|
621
|
+
addIssue(issue) {
|
|
622
|
+
this.#issues.push(issue);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* The doc files that did not load, by package.
|
|
627
|
+
* @returns {ReadonlyArray<{package: string, message: string}>}
|
|
628
|
+
*/
|
|
629
|
+
get issues() {
|
|
630
|
+
return this.#issues;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Add the namespace docs and placed guides one integration ships to the
|
|
635
|
+
* docs tree (spec:AST-046).
|
|
636
|
+
* @param {{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}} inputs
|
|
637
|
+
*/
|
|
638
|
+
addTreeInputs(inputs) {
|
|
639
|
+
if (inputs.namespaces.length > 0 || inputs.guides.length > 0) {
|
|
640
|
+
this.#treeInputs.push(inputs);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* What the integrations add to the docs tree, in configured order.
|
|
646
|
+
* @returns {ReadonlyArray<{namespaces: import('../doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../doc-compiler/tree.mjs').TreeDocInput[]}>}
|
|
647
|
+
*/
|
|
648
|
+
get treeInputs() {
|
|
649
|
+
return this.#treeInputs;
|
|
650
|
+
}
|
|
506
651
|
|
|
507
652
|
/**
|
|
508
653
|
* Seed a catalog with the CLI's own topics.
|
|
@@ -540,7 +685,11 @@ export class DocsCatalog {
|
|
|
540
685
|
message: `"${record.name}" extends "${record.extendsTopic}", which is not a topic in this project.`,
|
|
541
686
|
};
|
|
542
687
|
}
|
|
543
|
-
target.extensions.push({
|
|
688
|
+
target.extensions.push({
|
|
689
|
+
package: record.package,
|
|
690
|
+
path: record.path,
|
|
691
|
+
...(record.providerId ? {providerId: record.providerId} : {}),
|
|
692
|
+
});
|
|
544
693
|
return null;
|
|
545
694
|
}
|
|
546
695
|
|
|
@@ -578,6 +727,7 @@ export class DocsCatalog {
|
|
|
578
727
|
description: record.description,
|
|
579
728
|
category: record.category,
|
|
580
729
|
replaces: replaced,
|
|
730
|
+
...(record.providerId ? {providerId: record.providerId} : {}),
|
|
581
731
|
// Extensions were authored against the content that just went away.
|
|
582
732
|
extensions: [],
|
|
583
733
|
});
|
|
@@ -607,11 +757,26 @@ export class DocsCatalog {
|
|
|
607
757
|
title: record.title,
|
|
608
758
|
description: record.description,
|
|
609
759
|
category: record.category,
|
|
760
|
+
...(record.providerId ? {providerId: record.providerId} : {}),
|
|
610
761
|
extensions: [],
|
|
611
762
|
});
|
|
612
763
|
return null;
|
|
613
764
|
}
|
|
614
765
|
|
|
766
|
+
/**
|
|
767
|
+
* Every other name a topic answers to, lowercased: the names of the topics
|
|
768
|
+
* it replaced, directly or through a chain of replacements. `resolve` finds
|
|
769
|
+
* the topic by each of them.
|
|
770
|
+
* @param {DocsTopicEntry} entry
|
|
771
|
+
* @returns {string[]}
|
|
772
|
+
*/
|
|
773
|
+
aliasesOf(entry) {
|
|
774
|
+
const key = entry.name.toLowerCase();
|
|
775
|
+
return [...this.#aliases]
|
|
776
|
+
.filter(([, to]) => to === key)
|
|
777
|
+
.map(([from]) => from);
|
|
778
|
+
}
|
|
779
|
+
|
|
615
780
|
/**
|
|
616
781
|
* Look a topic up by name, case-insensitively, following the alias a renamed
|
|
617
782
|
* replacement left behind.
|