@astryxdesign/cli 0.7.4-canary.3f6ea7d → 0.7.4-canary.ac8260d
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 +63 -63
- package/api/docs/_adapter.d.mts +80 -0
- package/api/docs/_adapter.mjs +248 -5
- package/api/docs/detail/detail.mjs +8 -0
- package/api/docs/docs.doc.mjs +1 -1
- package/api/docs/docs.type.d.mts +28 -2
- package/api/docs/docs.type.mjs +13 -3
- package/api/docs/guide-route-targets.test.mjs +998 -0
- package/api/docs/index/index.mjs +9 -0
- package/api/docs/list/list.mjs +7 -1
- package/api/docs/node/node.mjs +9 -1
- package/api/doctor/built-checks.mjs +43 -13
- package/api/doctor/built-checks.test.mjs +29 -0
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/integration/_adapter.d.mts +8 -0
- package/api/integration/_adapter.mjs +25 -0
- package/api/integration/authoring-checks.mjs +29 -2
- package/api/integration/pack-check.mjs +32 -1
- package/api/integration/pack-check.test.mjs +33 -0
- package/api/integration/validate-integration.mjs +66 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_candidate-score.d.mts +3 -2
- package/api/search/_candidate-score.mjs +66 -3
- package/api/search/_gather-docs.mjs +12 -2
- package/api/search/_priority.mjs +2 -1
- package/api/search/_score.d.mts +2 -1
- package/api/search/_score.mjs +2 -2
- package/api/search/search.family-members.test.mjs +124 -0
- package/assets/discover/official-packages.json +16 -0
- package/assets/docs/tree/extend-or-replace.doc.mjs +36 -4
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +54 -0
- package/assets/templates/themes/butter/butterPalettes.generated.receipt.json +1499 -0
- package/assets/templates/themes/butter/butterPalettes.generated.ts +550 -0
- package/assets/templates/themes/butter/butterTheme.ts +274 -234
- package/assets/templates/themes/butter/palette.config.json +484 -0
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +51 -0
- package/assets/templates/themes/matcha/matchaPalettes.generated.receipt.json +1502 -0
- package/assets/templates/themes/matcha/matchaPalettes.generated.ts +501 -0
- package/assets/templates/themes/matcha/matchaPalettes.ts +21 -0
- package/assets/templates/themes/matcha/matchaTheme.ts +164 -103
- package/assets/templates/themes/matcha/palette.config.json +448 -0
- package/assets/templates/themes/y2k/palette.config.json +166 -0
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +54 -0
- package/assets/templates/themes/y2k/y2kPalettes.generated.receipt.json +872 -0
- package/assets/templates/themes/y2k/y2kPalettes.generated.ts +550 -0
- package/assets/templates/themes/y2k/y2kPalettes.ts +257 -0
- package/assets/templates/themes/y2k/y2kTheme.ts +164 -391
- package/authoring/doctypes/_schema.d.mts +4 -0
- package/authoring/doctypes/_schema.mjs +4 -0
- package/authoring/doctypes/reference/type.ts +14 -2
- package/clients/cli/commands/docs.mjs +27 -2
- package/foundation/discovery/docs-discovery.d.mts +93 -2
- package/foundation/discovery/docs-discovery.mjs +236 -8
- package/foundation/doc-compiler/compile.mjs +8 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +3 -0
- package/foundation/doc-compiler/tree.d.mts +5 -0
- package/foundation/doc-compiler/tree.mjs +3 -0
- package/foundation/integrations/cli-requirement.d.mts +14 -0
- package/foundation/integrations/cli-requirement.mjs +23 -0
- package/foundation/integrations/cli-requirement.test.mjs +1 -0
- package/foundation/response/response-types.doc.mjs +5 -5
- package/package.json +9 -9
|
@@ -137,12 +137,16 @@ export interface ReferenceDoc extends AuthoredDocGraphFields {
|
|
|
137
137
|
* `replaces: 'getting-started'` on a doc named `getting-started` swaps the
|
|
138
138
|
* content, and on a doc named something else swaps it and leaves the old
|
|
139
139
|
* name as an alias, so `astryx docs getting-started` still resolves.
|
|
140
|
+
* A route (`'authoring/quick-start'`) names a guide the docs tree
|
|
141
|
+
* places: readers who open that route get this doc.
|
|
140
142
|
* Ignored on a built-in topic (there is nothing above it to replace). */
|
|
141
143
|
replaces?: string;
|
|
142
144
|
/** Name of an existing topic this doc merges onto, section by section: a
|
|
143
145
|
* section whose title matches one in the base replaces it, and a section
|
|
144
|
-
* the base does not have is
|
|
145
|
-
*
|
|
146
|
+
* the base does not have is added where its `before` or `after` says, else
|
|
147
|
+
* at the end. A route (`'authoring/quick-start'`) names a guide the
|
|
148
|
+
* docs tree places. For correcting or adding to a topic rather than owning
|
|
149
|
+
* it — `replaces` and `extends` are exclusive. */
|
|
146
150
|
extends?: string;
|
|
147
151
|
/** Ordered sections that make up the doc. */
|
|
148
152
|
sections: ReferenceSection[];
|
|
@@ -170,6 +174,14 @@ export interface ReferenceSection {
|
|
|
170
174
|
* `reference` block includes another doc from its canonical source, so a
|
|
171
175
|
* guide never copies a schema's fields or a command's options. */
|
|
172
176
|
content: (ReferenceContentBlock | ReferenceDocBlock)[];
|
|
177
|
+
/** In a doc that `extends` a topic, the key of the base section (as
|
|
178
|
+
* `astryx docs <topic> --index` shows it) to add this section before,
|
|
179
|
+
* when it replaces none. Set `before` or `after`, not both; with neither,
|
|
180
|
+
* the section is added at the end. Ignored on any other doc. */
|
|
181
|
+
before?: string;
|
|
182
|
+
/** In a doc that `extends` a topic, the key of the base section to add this
|
|
183
|
+
* section after, when it replaces none. */
|
|
184
|
+
after?: string;
|
|
173
185
|
/** Preview type for token tables in this section. When set, the docsite
|
|
174
186
|
* renders a visual preview column using the token's computed CSS value
|
|
175
187
|
* from the current theme. Omit for non-token sections. */
|
|
@@ -431,6 +431,29 @@ function linkLines(links) {
|
|
|
431
431
|
];
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
+
/**
|
|
435
|
+
* A section title naming the package that wrote it, once: a title an author
|
|
436
|
+
* already ended with that package keeps its own.
|
|
437
|
+
* @param {string} title
|
|
438
|
+
* @param {string} pkg
|
|
439
|
+
* @returns {string}
|
|
440
|
+
*/
|
|
441
|
+
function titledWithPackage(title, pkg) {
|
|
442
|
+
const label = `(${pkg})`;
|
|
443
|
+
return title.endsWith(label) ? title : `${title} ${label}`;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* What a topic or guide took the place of, and whose it was, as the line
|
|
448
|
+
* read right after its `package:` line (INV28); nothing for any other read.
|
|
449
|
+
* @param {{replaces?: string, replacedPackage?: string}} data
|
|
450
|
+
* @returns {ReturnType<typeof text>[]}
|
|
451
|
+
*/
|
|
452
|
+
function replacedLine(data) {
|
|
453
|
+
if (data.replaces == null || data.replacedPackage == null) return [];
|
|
454
|
+
return [text(`replaces ${data.replacedPackage}'s ${data.replaces}`)];
|
|
455
|
+
}
|
|
456
|
+
|
|
434
457
|
/**
|
|
435
458
|
* A topic's section index: what the topic is, one line per section with the
|
|
436
459
|
* key to read it by, and how to read further.
|
|
@@ -445,6 +468,7 @@ function emitIndex(index, owner, run) {
|
|
|
445
468
|
index.description ? wrapText(index.description) : undefined,
|
|
446
469
|
),
|
|
447
470
|
record({package: owner}),
|
|
471
|
+
...replacedLine(index),
|
|
448
472
|
// Summaries wrap rather than being cut: the summary is how a reader picks
|
|
449
473
|
// the one section to open. A section another package wrote says which one.
|
|
450
474
|
records(
|
|
@@ -452,7 +476,7 @@ function emitIndex(index, owner, run) {
|
|
|
452
476
|
const shown = {...s, summary: prefixCliCommands(s.summary ?? '', run)};
|
|
453
477
|
return s.package === owner
|
|
454
478
|
? shown
|
|
455
|
-
: {...shown, title:
|
|
479
|
+
: {...shown, title: titledWithPackage(s.title, s.package)};
|
|
456
480
|
}),
|
|
457
481
|
{
|
|
458
482
|
fields: ['id', 'title', 'summary'],
|
|
@@ -717,6 +741,7 @@ export function registerDocs(program) {
|
|
|
717
741
|
const owner = result.package;
|
|
718
742
|
emit(
|
|
719
743
|
record({package: owner}),
|
|
744
|
+
...replacedLine(result.data),
|
|
720
745
|
code(
|
|
721
746
|
formatReferenceFull(
|
|
722
747
|
{
|
|
@@ -725,7 +750,7 @@ export function registerDocs(program) {
|
|
|
725
750
|
sections: result.data.sections.map(s =>
|
|
726
751
|
s.package === owner
|
|
727
752
|
? s
|
|
728
|
-
: {...s, title:
|
|
753
|
+
: {...s, title: titledWithPackage(s.title, s.package)},
|
|
729
754
|
),
|
|
730
755
|
},
|
|
731
756
|
detail,
|
|
@@ -1,6 +1,25 @@
|
|
|
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
|
+
* Whether a `replaces` or `extends` names a route of the docs tree rather than
|
|
6
|
+
* a flat topic: a topic name never holds a `/`, and a guide the tree places is
|
|
7
|
+
* always read by a route that does.
|
|
8
|
+
* @param {unknown} target
|
|
9
|
+
* @returns {target is string}
|
|
10
|
+
*/
|
|
11
|
+
export function isGuideRoute(target: unknown): target is string;
|
|
12
|
+
/**
|
|
13
|
+
* What the integrations do to one guide the docs tree places, in configured
|
|
14
|
+
* order: a replacement, and the extensions merged onto whatever is there.
|
|
15
|
+
* @typedef {object} GuideOverlay
|
|
16
|
+
* @property {DocsTopicRecord | null} replacement the doc readers get at the
|
|
17
|
+
* route instead of the guide; the last package configured wins
|
|
18
|
+
* @property {Array<{package: string, path: string, providerId?: string}>} extensions
|
|
19
|
+
* extensions authored after the replacement, if any, in configured order
|
|
20
|
+
* @property {string} [replacedPackage] the package of the replacement this one
|
|
21
|
+
* took over from, when the guide was replaced twice
|
|
22
|
+
*/
|
|
4
23
|
/**
|
|
5
24
|
* @typedef {object} DocsTopicRecord A doc file discovered under a docs root.
|
|
6
25
|
* @property {string} name
|
|
@@ -25,6 +44,8 @@
|
|
|
25
44
|
* @property {string} [description]
|
|
26
45
|
* @property {string|null} [category]
|
|
27
46
|
* @property {string} [replaces] the topic this one took the place of
|
|
47
|
+
* @property {string} [replacedPackage] the package whose topic or guide this
|
|
48
|
+
* one took the place of
|
|
28
49
|
* @property {Array<{package: string, path: string, providerId?: string}>} extensions
|
|
29
50
|
* overlays to merge onto the base doc, in the order their integrations were
|
|
30
51
|
* configured; each section an extension adds resolves its links against the
|
|
@@ -108,8 +129,9 @@ export function discoverIntegrationDocs(integration: {
|
|
|
108
129
|
/**
|
|
109
130
|
* Merge an extension onto a base topic: a section with a stable `id` replaces
|
|
110
131
|
* the base section with the same `id`; legacy sections without IDs fall back to
|
|
111
|
-
* title matching. A section with no match is
|
|
112
|
-
*
|
|
132
|
+
* title matching. A section with no match is added: before or after the
|
|
133
|
+
* section whose key its `before` or `after` names, else at the end. The title
|
|
134
|
+
* and description stay the base topic's: an extension adds to a topic, it never
|
|
113
135
|
* renames it. A topic that `replaces` another is the one that renames.
|
|
114
136
|
*
|
|
115
137
|
* Keyed by section TITLE rather than by position, the way the localization
|
|
@@ -122,6 +144,28 @@ export function discoverIntegrationDocs(integration: {
|
|
|
122
144
|
* @returns {any} a new doc; neither input is mutated
|
|
123
145
|
*/
|
|
124
146
|
export function mergeTopic(base: any, overlay: any): any;
|
|
147
|
+
/**
|
|
148
|
+
* {@link mergeTopic}, also naming each `before` or `after` that found no
|
|
149
|
+
* section: that section was added at the end instead.
|
|
150
|
+
*
|
|
151
|
+
* @param {any} base
|
|
152
|
+
* @param {any} overlay
|
|
153
|
+
* @returns {{doc: any, unplaced: Array<{section: string, field: 'before' | 'after', key: string}>}}
|
|
154
|
+
*/
|
|
155
|
+
export function mergeTopicReport(base: any, overlay: any): {
|
|
156
|
+
doc: any;
|
|
157
|
+
unplaced: Array<{
|
|
158
|
+
section: string;
|
|
159
|
+
field: "before" | "after";
|
|
160
|
+
key: string;
|
|
161
|
+
}>;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* A section without the fields that place it; readers never see them.
|
|
165
|
+
* @param {any} section
|
|
166
|
+
* @returns {any}
|
|
167
|
+
*/
|
|
168
|
+
export function withoutPosition(section: any): any;
|
|
125
169
|
export { withSourceTitle };
|
|
126
170
|
/**
|
|
127
171
|
* Owner package recorded for the built-in topics. They ship inside the CLI
|
|
@@ -139,6 +183,11 @@ export const GRAPH_BLOCK_TYPES: Set<string>;
|
|
|
139
183
|
* load; a guide the tree places may set `placement` (spec:AST-046).
|
|
140
184
|
*/
|
|
141
185
|
export const GRAPH_ONLY_FIELDS: string[];
|
|
186
|
+
/**
|
|
187
|
+
* The fields an extension section places itself with: the key of the base
|
|
188
|
+
* section it goes before or after. Read only by a merge, never by a reader.
|
|
189
|
+
*/
|
|
190
|
+
export const SECTION_POSITION_FIELDS: string[];
|
|
142
191
|
/**
|
|
143
192
|
* A component a link can name: its owner's provider id, package, and name,
|
|
144
193
|
* and the doc file that describes it.
|
|
@@ -183,6 +232,19 @@ export class DocsCatalog {
|
|
|
183
232
|
* @returns {DocsCatalog}
|
|
184
233
|
*/
|
|
185
234
|
static fromBuiltins(builtins?: Record<string, string>): DocsCatalog;
|
|
235
|
+
/**
|
|
236
|
+
* What the integrations do to the guide the docs tree places at `route`, or
|
|
237
|
+
* null when they leave it as it is.
|
|
238
|
+
* @param {string} route
|
|
239
|
+
* @returns {GuideOverlay | null}
|
|
240
|
+
*/
|
|
241
|
+
guideOverlay(route: string): GuideOverlay | null;
|
|
242
|
+
/**
|
|
243
|
+
* Every doc that replaces or extends a guide by its route, in configured
|
|
244
|
+
* order, so a check can name a route that holds no guide.
|
|
245
|
+
* @returns {ReadonlyArray<DocsTopicRecord>}
|
|
246
|
+
*/
|
|
247
|
+
get guideTargeters(): ReadonlyArray<DocsTopicRecord>;
|
|
186
248
|
/**
|
|
187
249
|
* Record a doc file a package ships that did not load. Its package's docs
|
|
188
250
|
* are withdrawn; readers name the package so an author knows where to look.
|
|
@@ -259,6 +321,30 @@ export class DocsCatalog {
|
|
|
259
321
|
entries(): DocsTopicEntry[];
|
|
260
322
|
#private;
|
|
261
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* What the integrations do to one guide the docs tree places, in configured
|
|
326
|
+
* order: a replacement, and the extensions merged onto whatever is there.
|
|
327
|
+
*/
|
|
328
|
+
export type GuideOverlay = {
|
|
329
|
+
/**
|
|
330
|
+
* the doc readers get at the
|
|
331
|
+
* route instead of the guide; the last package configured wins
|
|
332
|
+
*/
|
|
333
|
+
replacement: DocsTopicRecord | null;
|
|
334
|
+
/**
|
|
335
|
+
* extensions authored after the replacement, if any, in configured order
|
|
336
|
+
*/
|
|
337
|
+
extensions: Array<{
|
|
338
|
+
package: string;
|
|
339
|
+
path: string;
|
|
340
|
+
providerId?: string;
|
|
341
|
+
}>;
|
|
342
|
+
/**
|
|
343
|
+
* the package of the replacement this one
|
|
344
|
+
* took over from, when the guide was replaced twice
|
|
345
|
+
*/
|
|
346
|
+
replacedPackage?: string | undefined;
|
|
347
|
+
};
|
|
262
348
|
/**
|
|
263
349
|
* A doc file discovered under a docs root.
|
|
264
350
|
*/
|
|
@@ -314,6 +400,11 @@ export type DocsTopicEntry = {
|
|
|
314
400
|
* the topic this one took the place of
|
|
315
401
|
*/
|
|
316
402
|
replaces?: string | undefined;
|
|
403
|
+
/**
|
|
404
|
+
* the package whose topic or guide this
|
|
405
|
+
* one took the place of
|
|
406
|
+
*/
|
|
407
|
+
replacedPackage?: string | undefined;
|
|
317
408
|
/**
|
|
318
409
|
* overlays to merge onto the base doc, in the order their integrations were
|
|
319
410
|
* configured; each section an extension adds resolves its links against the
|
|
@@ -67,6 +67,29 @@ const INTEGRATION_DOC_SUFFIXES = ['.doc.ts', '.doc.mjs', '.doc.js'];
|
|
|
67
67
|
/** A topic name is a CLI argument and a URL segment; keep it to both. */
|
|
68
68
|
const TOPIC_NAME_RE = /^[\w-]+$/;
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Whether a `replaces` or `extends` names a route of the docs tree rather than
|
|
72
|
+
* a flat topic: a topic name never holds a `/`, and a guide the tree places is
|
|
73
|
+
* always read by a route that does.
|
|
74
|
+
* @param {unknown} target
|
|
75
|
+
* @returns {target is string}
|
|
76
|
+
*/
|
|
77
|
+
export function isGuideRoute(target) {
|
|
78
|
+
return typeof target === 'string' && target.includes('/');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* What the integrations do to one guide the docs tree places, in configured
|
|
83
|
+
* order: a replacement, and the extensions merged onto whatever is there.
|
|
84
|
+
* @typedef {object} GuideOverlay
|
|
85
|
+
* @property {DocsTopicRecord | null} replacement the doc readers get at the
|
|
86
|
+
* route instead of the guide; the last package configured wins
|
|
87
|
+
* @property {Array<{package: string, path: string, providerId?: string}>} extensions
|
|
88
|
+
* extensions authored after the replacement, if any, in configured order
|
|
89
|
+
* @property {string} [replacedPackage] the package of the replacement this one
|
|
90
|
+
* took over from, when the guide was replaced twice
|
|
91
|
+
*/
|
|
92
|
+
|
|
70
93
|
/**
|
|
71
94
|
* @typedef {object} DocsTopicRecord A doc file discovered under a docs root.
|
|
72
95
|
* @property {string} name
|
|
@@ -92,6 +115,8 @@ const TOPIC_NAME_RE = /^[\w-]+$/;
|
|
|
92
115
|
* @property {string} [description]
|
|
93
116
|
* @property {string|null} [category]
|
|
94
117
|
* @property {string} [replaces] the topic this one took the place of
|
|
118
|
+
* @property {string} [replacedPackage] the package whose topic or guide this
|
|
119
|
+
* one took the place of
|
|
95
120
|
* @property {Array<{package: string, path: string, providerId?: string}>} extensions
|
|
96
121
|
* overlays to merge onto the base doc, in the order their integrations were
|
|
97
122
|
* configured; each section an extension adds resolves its links against the
|
|
@@ -205,7 +230,21 @@ const BLOCK_FIELD_VALUES = {
|
|
|
205
230
|
const PROJECTION_FIELDS = ['fields', 'sections'];
|
|
206
231
|
|
|
207
232
|
/** Keys a section may carry. */
|
|
208
|
-
const SECTION_FIELDS = [
|
|
233
|
+
const SECTION_FIELDS = [
|
|
234
|
+
'id',
|
|
235
|
+
'title',
|
|
236
|
+
'category',
|
|
237
|
+
'content',
|
|
238
|
+
'previewType',
|
|
239
|
+
'before',
|
|
240
|
+
'after',
|
|
241
|
+
];
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* The fields an extension section places itself with: the key of the base
|
|
245
|
+
* section it goes before or after. Read only by a merge, never by a reader.
|
|
246
|
+
*/
|
|
247
|
+
export const SECTION_POSITION_FIELDS = ['before', 'after'];
|
|
209
248
|
|
|
210
249
|
/**
|
|
211
250
|
* Check the fields the docs surfaces actually read. `parseDoc` is the outer
|
|
@@ -265,6 +304,19 @@ export function problemsInTopic(doc, {placement = false} = {}) {
|
|
|
265
304
|
problems.push(`${at}.${key}: not a field of a section`);
|
|
266
305
|
}
|
|
267
306
|
}
|
|
307
|
+
for (const field of SECTION_POSITION_FIELDS) {
|
|
308
|
+
const value = section?.[field];
|
|
309
|
+
if (value != null && (typeof value !== 'string' || value === '')) {
|
|
310
|
+
problems.push(
|
|
311
|
+
`${at}.${field}: expected the key of a section, as \`--index\` shows it`,
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (section?.before != null && section?.after != null) {
|
|
316
|
+
problems.push(
|
|
317
|
+
`${at}: sets both \`before\` and \`after\`; a section goes in one place`,
|
|
318
|
+
);
|
|
319
|
+
}
|
|
268
320
|
if (!Array.isArray(section?.content)) {
|
|
269
321
|
problems.push(`${at}.content: expected an array of blocks`);
|
|
270
322
|
return;
|
|
@@ -599,8 +651,9 @@ export async function discoverIntegrationDocs(integration) {
|
|
|
599
651
|
/**
|
|
600
652
|
* Merge an extension onto a base topic: a section with a stable `id` replaces
|
|
601
653
|
* the base section with the same `id`; legacy sections without IDs fall back to
|
|
602
|
-
* title matching. A section with no match is
|
|
603
|
-
*
|
|
654
|
+
* title matching. A section with no match is added: before or after the
|
|
655
|
+
* section whose key its `before` or `after` names, else at the end. The title
|
|
656
|
+
* and description stay the base topic's: an extension adds to a topic, it never
|
|
604
657
|
* renames it. A topic that `replaces` another is the one that renames.
|
|
605
658
|
*
|
|
606
659
|
* Keyed by section TITLE rather than by position, the way the localization
|
|
@@ -613,22 +666,123 @@ export async function discoverIntegrationDocs(integration) {
|
|
|
613
666
|
* @returns {any} a new doc; neither input is mutated
|
|
614
667
|
*/
|
|
615
668
|
export function mergeTopic(base, overlay) {
|
|
669
|
+
return mergeTopicReport(base, overlay).doc;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* {@link mergeTopic}, also naming each `before` or `after` that found no
|
|
674
|
+
* section: that section was added at the end instead.
|
|
675
|
+
*
|
|
676
|
+
* @param {any} base
|
|
677
|
+
* @param {any} overlay
|
|
678
|
+
* @returns {{doc: any, unplaced: Array<{section: string, field: 'before' | 'after', key: string}>}}
|
|
679
|
+
*/
|
|
680
|
+
export function mergeTopicReport(base, overlay) {
|
|
616
681
|
const sections = [...(base.sections ?? [])];
|
|
617
|
-
|
|
682
|
+
/** @type {Array<{section: string, field: 'before' | 'after', key: string}>} */
|
|
683
|
+
const unplaced = [];
|
|
684
|
+
|
|
685
|
+
for (const authored of overlay.sections ?? []) {
|
|
686
|
+
const section = withoutPosition(authored);
|
|
618
687
|
const at = findMergeTarget(sections, section);
|
|
619
688
|
if (at === -1) {
|
|
620
|
-
|
|
689
|
+
const field = authored.before != null ? 'before' : 'after';
|
|
690
|
+
const key = authored[field];
|
|
691
|
+
if (typeof key !== 'string') {
|
|
692
|
+
sections.push(section);
|
|
693
|
+
continue;
|
|
694
|
+
}
|
|
695
|
+
const anchor = sections.findIndex(
|
|
696
|
+
candidate => sectionKey(candidate) === key || candidate.id === key,
|
|
697
|
+
);
|
|
698
|
+
if (anchor === -1) {
|
|
699
|
+
unplaced.push({section: sectionKey(section), field, key});
|
|
700
|
+
sections.push(section);
|
|
701
|
+
} else if (field === 'before') {
|
|
702
|
+
// Placed just before a section another was placed `after`, it joins
|
|
703
|
+
// that section's group, so later sections placed there follow both.
|
|
704
|
+
if (sections[anchor][PLACED_AFTER] != null) {
|
|
705
|
+
Object.defineProperty(section, PLACED_AFTER, {
|
|
706
|
+
value: sections[anchor][PLACED_AFTER],
|
|
707
|
+
configurable: true,
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
sections.splice(anchor, 0, section);
|
|
711
|
+
} else {
|
|
712
|
+
// Sections placed after one key keep their order, across every
|
|
713
|
+
// extension merged onto the topic: each goes after every section
|
|
714
|
+
// placed there before it, and after the sections placed after those.
|
|
715
|
+
const group = new Set([key]);
|
|
716
|
+
let at = anchor + 1;
|
|
717
|
+
while (at < sections.length && group.has(sections[at][PLACED_AFTER])) {
|
|
718
|
+
group.add(sectionKey(sections[at]));
|
|
719
|
+
at += 1;
|
|
720
|
+
}
|
|
721
|
+
Object.defineProperty(section, PLACED_AFTER, {
|
|
722
|
+
value: key,
|
|
723
|
+
configurable: true,
|
|
724
|
+
});
|
|
725
|
+
sections.splice(at, 0, section);
|
|
726
|
+
}
|
|
621
727
|
} else {
|
|
622
728
|
// A legacy extension that replaces a section which has since gained a
|
|
623
|
-
// stable ID keeps that ID, so readers addressing it keep working.
|
|
729
|
+
// stable ID keeps that ID, so readers addressing it keep working. A
|
|
730
|
+
// replacing section keeps the place of the one it replaces.
|
|
624
731
|
const replaced = sections[at];
|
|
625
|
-
|
|
732
|
+
const replacing =
|
|
626
733
|
section.id == null && replaced.id != null
|
|
627
734
|
? withSourceTitle({...section, id: replaced.id}, sourceTitle(section))
|
|
628
735
|
: section;
|
|
736
|
+
// It also keeps the place an earlier `after` gave the one it replaces,
|
|
737
|
+
// so sections placed after that key later still follow it.
|
|
738
|
+
if (replaced[PLACED_AFTER] != null) {
|
|
739
|
+
const placed = replacing === section ? withoutPosition({...section}) : replacing;
|
|
740
|
+
for (const symbol of Object.getOwnPropertySymbols(section)) {
|
|
741
|
+
if (!(symbol in placed)) {
|
|
742
|
+
Object.defineProperty(
|
|
743
|
+
placed,
|
|
744
|
+
symbol,
|
|
745
|
+
/** @type {PropertyDescriptor} */ (
|
|
746
|
+
Object.getOwnPropertyDescriptor(section, symbol)
|
|
747
|
+
),
|
|
748
|
+
);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
Object.defineProperty(placed, PLACED_AFTER, {
|
|
752
|
+
value: replaced[PLACED_AFTER],
|
|
753
|
+
configurable: true,
|
|
754
|
+
});
|
|
755
|
+
sections[at] = placed;
|
|
756
|
+
} else {
|
|
757
|
+
sections[at] = replacing;
|
|
758
|
+
}
|
|
629
759
|
}
|
|
630
760
|
}
|
|
631
|
-
return {...base, sections};
|
|
761
|
+
return {doc: {...base, sections}, unplaced};
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/** The key a merged section was placed `after`, so later ones follow it. */
|
|
765
|
+
const PLACED_AFTER = Symbol('astryx.docs.placedAfter');
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* A section without the fields that place it; readers never see them.
|
|
769
|
+
* @param {any} section
|
|
770
|
+
* @returns {any}
|
|
771
|
+
*/
|
|
772
|
+
export function withoutPosition(section) {
|
|
773
|
+
if (section?.before == null && section?.after == null) return section;
|
|
774
|
+
const {before: _before, after: _after, ...rest} = section;
|
|
775
|
+
// Copy every own symbol (the provider and authored-title marks) too.
|
|
776
|
+
for (const symbol of Object.getOwnPropertySymbols(section)) {
|
|
777
|
+
Object.defineProperty(
|
|
778
|
+
rest,
|
|
779
|
+
symbol,
|
|
780
|
+
/** @type {PropertyDescriptor} */ (
|
|
781
|
+
Object.getOwnPropertyDescriptor(section, symbol)
|
|
782
|
+
),
|
|
783
|
+
);
|
|
784
|
+
}
|
|
785
|
+
return rest;
|
|
632
786
|
}
|
|
633
787
|
|
|
634
788
|
/**
|
|
@@ -723,6 +877,71 @@ export class DocsCatalog {
|
|
|
723
877
|
#treeInputs = [];
|
|
724
878
|
/** @type {Array<{package: string, message: string}>} */
|
|
725
879
|
#issues = [];
|
|
880
|
+
/** @type {Map<string, GuideOverlay>} lowercased route → what applies there */
|
|
881
|
+
#guideOverlays = new Map();
|
|
882
|
+
/** @type {DocsTopicRecord[]} every doc that targets a route, in order */
|
|
883
|
+
#guideTargeters = [];
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Record a doc that replaces or extends a guide the docs tree places, by
|
|
887
|
+
* its route. Whether the route holds such a guide is known only once the
|
|
888
|
+
* tree is built: {@link guideOverlay} applies the record there, and a route
|
|
889
|
+
* that holds none applies nothing.
|
|
890
|
+
* @param {DocsTopicRecord} record
|
|
891
|
+
* @returns {import('../integrations/issue').AstryxIntegrationIssue | null}
|
|
892
|
+
*/
|
|
893
|
+
#targetGuide(record) {
|
|
894
|
+
const route = /** @type {string} */ (
|
|
895
|
+
record.replaces ?? record.extendsTopic
|
|
896
|
+
);
|
|
897
|
+
const key = route.toLowerCase();
|
|
898
|
+
const overlay = this.#guideOverlays.get(key) ?? {
|
|
899
|
+
replacement: null,
|
|
900
|
+
extensions: [],
|
|
901
|
+
};
|
|
902
|
+
if (record.replaces != null) {
|
|
903
|
+
const earlier = overlay.replacement;
|
|
904
|
+
if (earlier) {
|
|
905
|
+
// As with a flat topic, the later-configured doc wins, and reads name
|
|
906
|
+
// the replacement it took over from. Unlike a flat topic's, this is
|
|
907
|
+
// no warning: a new failing finding joins only in a minor release
|
|
908
|
+
// (architecture:cli-surface INV35); `integration validate` lists one
|
|
909
|
+
// package's two replacements of a guide as a note.
|
|
910
|
+
overlay.replacedPackage = earlier.package;
|
|
911
|
+
}
|
|
912
|
+
// Extensions were authored against the content that just went away.
|
|
913
|
+
overlay.replacement = record;
|
|
914
|
+
overlay.extensions = [];
|
|
915
|
+
} else {
|
|
916
|
+
overlay.extensions.push({
|
|
917
|
+
package: record.package,
|
|
918
|
+
path: record.path,
|
|
919
|
+
...(record.providerId ? {providerId: record.providerId} : {}),
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
this.#guideOverlays.set(key, overlay);
|
|
923
|
+
this.#guideTargeters.push(record);
|
|
924
|
+
return null;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* What the integrations do to the guide the docs tree places at `route`, or
|
|
929
|
+
* null when they leave it as it is.
|
|
930
|
+
* @param {string} route
|
|
931
|
+
* @returns {GuideOverlay | null}
|
|
932
|
+
*/
|
|
933
|
+
guideOverlay(route) {
|
|
934
|
+
return this.#guideOverlays.get(route.toLowerCase()) ?? null;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Every doc that replaces or extends a guide by its route, in configured
|
|
939
|
+
* order, so a check can name a route that holds no guide.
|
|
940
|
+
* @returns {ReadonlyArray<DocsTopicRecord>}
|
|
941
|
+
*/
|
|
942
|
+
get guideTargeters() {
|
|
943
|
+
return this.#guideTargeters;
|
|
944
|
+
}
|
|
726
945
|
|
|
727
946
|
/**
|
|
728
947
|
* Record a doc file a package ships that did not load. Its package's docs
|
|
@@ -810,6 +1029,9 @@ export class DocsCatalog {
|
|
|
810
1029
|
add(record) {
|
|
811
1030
|
if (record.extendsTopic != null) {
|
|
812
1031
|
const target = this.resolve(record.extendsTopic);
|
|
1032
|
+
if (!target && isGuideRoute(record.extendsTopic)) {
|
|
1033
|
+
return this.#targetGuide(record);
|
|
1034
|
+
}
|
|
813
1035
|
if (!target) {
|
|
814
1036
|
return {
|
|
815
1037
|
code: 'invalid_doc',
|
|
@@ -827,6 +1049,9 @@ export class DocsCatalog {
|
|
|
827
1049
|
|
|
828
1050
|
if (record.replaces != null) {
|
|
829
1051
|
const target = this.resolve(record.replaces);
|
|
1052
|
+
if (!target && isGuideRoute(record.replaces)) {
|
|
1053
|
+
return this.#targetGuide(record);
|
|
1054
|
+
}
|
|
830
1055
|
if (!target) {
|
|
831
1056
|
return {
|
|
832
1057
|
code: 'invalid_doc',
|
|
@@ -859,6 +1084,9 @@ export class DocsCatalog {
|
|
|
859
1084
|
description: record.description,
|
|
860
1085
|
category: record.category,
|
|
861
1086
|
replaces: replaced,
|
|
1087
|
+
// The package whose topic it took over: an earlier replacement's, when
|
|
1088
|
+
// the topic was already replaced.
|
|
1089
|
+
replacedPackage: target.package,
|
|
862
1090
|
...(record.providerId ? {providerId: record.providerId} : {}),
|
|
863
1091
|
// Extensions were authored against the content that just went away.
|
|
864
1092
|
extensions: [],
|
|
@@ -23,7 +23,11 @@
|
|
|
23
23
|
|
|
24
24
|
import {parseTemplate} from '../../authoring/doctypes/template/parse.mjs';
|
|
25
25
|
import {parseTheme} from '../../authoring/doctypes/theme/parse.mjs';
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
mergeTopic,
|
|
28
|
+
problemsInTopic,
|
|
29
|
+
withoutPosition,
|
|
30
|
+
} from '../discovery/docs-discovery.mjs';
|
|
27
31
|
import {
|
|
28
32
|
sectionKey,
|
|
29
33
|
sectionKeyErrors,
|
|
@@ -179,6 +183,9 @@ export function lowerReferenceTopic(input) {
|
|
|
179
183
|
);
|
|
180
184
|
}
|
|
181
185
|
}
|
|
186
|
+
// `before` and `after` place an extension's sections while it merges; no
|
|
187
|
+
// read carries them, whether or not the doc extends anything.
|
|
188
|
+
doc = {...doc, sections: doc.sections.map(withoutPosition)};
|
|
182
189
|
// Derived keys are stamped only now, so they never take part in merging.
|
|
183
190
|
const keyed = withSectionKeys(doc);
|
|
184
191
|
/** @type {Record<string, string>} */
|
|
@@ -389,8 +389,11 @@ const LOADER_MODULES = {
|
|
|
389
389
|
'discoverIntegrationDocs',
|
|
390
390
|
'GRAPH_BLOCK_TYPES',
|
|
391
391
|
'GRAPH_ONLY_FIELDS',
|
|
392
|
+
'isGuideRoute',
|
|
392
393
|
'mergeTopic',
|
|
394
|
+
'mergeTopicReport',
|
|
393
395
|
'problemsInTopic',
|
|
396
|
+
'withoutPosition',
|
|
394
397
|
'withSourceTitle',
|
|
395
398
|
],
|
|
396
399
|
};
|
|
@@ -300,6 +300,11 @@ export type TreeNode = {
|
|
|
300
300
|
slots: TreeSlot[];
|
|
301
301
|
source: string;
|
|
302
302
|
ref?: any;
|
|
303
|
+
/**
|
|
304
|
+
* what integrations do to a guide the tree places, by its route: set by the
|
|
305
|
+
* project's tree, absent when nothing replaces or extends it
|
|
306
|
+
*/
|
|
307
|
+
guideOverlay?: import("../discovery/docs-discovery.mjs").GuideOverlay | undefined;
|
|
303
308
|
};
|
|
304
309
|
export type DocsTree = {
|
|
305
310
|
/**
|
|
@@ -178,6 +178,9 @@ export const topicLevel = category =>
|
|
|
178
178
|
* @property {TreeSlot[]} slots a namespace's slots; empty for a leaf
|
|
179
179
|
* @property {string} source
|
|
180
180
|
* @property {any} [ref]
|
|
181
|
+
* @property {import('../discovery/docs-discovery.mjs').GuideOverlay} [guideOverlay]
|
|
182
|
+
* what integrations do to a guide the tree places, by its route: set by the
|
|
183
|
+
* project's tree, absent when nothing replaces or extends it
|
|
181
184
|
*/
|
|
182
185
|
|
|
183
186
|
/**
|
|
@@ -56,6 +56,14 @@ export function componentReplacesCliProblem(pkg: any): string | null;
|
|
|
56
56
|
* @returns {string | null}
|
|
57
57
|
*/
|
|
58
58
|
export function sectionIdsCliProblem(pkg: any): string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Why a package with a doc section that sets `before` or `after` would lose
|
|
61
|
+
* its doc topics on an older CLI, or null when its declared CLI range admits
|
|
62
|
+
* only CLIs that read the fields (spec:AST-046 FR11).
|
|
63
|
+
* @param {any} pkg package.json
|
|
64
|
+
* @returns {string | null}
|
|
65
|
+
*/
|
|
66
|
+
export function sectionPositionCliProblem(pkg: any): string | null;
|
|
59
67
|
/**
|
|
60
68
|
* Why a package that ships a theme would lose its themes and doc topics on an
|
|
61
69
|
* older CLI, or null when its declared CLI range admits only CLIs that read
|
|
@@ -140,3 +148,9 @@ export const THEMES_CLI: "0.6.4";
|
|
|
140
148
|
* published 0.6.4 reads the section by its id.
|
|
141
149
|
*/
|
|
142
150
|
export const SECTION_IDS_CLI: "0.6.4";
|
|
151
|
+
/**
|
|
152
|
+
* The first CLI release that reads a doc section's `before` and `after`.
|
|
153
|
+
* Earlier releases reject the fields and hide every doc topic the package
|
|
154
|
+
* ships.
|
|
155
|
+
*/
|
|
156
|
+
export const SECTION_POSITION_CLI: "0.7.4";
|