@astryxdesign/cli 0.6.3-canary.1f30d4e → 0.6.3-canary.1ffe66d
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 +20 -3
- 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 +146 -7
- package/api/doctor/doctor.test.mjs +89 -1
- 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/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/authoring/debug/parse.d.mts +3 -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/namespace/namespace.doc.mjs +5 -9
- package/authoring/doctypes/reference/reference.doc.mjs +3 -3
- package/authoring/doctypes/reference/type.ts +3 -0
- 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/integration/type.ts +1 -1
- package/clients/cli/commands/build-theme.mjs +1 -1
- 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 +175 -18
- package/clients/cli/commands/docs.test.mjs +114 -7
- 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 +2 -1
- 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 +17 -7
- 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 +177 -13
- package/foundation/discovery/docs-discovery.test.mjs +56 -17
- 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 +9 -2
- package/foundation/discovery/docs-section-key.mjs +15 -1
- 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 +52 -6
- 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
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Unit coverage for the integration-template conflict release boundary.
|
|
5
|
+
* @input CLI versions and explicit warning-only or expanded projections.
|
|
6
|
+
* @output Boolean activation assertions for the expanded conflict schema.
|
|
7
|
+
* @position Colocated coverage for the private release gate.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {describe, expect, it} from 'vitest';
|
|
11
|
+
import {expandedTemplateConflictSchemaActive} from './template-conflict-release.mjs';
|
|
12
|
+
|
|
13
|
+
describe('expandedTemplateConflictSchemaActive', () => {
|
|
14
|
+
it.each(['0.6.3', '0.6.4', '0.6.99'])(
|
|
15
|
+
'keeps %s narrow even when the expanded projection is requested',
|
|
16
|
+
version => {
|
|
17
|
+
expect(expandedTemplateConflictSchemaActive(version, 'expanded')).toBe(
|
|
18
|
+
false,
|
|
19
|
+
);
|
|
20
|
+
},
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
it.each(['0.7.0-rc.1', '0.7.0', '0.8.0'])(
|
|
24
|
+
'does not let version %s expand the warning-only projection',
|
|
25
|
+
version => {
|
|
26
|
+
expect(
|
|
27
|
+
expandedTemplateConflictSchemaActive(version, 'warning-only'),
|
|
28
|
+
).toBe(false);
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
it.each(['0.7.0-rc.1', '0.7.0', '0.8.0'])(
|
|
33
|
+
'allows the deliberate expanded projection in %s',
|
|
34
|
+
version => {
|
|
35
|
+
expect(expandedTemplateConflictSchemaActive(version, 'expanded')).toBe(
|
|
36
|
+
true,
|
|
37
|
+
);
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
});
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
} from './compile.mjs';
|
|
26
26
|
import {diagnostic as rawDiagnostic, sortDiagnostics} from './diagnostics.mjs';
|
|
27
27
|
import {collectDocInputs} from './inputs.mjs';
|
|
28
|
-
import {compileDocFile, loadTopicInput} from './read.mjs';
|
|
28
|
+
import {compileDocFile, loadTopicInput, readDocView} from './read.mjs';
|
|
29
29
|
import {packageSource, scrubPaths} from './source.mjs';
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -127,6 +127,50 @@ export async function compileDocs(project, {lang = null} = {}) {
|
|
|
127
127
|
/** @type {Array<CompiledDocNode | CompiledReferenceNode>} */
|
|
128
128
|
const nodes = [];
|
|
129
129
|
for (const input of inputs) {
|
|
130
|
+
// A guide the docs tree places is a reference topic, lowered and linked
|
|
131
|
+
// like one; a namespace doc lowers like any typed descriptor below.
|
|
132
|
+
if (
|
|
133
|
+
input.root === 'tree' &&
|
|
134
|
+
(await treeDocType(input.file)) === 'generic'
|
|
135
|
+
) {
|
|
136
|
+
const entry = {
|
|
137
|
+
name: input.name,
|
|
138
|
+
package: input.owner,
|
|
139
|
+
path: input.file,
|
|
140
|
+
extensions: [],
|
|
141
|
+
tree: true,
|
|
142
|
+
};
|
|
143
|
+
const topic = await loadTopicInput(entry, lang);
|
|
144
|
+
if ('error' in topic.base || 'overlayError' in topic.base) {
|
|
145
|
+
const failure =
|
|
146
|
+
'error' in topic.base ? topic.base.error : topic.base.overlayError;
|
|
147
|
+
diagnostics.push(
|
|
148
|
+
diagnostic('error' in topic.base ? 'load_failed' : 'overlay_failed', {
|
|
149
|
+
provider: input.owner,
|
|
150
|
+
source: input.source,
|
|
151
|
+
message: `${topic.base.file}: ${messageOf(failure)}`,
|
|
152
|
+
}),
|
|
153
|
+
);
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
const linked = await linkReferenceTopic(
|
|
158
|
+
lowerReferenceTopic(topic),
|
|
159
|
+
lowerTarget,
|
|
160
|
+
);
|
|
161
|
+
diagnostics.push(...unresolvedReferences(linked, input));
|
|
162
|
+
nodes.push(linked);
|
|
163
|
+
} catch (error) {
|
|
164
|
+
diagnostics.push(
|
|
165
|
+
diagnostic('invalid_topic', {
|
|
166
|
+
provider: input.owner,
|
|
167
|
+
source: input.source,
|
|
168
|
+
message: messageOf(error),
|
|
169
|
+
}),
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
130
174
|
if (input.root === 'docs') {
|
|
131
175
|
if (input.role !== 'base') continue;
|
|
132
176
|
const lowered = topics.get(input.name.toLowerCase());
|
|
@@ -146,6 +190,7 @@ export async function compileDocs(project, {lang = null} = {}) {
|
|
|
146
190
|
input.root === 'components' || input.root === 'hooks' ? lang : null,
|
|
147
191
|
check: true,
|
|
148
192
|
...(input.root === 'templates' ? {loader: 'template'} : {}),
|
|
193
|
+
...(input.root === 'tree' ? {loader: 'native'} : {}),
|
|
149
194
|
...(input.root === 'themes'
|
|
150
195
|
? {
|
|
151
196
|
label: themeDescriptorLabel(input.file, input.owner),
|
|
@@ -174,6 +219,21 @@ export async function compileDocs(project, {lang = null} = {}) {
|
|
|
174
219
|
};
|
|
175
220
|
}
|
|
176
221
|
|
|
222
|
+
/**
|
|
223
|
+
* The stamped type of a docs-tree file, or null when it cannot be read; the
|
|
224
|
+
* compile that follows reports why.
|
|
225
|
+
* @param {string} file
|
|
226
|
+
* @returns {Promise<string | null>}
|
|
227
|
+
*/
|
|
228
|
+
async function treeDocType(file) {
|
|
229
|
+
try {
|
|
230
|
+
const doc = await readDocView(file, {root: 'tree', loader: 'native'});
|
|
231
|
+
return typeof doc?.type === 'string' ? doc.type : null;
|
|
232
|
+
} catch {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
177
237
|
/**
|
|
178
238
|
* A warning for each token reference in a linked topic that finds no topic or
|
|
179
239
|
* no section.
|
|
@@ -144,19 +144,26 @@ describe('compileDocs over a broken integration', () => {
|
|
|
144
144
|
expect(bundle.nodes.some(node => node.id === 'acme-guide')).toBe(true);
|
|
145
145
|
});
|
|
146
146
|
|
|
147
|
-
it('
|
|
147
|
+
it('withdraws a component doc that fails to load, reports it, and compiles the rest', async () => {
|
|
148
148
|
write(
|
|
149
149
|
'components/AcmeCard.doc.mjs',
|
|
150
150
|
"throw new Error('boom');\nexport default {};\n",
|
|
151
151
|
);
|
|
152
152
|
const project = await Project.load(tmpDir);
|
|
153
153
|
const bundle = await compileDocs(project);
|
|
154
|
-
|
|
155
|
-
//
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
expect(
|
|
154
|
+
// Discovery loads each integration component doc and withdraws one that
|
|
155
|
+
// fails, so the project reports it and the compiler never reads it.
|
|
156
|
+
const issues = (await project.issues()).filter(
|
|
157
|
+
issue => issue.package === '@acme/kit',
|
|
158
|
+
);
|
|
159
|
+
expect(issues.map(issue => issue.code)).toEqual(['invalid_component']);
|
|
160
|
+
expect(issues[0].message).toMatch(/boom/);
|
|
161
|
+
expect(
|
|
162
|
+
bundle.diagnostics.filter(d => d.provider === '@acme/kit'),
|
|
163
|
+
).toEqual([]);
|
|
164
|
+
expect(
|
|
165
|
+
bundle.nodes.some(node => node.id === '@acme/kit:components:AcmeCard'),
|
|
166
|
+
).toBe(false);
|
|
160
167
|
expect(bundle.nodes.some(node => node.kind === 'reference')).toBe(true);
|
|
161
168
|
});
|
|
162
169
|
|
|
@@ -165,9 +172,13 @@ describe('compileDocs over a broken integration', () => {
|
|
|
165
172
|
'components/AcmeCard.doc.mjs',
|
|
166
173
|
"export default {type: 'component', displayName: 'No name'};\n",
|
|
167
174
|
);
|
|
168
|
-
const
|
|
169
|
-
const
|
|
170
|
-
|
|
175
|
+
const project = await Project.load(tmpDir);
|
|
176
|
+
const bundle = await compileDocs(project);
|
|
177
|
+
const issues = (await project.issues()).filter(
|
|
178
|
+
issue => issue.package === '@acme/kit',
|
|
179
|
+
);
|
|
180
|
+
expect(issues.map(issue => issue.code)).toEqual(['invalid_component']);
|
|
181
|
+
expect(issues[0].message).toMatch(/invalid metadata/);
|
|
171
182
|
expect(
|
|
172
183
|
bundle.nodes.some(node => node.id === '@acme/kit:components:AcmeCard'),
|
|
173
184
|
).toBe(false);
|
|
@@ -1,44 +1,6 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* One authored file, as discovery loaded it.
|
|
6
|
-
* @typedef {object} AuthoredFile
|
|
7
|
-
* @property {string} file the file's name, for messages only
|
|
8
|
-
* @property {any} [doc] the parsed doc, when it loaded
|
|
9
|
-
* @property {unknown} [error] why it did not load or parse
|
|
10
|
-
* @property {any} [overlay] the language overlay's export, when one applies
|
|
11
|
-
* @property {unknown} [overlayError] why the overlay did not load
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* @typedef {object} ReferenceTopicInput
|
|
15
|
-
* @property {string} id the topic's name in the catalog
|
|
16
|
-
* @property {string} provider the package that owns the topic
|
|
17
|
-
* @property {string | null} replaces the topic it took the place of
|
|
18
|
-
* @property {string | null} lang the overlay language, or null for authored text
|
|
19
|
-
* @property {AuthoredFile} base
|
|
20
|
-
* @property {Array<AuthoredFile & {provider: string}>} extensions in merge order
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* A token reference after linking: the target section's content, or why it
|
|
24
|
-
* has none.
|
|
25
|
-
* @typedef {{status: 'resolved', topic: string, section: string, previewType?: string, content: any[]}
|
|
26
|
-
* | {status: 'unknown-topic'}
|
|
27
|
-
* | {status: 'unknown-section'}} TokenRefResolution
|
|
28
|
-
*/
|
|
29
|
-
/**
|
|
30
|
-
* @typedef {object} CompiledReferenceNode
|
|
31
|
-
* @property {number} schemaVersion
|
|
32
|
-
* @property {'reference'} kind
|
|
33
|
-
* @property {'lowered' | 'linked'} stage `linked` once every token reference
|
|
34
|
-
* carries its resolution; a lowered node carries none
|
|
35
|
-
* @property {string} id the topic's name in the catalog
|
|
36
|
-
* @property {string | null} lang
|
|
37
|
-
* @property {{provider: string, replaces: string | null, extensions: string[]}} provenance
|
|
38
|
-
* @property {Record<string, string>} sourceTitles section key -> authored title
|
|
39
|
-
* @property {any} doc the topic: authored fields in authored order, every
|
|
40
|
-
* section keyed; a linked node's token references carry `resolved`
|
|
41
|
-
*/
|
|
42
4
|
/**
|
|
43
5
|
* Lower one topic: overlay each file, merge the extensions in order, and stamp
|
|
44
6
|
* every section with its key.
|
|
@@ -148,106 +110,13 @@ export function lowerDoc(input: DocFileInput, { check, node: wantNode }?: {
|
|
|
148
110
|
/** Bumped whenever the shape of a compiled node changes. */
|
|
149
111
|
export const COMPILED_DOC_SCHEMA_VERSION: 1;
|
|
150
112
|
/** Every kind a compiled node has: one per authored doc kind a root reads. */
|
|
151
|
-
export const COMPILED_DOC_KINDS: readonly ["component", "function", "reference", "page", "block", "schema", "command", "enum", "theme"];
|
|
113
|
+
export const COMPILED_DOC_KINDS: readonly ["component", "function", "reference", "page", "block", "schema", "command", "enum", "theme", "namespace"];
|
|
152
114
|
/**
|
|
153
115
|
* The roots that read docs, and the kinds each may hold. A doc without a
|
|
154
116
|
* stamped `type` (the legacy form) takes its root's first kind.
|
|
155
117
|
* @type {Readonly<Record<string, readonly string[]>>}
|
|
156
118
|
*/
|
|
157
119
|
export const ROOT_KINDS: Readonly<Record<string, readonly string[]>>;
|
|
158
|
-
/**
|
|
159
|
-
* One authored file, as discovery loaded it.
|
|
160
|
-
*/
|
|
161
|
-
export type AuthoredFile = {
|
|
162
|
-
/**
|
|
163
|
-
* the file's name, for messages only
|
|
164
|
-
*/
|
|
165
|
-
file: string;
|
|
166
|
-
/**
|
|
167
|
-
* the parsed doc, when it loaded
|
|
168
|
-
*/
|
|
169
|
-
doc?: any;
|
|
170
|
-
/**
|
|
171
|
-
* why it did not load or parse
|
|
172
|
-
*/
|
|
173
|
-
error?: unknown;
|
|
174
|
-
/**
|
|
175
|
-
* the language overlay's export, when one applies
|
|
176
|
-
*/
|
|
177
|
-
overlay?: any;
|
|
178
|
-
/**
|
|
179
|
-
* why the overlay did not load
|
|
180
|
-
*/
|
|
181
|
-
overlayError?: unknown;
|
|
182
|
-
};
|
|
183
|
-
export type ReferenceTopicInput = {
|
|
184
|
-
/**
|
|
185
|
-
* the topic's name in the catalog
|
|
186
|
-
*/
|
|
187
|
-
id: string;
|
|
188
|
-
/**
|
|
189
|
-
* the package that owns the topic
|
|
190
|
-
*/
|
|
191
|
-
provider: string;
|
|
192
|
-
/**
|
|
193
|
-
* the topic it took the place of
|
|
194
|
-
*/
|
|
195
|
-
replaces: string | null;
|
|
196
|
-
/**
|
|
197
|
-
* the overlay language, or null for authored text
|
|
198
|
-
*/
|
|
199
|
-
lang: string | null;
|
|
200
|
-
base: AuthoredFile;
|
|
201
|
-
/**
|
|
202
|
-
* in merge order
|
|
203
|
-
*/
|
|
204
|
-
extensions: Array<AuthoredFile & {
|
|
205
|
-
provider: string;
|
|
206
|
-
}>;
|
|
207
|
-
};
|
|
208
|
-
/**
|
|
209
|
-
* A token reference after linking: the target section's content, or why it
|
|
210
|
-
* has none.
|
|
211
|
-
*/
|
|
212
|
-
export type TokenRefResolution = {
|
|
213
|
-
status: "resolved";
|
|
214
|
-
topic: string;
|
|
215
|
-
section: string;
|
|
216
|
-
previewType?: string;
|
|
217
|
-
content: any[];
|
|
218
|
-
} | {
|
|
219
|
-
status: "unknown-topic";
|
|
220
|
-
} | {
|
|
221
|
-
status: "unknown-section";
|
|
222
|
-
};
|
|
223
|
-
export type CompiledReferenceNode = {
|
|
224
|
-
schemaVersion: number;
|
|
225
|
-
kind: "reference";
|
|
226
|
-
/**
|
|
227
|
-
* `linked` once every token reference
|
|
228
|
-
* carries its resolution; a lowered node carries none
|
|
229
|
-
*/
|
|
230
|
-
stage: "lowered" | "linked";
|
|
231
|
-
/**
|
|
232
|
-
* the topic's name in the catalog
|
|
233
|
-
*/
|
|
234
|
-
id: string;
|
|
235
|
-
lang: string | null;
|
|
236
|
-
provenance: {
|
|
237
|
-
provider: string;
|
|
238
|
-
replaces: string | null;
|
|
239
|
-
extensions: string[];
|
|
240
|
-
};
|
|
241
|
-
/**
|
|
242
|
-
* section key -> authored title
|
|
243
|
-
*/
|
|
244
|
-
sourceTitles: Record<string, string>;
|
|
245
|
-
/**
|
|
246
|
-
* the topic: authored fields in authored order, every
|
|
247
|
-
* section keyed; a linked node's token references carry `resolved`
|
|
248
|
-
*/
|
|
249
|
-
doc: any;
|
|
250
|
-
};
|
|
251
120
|
export type CompilerDiagnostic = import("./diagnostics.mjs").CompilerDiagnostic;
|
|
252
121
|
/**
|
|
253
122
|
* One authored doc of any kind but a reference topic, as its root loaded it.
|
|
@@ -360,3 +229,115 @@ export type LoweredDoc = {
|
|
|
360
229
|
*/
|
|
361
230
|
overlayFailure?: unknown;
|
|
362
231
|
};
|
|
232
|
+
/**
|
|
233
|
+
* One authored file, as discovery loaded it.
|
|
234
|
+
*/
|
|
235
|
+
export type AuthoredFile = {
|
|
236
|
+
/**
|
|
237
|
+
* the file's name, for messages only
|
|
238
|
+
*/
|
|
239
|
+
file: string;
|
|
240
|
+
/**
|
|
241
|
+
* the parsed doc, when it loaded
|
|
242
|
+
*/
|
|
243
|
+
doc?: any;
|
|
244
|
+
/**
|
|
245
|
+
* why it did not load or parse
|
|
246
|
+
*/
|
|
247
|
+
error?: unknown;
|
|
248
|
+
/**
|
|
249
|
+
* the language overlay's export, when one applies
|
|
250
|
+
*/
|
|
251
|
+
overlay?: any;
|
|
252
|
+
/**
|
|
253
|
+
* why the overlay did not load
|
|
254
|
+
*/
|
|
255
|
+
overlayError?: unknown;
|
|
256
|
+
};
|
|
257
|
+
export type ReferenceTopicInput = {
|
|
258
|
+
/**
|
|
259
|
+
* the topic's name in the catalog
|
|
260
|
+
*/
|
|
261
|
+
id: string;
|
|
262
|
+
/**
|
|
263
|
+
* the package that owns the topic
|
|
264
|
+
*/
|
|
265
|
+
provider: string;
|
|
266
|
+
/**
|
|
267
|
+
* the topic it took the place of
|
|
268
|
+
*/
|
|
269
|
+
replaces: string | null;
|
|
270
|
+
/**
|
|
271
|
+
* the overlay language, or null for authored text
|
|
272
|
+
*/
|
|
273
|
+
lang: string | null;
|
|
274
|
+
/**
|
|
275
|
+
* the owner's provider id; the package name
|
|
276
|
+
* when absent. The base file's sections resolve their links against it.
|
|
277
|
+
*/
|
|
278
|
+
providerId?: string | undefined;
|
|
279
|
+
base: AuthoredFile;
|
|
280
|
+
/**
|
|
281
|
+
* in merge order; each extension's sections resolve their links against its
|
|
282
|
+
* own provider id
|
|
283
|
+
*/
|
|
284
|
+
extensions: Array<AuthoredFile & {
|
|
285
|
+
provider: string;
|
|
286
|
+
providerId?: string;
|
|
287
|
+
}>;
|
|
288
|
+
/**
|
|
289
|
+
* a guide the docs tree places: its `placement` is
|
|
290
|
+
* read by the tree, so the topic reader accepts it
|
|
291
|
+
*/
|
|
292
|
+
tree?: boolean | undefined;
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* A token reference after linking: the target section's content, or why it
|
|
296
|
+
* has none.
|
|
297
|
+
*/
|
|
298
|
+
export type TokenRefResolution = {
|
|
299
|
+
status: "resolved";
|
|
300
|
+
topic: string;
|
|
301
|
+
section: string;
|
|
302
|
+
previewType?: string;
|
|
303
|
+
content: any[];
|
|
304
|
+
} | {
|
|
305
|
+
status: "unknown-topic";
|
|
306
|
+
} | {
|
|
307
|
+
status: "unknown-section";
|
|
308
|
+
};
|
|
309
|
+
export type CompiledReferenceNode = {
|
|
310
|
+
schemaVersion: number;
|
|
311
|
+
kind: "reference";
|
|
312
|
+
/**
|
|
313
|
+
* `linked` once every token reference
|
|
314
|
+
* carries its resolution; a lowered node carries none
|
|
315
|
+
*/
|
|
316
|
+
stage: "lowered" | "linked";
|
|
317
|
+
/**
|
|
318
|
+
* the topic's name in the catalog
|
|
319
|
+
*/
|
|
320
|
+
id: string;
|
|
321
|
+
lang: string | null;
|
|
322
|
+
provenance: {
|
|
323
|
+
provider: string;
|
|
324
|
+
replaces: string | null;
|
|
325
|
+
extensions: string[];
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* section key -> authored title
|
|
329
|
+
*/
|
|
330
|
+
sourceTitles: Record<string, string>;
|
|
331
|
+
/**
|
|
332
|
+
* section key -> the
|
|
333
|
+
* provider id that wrote the section: a topic merges sections from its base
|
|
334
|
+
* and its extensions, and each section's links resolve against its own
|
|
335
|
+
* provider (spec:AST-047 FR9)
|
|
336
|
+
*/
|
|
337
|
+
sectionProviders: Record<string, string>;
|
|
338
|
+
/**
|
|
339
|
+
* the topic: authored fields in authored order, every
|
|
340
|
+
* section keyed; a linked node's token references carry `resolved`
|
|
341
|
+
*/
|
|
342
|
+
doc: any;
|
|
343
|
+
};
|
|
@@ -63,6 +63,7 @@ export const COMPILED_DOC_KINDS = /** @type {const} */ ([
|
|
|
63
63
|
'command',
|
|
64
64
|
'enum',
|
|
65
65
|
'theme',
|
|
66
|
+
'namespace',
|
|
66
67
|
]);
|
|
67
68
|
|
|
68
69
|
/**
|
|
@@ -76,6 +77,7 @@ export const ROOT_KINDS = Object.freeze({
|
|
|
76
77
|
templates: ['page', 'block'],
|
|
77
78
|
themes: ['theme'],
|
|
78
79
|
'self-docs': ['command', 'function', 'schema', 'enum'],
|
|
80
|
+
tree: ['namespace', 'generic'],
|
|
79
81
|
});
|
|
80
82
|
|
|
81
83
|
/**
|
|
@@ -94,8 +96,14 @@ export const ROOT_KINDS = Object.freeze({
|
|
|
94
96
|
* @property {string} provider the package that owns the topic
|
|
95
97
|
* @property {string | null} replaces the topic it took the place of
|
|
96
98
|
* @property {string | null} lang the overlay language, or null for authored text
|
|
99
|
+
* @property {string} [providerId] the owner's provider id; the package name
|
|
100
|
+
* when absent. The base file's sections resolve their links against it.
|
|
97
101
|
* @property {AuthoredFile} base
|
|
98
|
-
* @property {Array<AuthoredFile & {provider: string}>} extensions
|
|
102
|
+
* @property {Array<AuthoredFile & {provider: string, providerId?: string}>} extensions
|
|
103
|
+
* in merge order; each extension's sections resolve their links against its
|
|
104
|
+
* own provider id
|
|
105
|
+
* @property {boolean} [tree] a guide the docs tree places: its `placement` is
|
|
106
|
+
* read by the tree, so the topic reader accepts it
|
|
99
107
|
*/
|
|
100
108
|
|
|
101
109
|
/**
|
|
@@ -116,10 +124,33 @@ export const ROOT_KINDS = Object.freeze({
|
|
|
116
124
|
* @property {string | null} lang
|
|
117
125
|
* @property {{provider: string, replaces: string | null, extensions: string[]}} provenance
|
|
118
126
|
* @property {Record<string, string>} sourceTitles section key -> authored title
|
|
127
|
+
* @property {Record<string, string>} sectionProviders section key -> the
|
|
128
|
+
* provider id that wrote the section: a topic merges sections from its base
|
|
129
|
+
* and its extensions, and each section's links resolve against its own
|
|
130
|
+
* provider (spec:AST-047 FR9)
|
|
119
131
|
* @property {any} doc the topic: authored fields in authored order, every
|
|
120
132
|
* section keyed; a linked node's token references carry `resolved`
|
|
121
133
|
*/
|
|
122
134
|
|
|
135
|
+
/** Which provider wrote a section, until lowering records it by key. */
|
|
136
|
+
const SECTION_PROVIDER = Symbol('astryx.docs.sectionProvider');
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Mark each section of one authored file with the provider that wrote it. The
|
|
140
|
+
* overlay, the merge, and the key stamp copy the mark with the section.
|
|
141
|
+
* @param {any} doc
|
|
142
|
+
* @param {string} provider
|
|
143
|
+
* @returns {any}
|
|
144
|
+
*/
|
|
145
|
+
function markProvider(doc, provider) {
|
|
146
|
+
return {
|
|
147
|
+
...doc,
|
|
148
|
+
sections: doc.sections.map((/** @type {any} */ section) =>
|
|
149
|
+
withSourceTitle({...section, [SECTION_PROVIDER]: provider}, sourceTitle(section)),
|
|
150
|
+
),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
123
154
|
/**
|
|
124
155
|
* Lower one topic: overlay each file, merge the extensions in order, and stamp
|
|
125
156
|
* every section with its key.
|
|
@@ -127,9 +158,18 @@ export const ROOT_KINDS = Object.freeze({
|
|
|
127
158
|
* @returns {CompiledReferenceNode}
|
|
128
159
|
*/
|
|
129
160
|
export function lowerReferenceTopic(input) {
|
|
130
|
-
let doc =
|
|
161
|
+
let doc = markProvider(
|
|
162
|
+
readAuthoredFile(input.base, {placement: input.tree === true}),
|
|
163
|
+
input.providerId ?? input.provider,
|
|
164
|
+
);
|
|
131
165
|
for (const extension of input.extensions) {
|
|
132
|
-
doc = mergeTopic(
|
|
166
|
+
doc = mergeTopic(
|
|
167
|
+
doc,
|
|
168
|
+
markProvider(
|
|
169
|
+
readAuthoredFile(extension),
|
|
170
|
+
extension.providerId ?? extension.provider,
|
|
171
|
+
),
|
|
172
|
+
);
|
|
133
173
|
// Explicit authored IDs remain strict. Legacy title-derived collisions are
|
|
134
174
|
// assigned deterministic compatibility keys after every extension merges.
|
|
135
175
|
const problems = sectionKeyErrors(doc.sections);
|
|
@@ -143,8 +183,12 @@ export function lowerReferenceTopic(input) {
|
|
|
143
183
|
const keyed = withSectionKeys(doc);
|
|
144
184
|
/** @type {Record<string, string>} */
|
|
145
185
|
const sourceTitles = {};
|
|
186
|
+
/** @type {Record<string, string>} */
|
|
187
|
+
const sectionProviders = {};
|
|
146
188
|
for (const section of keyed.sections) {
|
|
147
189
|
sourceTitles[section.id] = sourceTitle(section);
|
|
190
|
+
sectionProviders[section.id] =
|
|
191
|
+
section[SECTION_PROVIDER] ?? input.providerId ?? input.provider;
|
|
148
192
|
}
|
|
149
193
|
return {
|
|
150
194
|
schemaVersion: COMPILED_DOC_SCHEMA_VERSION,
|
|
@@ -158,7 +202,9 @@ export function lowerReferenceTopic(input) {
|
|
|
158
202
|
extensions: input.extensions.map(extension => extension.provider),
|
|
159
203
|
},
|
|
160
204
|
sourceTitles,
|
|
161
|
-
|
|
205
|
+
sectionProviders,
|
|
206
|
+
// The authored title and provider travel in sourceTitles and
|
|
207
|
+
// sectionProviders; JSON drops the symbols.
|
|
162
208
|
doc: asJson(keyed, input.id),
|
|
163
209
|
};
|
|
164
210
|
}
|
|
@@ -255,13 +301,13 @@ function asJson(value, topic) {
|
|
|
255
301
|
* @param {AuthoredFile} file
|
|
256
302
|
* @returns {any}
|
|
257
303
|
*/
|
|
258
|
-
function readAuthoredFile(file) {
|
|
304
|
+
function readAuthoredFile(file, {placement = false} = {}) {
|
|
259
305
|
if ('error' in file) throw file.error;
|
|
260
306
|
const parsed = file.doc;
|
|
261
307
|
if (!('sections' in parsed)) {
|
|
262
308
|
throw new Error(`${file.file} is not a reference document.`);
|
|
263
309
|
}
|
|
264
|
-
const problems = problemsInTopic(parsed);
|
|
310
|
+
const problems = problemsInTopic(parsed, {placement});
|
|
265
311
|
if (problems.length > 0) {
|
|
266
312
|
throw new Error(`${file.file} is invalid: ${problems.join('; ')}`);
|
|
267
313
|
}
|
|
@@ -123,6 +123,34 @@ export const DIAGNOSTIC_CODES = Object.freeze(
|
|
|
123
123
|
remediation:
|
|
124
124
|
'Point the token reference at a topic and section that exist; `astryx docs <topic> --index` lists the section keys.',
|
|
125
125
|
},
|
|
126
|
+
invalid_namespace: {
|
|
127
|
+
phase: 'link',
|
|
128
|
+
severity: 'error',
|
|
129
|
+
scope: 'node',
|
|
130
|
+
remediation:
|
|
131
|
+
'Give each namespace a route-safe name (lowercase letters and digits joined by hyphens) that no other namespace in its package uses.',
|
|
132
|
+
},
|
|
133
|
+
invalid_placement: {
|
|
134
|
+
phase: 'link',
|
|
135
|
+
severity: 'error',
|
|
136
|
+
scope: 'node',
|
|
137
|
+
remediation:
|
|
138
|
+
'Point placement.parent at a namespace of the same package ("namespace:<name>"), name one of its slots, and use a slot that accepts the doc\'s kind; `astryx docs authoring namespace-doc` lists the fields.',
|
|
139
|
+
},
|
|
140
|
+
overlapping_adoption: {
|
|
141
|
+
phase: 'link',
|
|
142
|
+
severity: 'error',
|
|
143
|
+
scope: 'node',
|
|
144
|
+
remediation:
|
|
145
|
+
'Change the adoption rules so exactly one namespace adopts the doc, or give the doc an explicit placement.',
|
|
146
|
+
},
|
|
147
|
+
duplicate_route: {
|
|
148
|
+
phase: 'link',
|
|
149
|
+
severity: 'error',
|
|
150
|
+
scope: 'node',
|
|
151
|
+
remediation:
|
|
152
|
+
'Rename or move one of the two docs, so each route in the docs tree belongs to one doc.',
|
|
153
|
+
},
|
|
126
154
|
not_json: {
|
|
127
155
|
phase: 'serialize',
|
|
128
156
|
severity: 'error',
|
|
@@ -252,8 +252,8 @@ const RUNNERS = {
|
|
|
252
252
|
sites: ['importDocModule'],
|
|
253
253
|
},
|
|
254
254
|
'foundation/discovery/template-adapter.mjs': {
|
|
255
|
-
runs: '@babel/parser, to find the fixture references in template source',
|
|
256
|
-
sites: ['require(@babel/parser)'],
|
|
255
|
+
runs: '@babel/parser, to find the fixture references in template source; and a template doc that does not validate, to read the replacement it declares',
|
|
256
|
+
sites: ['importDocModule', 'require(@babel/parser)'],
|
|
257
257
|
},
|
|
258
258
|
'foundation/discovery/theme-discovery.mjs': {
|
|
259
259
|
runs: '@babel/parser and jscodeshift (CommonJS), each on first use, so listing bundled themes never loads jscodeshift',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @typedef {'components' | 'hooks' | 'templates' | 'themes' | 'docs' | 'self-docs'} DocRoot
|
|
5
|
+
* @typedef {'components' | 'hooks' | 'templates' | 'themes' | 'docs' | 'self-docs' | 'tree'} DocRoot
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
8
|
* One authored descriptor, as the compiler will read it.
|
|
@@ -45,7 +45,7 @@ export function selfDocFiles(): string[];
|
|
|
45
45
|
export { packageSource };
|
|
46
46
|
/** Where the CLI keeps self-documentation, relative to its package root. */
|
|
47
47
|
export const SELF_DOC_TREES: string[];
|
|
48
|
-
export type DocRoot = "components" | "hooks" | "templates" | "themes" | "docs" | "self-docs";
|
|
48
|
+
export type DocRoot = "components" | "hooks" | "templates" | "themes" | "docs" | "self-docs" | "tree";
|
|
49
49
|
/**
|
|
50
50
|
* One authored descriptor, as the compiler will read it.
|
|
51
51
|
*/
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
import {discoverHooks, findHookDoc} from '../discovery/hook-discovery.mjs';
|
|
25
25
|
import {CLI_ROOT, findCoreDir} from '../fs/paths.mjs';
|
|
26
26
|
import {packageSource} from './source.mjs';
|
|
27
|
+
import {treeDocFiles} from './tree.mjs';
|
|
27
28
|
|
|
28
29
|
export {packageSource};
|
|
29
30
|
|
|
@@ -42,7 +43,7 @@ const NON_DESCRIPTOR_DIRS = new Set([
|
|
|
42
43
|
]);
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
|
-
* @typedef {'components' | 'hooks' | 'templates' | 'themes' | 'docs' | 'self-docs'} DocRoot
|
|
46
|
+
* @typedef {'components' | 'hooks' | 'templates' | 'themes' | 'docs' | 'self-docs' | 'tree'} DocRoot
|
|
46
47
|
*/
|
|
47
48
|
|
|
48
49
|
/**
|
|
@@ -125,6 +126,10 @@ export async function collectDocInputs(project) {
|
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
|
|
129
|
+
// The docs tree's own files: its namespaces and the guides it places.
|
|
130
|
+
for (const file of treeDocFiles()) {
|
|
131
|
+
list.add('tree', path.basename(file, '.doc.mjs'), CLI_PACKAGE, file);
|
|
132
|
+
}
|
|
128
133
|
for (const file of selfDocFiles()) {
|
|
129
134
|
const name = path
|
|
130
135
|
.relative(CLI_ROOT, file)
|