@astryxdesign/cli 0.6.3-canary.00af005 → 0.6.3-canary.02d93e4
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/api/docs/_adapter.d.mts +7 -49
- package/api/docs/_adapter.mjs +33 -284
- package/api/docs/docs.doc.mjs +3 -4
- package/api/docs/docs.type.d.mts +5 -21
- package/api/docs/docs.type.mjs +5 -21
- package/api/docs/integration-tree.test.mjs +1 -9
- package/api/doctor/doctor.mjs +1 -5
- package/api/integration/authoring-checks.mjs +1 -14
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/authoring/doctypes/_schema.d.mts +0 -72
- package/authoring/doctypes/_schema.mjs +1 -25
- package/authoring/doctypes/load-contract.test.mjs +0 -25
- package/authoring/doctypes/reference/reference.doc.mjs +4 -31
- package/authoring/doctypes/reference/type.ts +5 -20
- package/clients/cli/commands/docs.mjs +2 -2
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
- package/foundation/discovery/authoring-self-docs.d.mts +0 -12
- package/foundation/discovery/authoring-self-docs.mjs +8 -20
- package/foundation/discovery/authoring-self-docs.test.mjs +2 -7
- package/foundation/discovery/docs-discovery.d.mts +1 -4
- package/foundation/discovery/docs-discovery.mjs +6 -40
- package/foundation/discovery/docs-discovery.test.mjs +0 -40
- package/foundation/doc-compiler/lenses.d.mts +3 -5
- package/foundation/doc-compiler/lenses.mjs +3 -48
- package/foundation/doc-compiler/links.d.mts +3 -30
- package/foundation/doc-compiler/links.mjs +5 -46
- package/foundation/doc-compiler/links.test.mjs +0 -53
- package/package.json +9 -9
- package/api/docs/reference-blocks.test.mjs +0 -406
package/api/docs/_adapter.d.mts
CHANGED
|
@@ -23,9 +23,8 @@ export function builtinCatalog(): DocsCatalog;
|
|
|
23
23
|
/**
|
|
24
24
|
* One topic, lowered for `lang` with every link between docs resolved
|
|
25
25
|
* (spec:AST-047 FR9): an inline `{@link <target>}` reads as the command that
|
|
26
|
-
* opens its doc, and a `reference` block carries the doc it
|
|
27
|
-
*
|
|
28
|
-
* lowered node.
|
|
26
|
+
* opens its doc, and a `reference` or `workflow` block carries the doc it
|
|
27
|
+
* names. Memoized per catalog and frozen, like the lowered node.
|
|
29
28
|
* @param {DocsCatalog} catalog
|
|
30
29
|
* @param {DocsTopicEntry} entry
|
|
31
30
|
* @param {string | null} [lang]
|
|
@@ -52,8 +51,9 @@ export function projectTree(catalog: DocsCatalog, { fresh }?: {
|
|
|
52
51
|
fresh?: boolean;
|
|
53
52
|
}): Promise<DocsTree>;
|
|
54
53
|
/**
|
|
55
|
-
* How a doc's links find their targets (spec:AST-047 FR9)
|
|
56
|
-
*
|
|
54
|
+
* How a doc's links find their targets (spec:AST-047 FR9): a doc in the
|
|
55
|
+
* project's docs tree by its identity, or a flat topic by its provider and
|
|
56
|
+
* name. A target that matches neither is a problem, never a guess.
|
|
57
57
|
* @param {DocsCatalog} catalog
|
|
58
58
|
* @param {string} fromProvider the provider id of the doc the links sit in
|
|
59
59
|
* @returns {Promise<LinkResolver>}
|
|
@@ -64,15 +64,11 @@ export function linkResolver(catalog: DocsCatalog, fromProvider: string): Promis
|
|
|
64
64
|
* guide the tree places, and each typed doc.
|
|
65
65
|
* @param {DocsCatalog} catalog
|
|
66
66
|
* @param {DocsTree} tree
|
|
67
|
-
* @param {{owner?: string
|
|
68
|
-
* docs this package owns. `references`: instead of the links, each reference
|
|
69
|
-
* block that cannot include what it names; a reader loses that content,
|
|
70
|
-
* where a link that names no doc still prints as written
|
|
67
|
+
* @param {{owner?: string}} [options] `owner`: only the docs this package owns
|
|
71
68
|
* @returns {Promise<string[]>}
|
|
72
69
|
*/
|
|
73
|
-
export function docsLinkProblems(catalog: DocsCatalog, tree: DocsTree, { owner
|
|
70
|
+
export function docsLinkProblems(catalog: DocsCatalog, tree: DocsTree, { owner }?: {
|
|
74
71
|
owner?: string;
|
|
75
|
-
references?: boolean;
|
|
76
72
|
}): Promise<string[]>;
|
|
77
73
|
/**
|
|
78
74
|
* What \`astryx doctor integration docs\` checks in one integration's docs: the
|
|
@@ -97,22 +93,6 @@ export function packageDocsProblems(integration: {
|
|
|
97
93
|
* @returns {(topic: string) => Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode | null>}
|
|
98
94
|
*/
|
|
99
95
|
export function referenceTargets(catalog: DocsCatalog, lang: string | null): (topic: string) => Promise<import("../../foundation/doc-compiler/compile.mjs").CompiledReferenceNode | null>;
|
|
100
|
-
/**
|
|
101
|
-
* Each reference block in one integration's docs that cannot include what it
|
|
102
|
-
* names (spec:AST-047 FR9): a target that names no doc, a field its schema
|
|
103
|
-
* does not have, or a projection its doc cannot take. A reader would lose
|
|
104
|
-
* that content, so `astryx doctor integration docs` fails on each.
|
|
105
|
-
* @param {{name: string}} integration
|
|
106
|
-
* @param {{records: import('../../foundation/discovery/docs-discovery.mjs').DocsTopicRecord[], namespaces: import('../../foundation/doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../../foundation/doc-compiler/tree.mjs').TreeDocInput[]}} discovered
|
|
107
|
-
* @returns {Promise<string[]>}
|
|
108
|
-
*/
|
|
109
|
-
export function packageReferenceProblems(integration: {
|
|
110
|
-
name: string;
|
|
111
|
-
}, discovered: {
|
|
112
|
-
records: import("../../foundation/discovery/docs-discovery.mjs").DocsTopicRecord[];
|
|
113
|
-
namespaces: import("../../foundation/doc-compiler/tree.mjs").TreeNamespaceInput[];
|
|
114
|
-
guides: import("../../foundation/doc-compiler/tree.mjs").TreeDocInput[];
|
|
115
|
-
}): Promise<string[]>;
|
|
116
96
|
/**
|
|
117
97
|
* One topic, compiled for `lang`: lowered, then every token reference linked.
|
|
118
98
|
* @param {DocsCatalog} catalog
|
|
@@ -265,32 +245,10 @@ export function resolveTopicDocs(topic: unknown, options?: {
|
|
|
265
245
|
lang: string | null;
|
|
266
246
|
entry: import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry;
|
|
267
247
|
}>;
|
|
268
|
-
/**
|
|
269
|
-
* A doc a link found: what a read shows of the link, and the typed doc behind
|
|
270
|
-
* it when a reference block can include it.
|
|
271
|
-
*/
|
|
272
|
-
export type FoundDoc = {
|
|
273
|
-
link: import("../../foundation/doc-compiler/links.mjs").DocLink;
|
|
274
|
-
/**
|
|
275
|
-
* the doc's kind
|
|
276
|
-
*/
|
|
277
|
-
kind: string;
|
|
278
|
-
/**
|
|
279
|
-
* a
|
|
280
|
-
* schema, command, function, or enum doc: a leaf of the docs tree (`tree`),
|
|
281
|
-
* or a section of `astryx docs authoring`; null for any other kind
|
|
282
|
-
*/
|
|
283
|
-
typed: {
|
|
284
|
-
doc: any;
|
|
285
|
-
providerId: string;
|
|
286
|
-
tree: boolean;
|
|
287
|
-
} | null;
|
|
288
|
-
};
|
|
289
248
|
export type DocsTree = import("../../foundation/doc-compiler/tree.mjs").DocsTree;
|
|
290
249
|
export type TreeNode = import("../../foundation/doc-compiler/tree.mjs").TreeNode;
|
|
291
250
|
export type LinkProblem = import("../../foundation/doc-compiler/links.mjs").LinkProblem;
|
|
292
251
|
export type LinkResolver = import("../../foundation/doc-compiler/links.mjs").LinkResolver;
|
|
293
|
-
export type DocIncluder = import("../../foundation/doc-compiler/links.mjs").DocIncluder;
|
|
294
252
|
export type DocsTopicEntry = import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry;
|
|
295
253
|
import { DocsCatalog } from '../../foundation/discovery/docs-discovery.mjs';
|
|
296
254
|
import { AstryxError } from '../error.mjs';
|
package/api/docs/_adapter.mjs
CHANGED
|
@@ -47,12 +47,6 @@ import {
|
|
|
47
47
|
cliDocIndex,
|
|
48
48
|
cliDocSection,
|
|
49
49
|
} from '../../foundation/discovery/cli-self-docs.mjs';
|
|
50
|
-
import {
|
|
51
|
-
loadAuthoringSelfDocs,
|
|
52
|
-
schemaFieldTable,
|
|
53
|
-
selfDocSection,
|
|
54
|
-
} from '../../foundation/discovery/authoring-self-docs.mjs';
|
|
55
|
-
import {CLI_PROVIDER_ID} from '../../foundation/identity/providers.mjs';
|
|
56
50
|
import {AstryxError} from '../error.mjs';
|
|
57
51
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
58
52
|
|
|
@@ -125,7 +119,6 @@ function lowerRawTopic(catalog, entry, lang = null) {
|
|
|
125
119
|
* @typedef {import('../../foundation/doc-compiler/tree.mjs').TreeNode} TreeNode
|
|
126
120
|
* @typedef {import('../../foundation/doc-compiler/links.mjs').LinkProblem} LinkProblem
|
|
127
121
|
* @typedef {import('../../foundation/doc-compiler/links.mjs').LinkResolver} LinkResolver
|
|
128
|
-
* @typedef {import('../../foundation/doc-compiler/links.mjs').DocIncluder} DocIncluder
|
|
129
122
|
* @typedef {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} DocsTopicEntry
|
|
130
123
|
*/
|
|
131
124
|
|
|
@@ -153,9 +146,8 @@ function providerOf(entry) {
|
|
|
153
146
|
/**
|
|
154
147
|
* One topic, lowered for `lang` with every link between docs resolved
|
|
155
148
|
* (spec:AST-047 FR9): an inline `{@link <target>}` reads as the command that
|
|
156
|
-
* opens its doc, and a `reference` block carries the doc it
|
|
157
|
-
*
|
|
158
|
-
* lowered node.
|
|
149
|
+
* opens its doc, and a `reference` or `workflow` block carries the doc it
|
|
150
|
+
* names. Memoized per catalog and frozen, like the lowered node.
|
|
159
151
|
* @param {DocsCatalog} catalog
|
|
160
152
|
* @param {DocsTopicEntry} entry
|
|
161
153
|
* @param {string | null} [lang]
|
|
@@ -191,19 +183,16 @@ function linkTopic(catalog, entry, lang) {
|
|
|
191
183
|
if (!linked) {
|
|
192
184
|
linked = (async () => {
|
|
193
185
|
const raw = await lowerRawTopic(catalog, entry, lang);
|
|
194
|
-
/** @type {Map<string,
|
|
195
|
-
const
|
|
186
|
+
/** @type {Map<string, LinkResolver>} */
|
|
187
|
+
const resolvers = new Map();
|
|
196
188
|
/** @param {string} provider */
|
|
197
|
-
const
|
|
198
|
-
let
|
|
199
|
-
if (!
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
include: await docIncluder(catalog, provider),
|
|
203
|
-
};
|
|
204
|
-
linkers.set(provider, linker);
|
|
189
|
+
const resolverFor = async provider => {
|
|
190
|
+
let resolve = resolvers.get(provider);
|
|
191
|
+
if (!resolve) {
|
|
192
|
+
resolve = await linkResolver(catalog, provider);
|
|
193
|
+
resolvers.set(provider, resolve);
|
|
205
194
|
}
|
|
206
|
-
return
|
|
195
|
+
return resolve;
|
|
207
196
|
};
|
|
208
197
|
/** @type {LinkProblem[]} */
|
|
209
198
|
const problems = [];
|
|
@@ -213,14 +202,12 @@ function linkTopic(catalog, entry, lang) {
|
|
|
213
202
|
// base topic's.
|
|
214
203
|
for (const section of raw.doc.sections) {
|
|
215
204
|
const provider = raw.sectionProviders?.[section.id];
|
|
216
|
-
const {resolve, include} = await linkerFor(
|
|
217
|
-
provider == null ? providerOf(entry) : normalizeProviderId(provider),
|
|
218
|
-
);
|
|
219
205
|
const linked = await linkBlocks(
|
|
220
206
|
section.content,
|
|
221
|
-
|
|
207
|
+
await resolverFor(
|
|
208
|
+
provider == null ? providerOf(entry) : normalizeProviderId(provider),
|
|
209
|
+
),
|
|
222
210
|
{section: section.id ?? section.title},
|
|
223
|
-
include,
|
|
224
211
|
);
|
|
225
212
|
problems.push(...linked.problems);
|
|
226
213
|
sections.push({...section, content: linked.content});
|
|
@@ -345,52 +332,15 @@ function identitiesOf(tree) {
|
|
|
345
332
|
return index;
|
|
346
333
|
}
|
|
347
334
|
|
|
348
|
-
/**
|
|
349
|
-
* The CLI's authoring docs, by kind and name. `astryx docs authoring` reads
|
|
350
|
-
* each as one section keyed by its name, so a link to one opens that section.
|
|
351
|
-
* Loaded once per process, like the CLI's tree files.
|
|
352
|
-
* @type {Promise<Map<string, any>> | undefined}
|
|
353
|
-
*/
|
|
354
|
-
let authoringDocs;
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* The CLI authoring doc a link names, while `astryx docs authoring` is the
|
|
358
|
-
* CLI's own topic.
|
|
359
|
-
* @param {DocsCatalog} catalog
|
|
360
|
-
* @param {string} kind
|
|
361
|
-
* @param {string} name
|
|
362
|
-
* @returns {Promise<any | null>}
|
|
363
|
-
*/
|
|
364
|
-
async function authoringDoc(catalog, kind, name) {
|
|
365
|
-
if (catalog.resolve('authoring')?.package !== CLI_PROVIDER_ID) return null;
|
|
366
|
-
authoringDocs ??= loadAuthoringSelfDocs().then(
|
|
367
|
-
({loaded}) =>
|
|
368
|
-
new Map(loaded.map(({doc}) => [`${doc.type}\u0000${doc.name}`, doc])),
|
|
369
|
-
);
|
|
370
|
-
return (await authoringDocs).get(`${kind}\u0000${name}`) ?? null;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* A doc a link found: what a read shows of the link, and the typed doc behind
|
|
375
|
-
* it when a reference block can include it.
|
|
376
|
-
* @typedef {object} FoundDoc
|
|
377
|
-
* @property {import('../../foundation/doc-compiler/links.mjs').DocLink} link
|
|
378
|
-
* @property {string} kind the doc's kind
|
|
379
|
-
* @property {{doc: any, providerId: string, tree: boolean} | null} typed a
|
|
380
|
-
* schema, command, function, or enum doc: a leaf of the docs tree (`tree`),
|
|
381
|
-
* or a section of `astryx docs authoring`; null for any other kind
|
|
382
|
-
*/
|
|
383
|
-
|
|
384
335
|
/**
|
|
385
336
|
* How a doc's links find their targets (spec:AST-047 FR9): a doc in the
|
|
386
|
-
* project's docs tree by its identity, a
|
|
387
|
-
*
|
|
388
|
-
* target that matches none is a problem, never a guess.
|
|
337
|
+
* project's docs tree by its identity, or a flat topic by its provider and
|
|
338
|
+
* name. A target that matches neither is a problem, never a guess.
|
|
389
339
|
* @param {DocsCatalog} catalog
|
|
390
340
|
* @param {string} fromProvider the provider id of the doc the links sit in
|
|
391
|
-
* @returns {Promise<
|
|
341
|
+
* @returns {Promise<LinkResolver>}
|
|
392
342
|
*/
|
|
393
|
-
async function
|
|
343
|
+
export async function linkResolver(catalog, fromProvider) {
|
|
394
344
|
const identities = identitiesOf(await projectTree(catalog));
|
|
395
345
|
return async target => {
|
|
396
346
|
const parsed = parseLinkTarget(target);
|
|
@@ -406,36 +356,12 @@ async function docFinder(catalog, fromProvider) {
|
|
|
406
356
|
const node = identities.get(identityKey(provider, parsed.kind, parsed.name));
|
|
407
357
|
if (node) {
|
|
408
358
|
return {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
command: `astryx docs ${node.route}`,
|
|
416
|
-
},
|
|
417
|
-
kind: node.kind,
|
|
418
|
-
typed: node.ref?.selfDoc
|
|
419
|
-
? {doc: node.ref.selfDoc, providerId: node.providerId, tree: true}
|
|
420
|
-
: null,
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
const authored =
|
|
424
|
-
provider === CLI_PROVIDER_ID
|
|
425
|
-
? await authoringDoc(catalog, parsed.kind, parsed.name)
|
|
426
|
-
: null;
|
|
427
|
-
if (authored) {
|
|
428
|
-
return {
|
|
429
|
-
link: {
|
|
430
|
-
target,
|
|
431
|
-
id: createDocId(provider, authored.type, authored.name),
|
|
432
|
-
route: 'authoring',
|
|
433
|
-
title: authored.displayName ?? authored.name,
|
|
434
|
-
summary: authored.description ?? '',
|
|
435
|
-
command: `astryx docs authoring ${authored.name}`,
|
|
436
|
-
},
|
|
437
|
-
kind: parsed.kind,
|
|
438
|
-
typed: {doc: authored, providerId: CLI_PROVIDER_ID, tree: false},
|
|
359
|
+
target,
|
|
360
|
+
id: /** @type {string} */ (node.id),
|
|
361
|
+
route: node.route,
|
|
362
|
+
title: node.title,
|
|
363
|
+
summary: node.summary,
|
|
364
|
+
command: `astryx docs ${node.route}`,
|
|
439
365
|
};
|
|
440
366
|
}
|
|
441
367
|
if (parsed.kind === 'generic') {
|
|
@@ -457,16 +383,12 @@ async function docFinder(catalog, fromProvider) {
|
|
|
457
383
|
// link still opens it.
|
|
458
384
|
}
|
|
459
385
|
return {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
command: `astryx docs ${entry.name}`,
|
|
467
|
-
},
|
|
468
|
-
kind: 'generic',
|
|
469
|
-
typed: null,
|
|
386
|
+
target,
|
|
387
|
+
id: createDocId(provider, 'generic', parsed.name),
|
|
388
|
+
route: entry.name,
|
|
389
|
+
title,
|
|
390
|
+
summary,
|
|
391
|
+
command: `astryx docs ${entry.name}`,
|
|
470
392
|
};
|
|
471
393
|
}
|
|
472
394
|
}
|
|
@@ -476,158 +398,20 @@ async function docFinder(catalog, fromProvider) {
|
|
|
476
398
|
};
|
|
477
399
|
}
|
|
478
400
|
|
|
479
|
-
/**
|
|
480
|
-
* How a doc's links find their targets (spec:AST-047 FR9), as
|
|
481
|
-
* {@link docFinder} finds them: each resolves to the link a read shows.
|
|
482
|
-
* @param {DocsCatalog} catalog
|
|
483
|
-
* @param {string} fromProvider the provider id of the doc the links sit in
|
|
484
|
-
* @returns {Promise<LinkResolver>}
|
|
485
|
-
*/
|
|
486
|
-
export async function linkResolver(catalog, fromProvider) {
|
|
487
|
-
const find = await docFinder(catalog, fromProvider);
|
|
488
|
-
return async target => {
|
|
489
|
-
const found = await find(target);
|
|
490
|
-
return 'problem' in found ? found : found.link;
|
|
491
|
-
};
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
/** How a problem names a doc kind that a reference block cannot include. */
|
|
495
|
-
const KIND_NAMES = /** @type {Record<string, string>} */ ({
|
|
496
|
-
generic: 'topic',
|
|
497
|
-
namespace: 'namespace',
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* How a topic's reference blocks include the docs they name (spec:AST-047
|
|
502
|
-
* FR9): a schema, command, function, or enum doc as `astryx docs` prints
|
|
503
|
-
* it, narrowed by the block's projection and presentation, with the included
|
|
504
|
-
* doc's own links resolved against its own provider. Any other doc shows its
|
|
505
|
-
* title and summary. Each part a block names that it cannot include is a
|
|
506
|
-
* problem, and a read marks where it is missing; a target that names no doc
|
|
507
|
-
* is the resolver's problem.
|
|
508
|
-
* @param {DocsCatalog} catalog
|
|
509
|
-
* @param {string} fromProvider the provider id of the doc the blocks sit in
|
|
510
|
-
* @returns {Promise<DocIncluder>}
|
|
511
|
-
*/
|
|
512
|
-
async function docIncluder(catalog, fromProvider) {
|
|
513
|
-
const find = await docFinder(catalog, fromProvider);
|
|
514
|
-
const tree = await projectTree(catalog);
|
|
515
|
-
return async block => {
|
|
516
|
-
const found = await find(block.target);
|
|
517
|
-
if ('problem' in found) return {content: [], problems: []};
|
|
518
|
-
return includedContent(catalog, tree, block, found);
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* What one reference block includes of the doc it found.
|
|
524
|
-
* @param {DocsCatalog} catalog
|
|
525
|
-
* @param {DocsTree} tree
|
|
526
|
-
* @param {any} block
|
|
527
|
-
* @param {FoundDoc} found
|
|
528
|
-
* @returns {Promise<{content: any[], problems: string[]}>}
|
|
529
|
-
*/
|
|
530
|
-
async function includedContent(catalog, tree, block, found) {
|
|
531
|
-
/** @type {string[]} */
|
|
532
|
-
const problems = [];
|
|
533
|
-
const {fields, sections} = block.projection ?? {};
|
|
534
|
-
const presentation = block.presentation ?? 'full';
|
|
535
|
-
if (sections != null) {
|
|
536
|
-
problems.push(
|
|
537
|
-
'projection.sections: a reference block does not include topic sections; reference a schema, command, function, or enum doc, and name the fields of a schema with projection.fields',
|
|
538
|
-
);
|
|
539
|
-
}
|
|
540
|
-
const typed = found.typed;
|
|
541
|
-
if (typed == null) {
|
|
542
|
-
// A reference shows any other doc only by its title and summary.
|
|
543
|
-
if (fields != null || (block.presentation ?? 'summary') !== 'summary') {
|
|
544
|
-
problems.push(
|
|
545
|
-
`"${block.target}" is a ${KIND_NAMES[found.kind] ?? `${found.kind} doc`}, which a reference block shows only by its title and summary; remove the projection and the presentation, or reference a schema, command, function, or enum doc`,
|
|
546
|
-
);
|
|
547
|
-
}
|
|
548
|
-
return {content: [], problems};
|
|
549
|
-
}
|
|
550
|
-
if (presentation === 'summary') {
|
|
551
|
-
if (fields != null) {
|
|
552
|
-
problems.push(
|
|
553
|
-
"projection.fields: a summary includes no fields; remove projection.fields or presentation: 'summary'",
|
|
554
|
-
);
|
|
555
|
-
}
|
|
556
|
-
return {content: [], problems};
|
|
557
|
-
}
|
|
558
|
-
/** @type {any[]} */
|
|
559
|
-
let content;
|
|
560
|
-
if (fields != null && typed.doc.type === 'schema') {
|
|
561
|
-
/** @type {Map<string, any>} */
|
|
562
|
-
const byName = new Map(
|
|
563
|
-
(typed.doc.fields ?? []).map((/** @type {any} */ field) => [
|
|
564
|
-
field.name,
|
|
565
|
-
field,
|
|
566
|
-
]),
|
|
567
|
-
);
|
|
568
|
-
const selected = [];
|
|
569
|
-
/** @type {any[]} */
|
|
570
|
-
const missing = [];
|
|
571
|
-
for (const name of fields) {
|
|
572
|
-
const field = byName.get(name);
|
|
573
|
-
if (field) {
|
|
574
|
-
selected.push(field);
|
|
575
|
-
continue;
|
|
576
|
-
}
|
|
577
|
-
problems.push(
|
|
578
|
-
`projection.fields: "${name}" is not a field of ${found.link.title} (${block.target}). Its fields: ${[...byName.keys()].join(', ')}`,
|
|
579
|
-
);
|
|
580
|
-
missing.push({
|
|
581
|
-
type: 'prose',
|
|
582
|
-
text: `[reference: field "${name}" not found in "${block.target}"]`,
|
|
583
|
-
});
|
|
584
|
-
}
|
|
585
|
-
const table = schemaFieldTable(selected);
|
|
586
|
-
content = [...(table ? [table] : []), ...missing];
|
|
587
|
-
} else {
|
|
588
|
-
if (fields != null) {
|
|
589
|
-
problems.push(
|
|
590
|
-
`projection.fields: names the fields of a schema doc, and "${block.target}" is a ${typed.doc.type} doc; remove it to include the whole doc`,
|
|
591
|
-
);
|
|
592
|
-
}
|
|
593
|
-
content = typed.tree
|
|
594
|
-
? cliDocSection(typed.doc, typedDocIndex(tree)).content
|
|
595
|
-
: selfDocSection(typed.doc).content;
|
|
596
|
-
}
|
|
597
|
-
if (presentation === 'compact') {
|
|
598
|
-
content = content.filter(each => each?.type !== 'code');
|
|
599
|
-
}
|
|
600
|
-
// The included doc's own links resolve against its own provider. A link in
|
|
601
|
-
// it that names no doc is that doc's problem, reported where it is written.
|
|
602
|
-
const linked = await linkBlocks(
|
|
603
|
-
content,
|
|
604
|
-
await linkResolver(catalog, typed.providerId),
|
|
605
|
-
);
|
|
606
|
-
return {content: linked.content, problems};
|
|
607
|
-
}
|
|
608
|
-
|
|
609
401
|
/**
|
|
610
402
|
* Every link in the project's docs that names no doc: in each topic, each
|
|
611
403
|
* guide the tree places, and each typed doc.
|
|
612
404
|
* @param {DocsCatalog} catalog
|
|
613
405
|
* @param {DocsTree} tree
|
|
614
|
-
* @param {{owner?: string
|
|
615
|
-
* docs this package owns. `references`: instead of the links, each reference
|
|
616
|
-
* block that cannot include what it names; a reader loses that content,
|
|
617
|
-
* where a link that names no doc still prints as written
|
|
406
|
+
* @param {{owner?: string}} [options] `owner`: only the docs this package owns
|
|
618
407
|
* @returns {Promise<string[]>}
|
|
619
408
|
*/
|
|
620
|
-
export async function docsLinkProblems(
|
|
621
|
-
catalog,
|
|
622
|
-
tree,
|
|
623
|
-
{owner, references = false} = {},
|
|
624
|
-
) {
|
|
409
|
+
export async function docsLinkProblems(catalog, tree, {owner} = {}) {
|
|
625
410
|
/** @type {string[]} */
|
|
626
411
|
const problems = [];
|
|
627
412
|
/** @param {string} where @param {LinkProblem[]} found */
|
|
628
413
|
const note = (where, found) => {
|
|
629
414
|
for (const problem of found) {
|
|
630
|
-
if ((problem.include === true) !== references) continue;
|
|
631
415
|
problems.push(
|
|
632
416
|
`${where}${problem.section ? ` \u00a7 ${problem.section}` : ''}: ${problem.message}`,
|
|
633
417
|
);
|
|
@@ -703,28 +487,6 @@ export function referenceTargets(catalog, lang) {
|
|
|
703
487
|
};
|
|
704
488
|
}
|
|
705
489
|
|
|
706
|
-
/**
|
|
707
|
-
* Each reference block in one integration's docs that cannot include what it
|
|
708
|
-
* names (spec:AST-047 FR9): a target that names no doc, a field its schema
|
|
709
|
-
* does not have, or a projection its doc cannot take. A reader would lose
|
|
710
|
-
* that content, so `astryx doctor integration docs` fails on each.
|
|
711
|
-
* @param {{name: string}} integration
|
|
712
|
-
* @param {{records: import('../../foundation/discovery/docs-discovery.mjs').DocsTopicRecord[], namespaces: import('../../foundation/doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../../foundation/doc-compiler/tree.mjs').TreeDocInput[]}} discovered
|
|
713
|
-
* @returns {Promise<string[]>}
|
|
714
|
-
*/
|
|
715
|
-
export async function packageReferenceProblems(integration, discovered) {
|
|
716
|
-
const catalog = DocsCatalog.fromBuiltins();
|
|
717
|
-
for (const record of discovered.records) catalog.add(record);
|
|
718
|
-
catalog.addTreeInputs({
|
|
719
|
-
namespaces: discovered.namespaces.map(input => ({...input, rank: 1})),
|
|
720
|
-
guides: discovered.guides.map(input => ({...input, rank: 1})),
|
|
721
|
-
});
|
|
722
|
-
return docsLinkProblems(catalog, await projectTree(catalog), {
|
|
723
|
-
owner: integration.name,
|
|
724
|
-
references: true,
|
|
725
|
-
});
|
|
726
|
-
}
|
|
727
|
-
|
|
728
490
|
/**
|
|
729
491
|
* One topic, compiled for `lang`: lowered, then every token reference linked.
|
|
730
492
|
* @param {DocsCatalog} catalog
|
|
@@ -773,20 +535,6 @@ const typedDocIndexes = new WeakMap();
|
|
|
773
535
|
*/
|
|
774
536
|
export async function nodeContent(catalog, tree, node) {
|
|
775
537
|
if (!node.ref?.selfDoc) return {content: [], problems: []};
|
|
776
|
-
const resolve = await linkResolver(catalog, node.providerId);
|
|
777
|
-
return linkBlocks(
|
|
778
|
-
cliDocSection(node.ref.selfDoc, typedDocIndex(tree)).content,
|
|
779
|
-
resolve,
|
|
780
|
-
);
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
/**
|
|
784
|
-
* The index a typed doc's content reads its cross-links from: every typed doc
|
|
785
|
-
* in the tree. Built once per tree.
|
|
786
|
-
* @param {DocsTree} tree
|
|
787
|
-
* @returns {ReturnType<typeof cliDocIndex>}
|
|
788
|
-
*/
|
|
789
|
-
function typedDocIndex(tree) {
|
|
790
538
|
let index = typedDocIndexes.get(tree);
|
|
791
539
|
if (!index) {
|
|
792
540
|
index = cliDocIndex(
|
|
@@ -796,7 +544,8 @@ function typedDocIndex(tree) {
|
|
|
796
544
|
);
|
|
797
545
|
typedDocIndexes.set(tree, index);
|
|
798
546
|
}
|
|
799
|
-
|
|
547
|
+
const resolve = await linkResolver(catalog, node.providerId);
|
|
548
|
+
return linkBlocks(cliDocSection(node.ref.selfDoc, index).content, resolve);
|
|
800
549
|
}
|
|
801
550
|
|
|
802
551
|
/**
|
package/api/docs/docs.doc.mjs
CHANGED
|
@@ -20,8 +20,7 @@ export const doc = {
|
|
|
20
20
|
'ReferenceDoc, and `index: true` returns its section index (each ' +
|
|
21
21
|
'section\'s key, title, and summary); a topic plus a section returns ' +
|
|
22
22
|
'that one section. Token-ref blocks are ' +
|
|
23
|
-
'inlined in every read
|
|
24
|
-
'includes, then the command that opens that doc. The topic set is the CLI\'s own docs plus the ' +
|
|
23
|
+
'inlined in every read. The topic set is the CLI\'s own docs plus the ' +
|
|
25
24
|
'ones the project\'s configured integrations contribute, including any ' +
|
|
26
25
|
'topic an integration replaces or extends, so it depends on the cwd. ' +
|
|
27
26
|
'A route opens a node of the docs tree instead: a namespace such as ' +
|
|
@@ -98,7 +97,7 @@ export const doc = {
|
|
|
98
97
|
{
|
|
99
98
|
type: 'docs.detail',
|
|
100
99
|
description:
|
|
101
|
-
"One topic's full ReferenceDoc, with token-ref
|
|
100
|
+
"One topic's full ReferenceDoc, with token-ref blocks inlined, plus links.",
|
|
102
101
|
},
|
|
103
102
|
{
|
|
104
103
|
type: 'docs.index',
|
|
@@ -108,7 +107,7 @@ export const doc = {
|
|
|
108
107
|
{
|
|
109
108
|
type: 'docs.detail.section',
|
|
110
109
|
description:
|
|
111
|
-
'One ReferenceSection of the topic, found by key or title, with token-ref
|
|
110
|
+
'One ReferenceSection of the topic, found by key or title, with token-ref blocks inlined.',
|
|
112
111
|
},
|
|
113
112
|
{
|
|
114
113
|
type: 'docs.node',
|
package/api/docs/docs.type.d.mts
CHANGED
|
@@ -67,31 +67,15 @@ export type DocsDetailResponse = {
|
|
|
67
67
|
/**
|
|
68
68
|
* the whole doc, and the moves from it
|
|
69
69
|
*/
|
|
70
|
-
data:
|
|
70
|
+
data: import("@astryxdesign/cli/authoring").ReferenceDoc & {
|
|
71
71
|
links: DocsLinks;
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
|
-
/**
|
|
75
|
-
* A topic section as a read returns it. A read inlines each token reference
|
|
76
|
-
* and each `reference` block the author wrote, so its content holds only the
|
|
77
|
-
* stable ReferenceContentBlock kinds.
|
|
78
|
-
*/
|
|
79
|
-
export type DocsReadSection = Omit<import("@astryxdesign/cli/authoring").ReferenceSection, "content"> & {
|
|
80
|
-
content: import("@astryxdesign/cli/authoring").ReferenceContentBlock[];
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* A topic as a read returns it: every section a {@link DocsReadSection}.
|
|
84
|
-
*/
|
|
85
|
-
export type DocsReadDoc = Omit<import("@astryxdesign/cli/authoring").ReferenceDoc, "sections"> & {
|
|
86
|
-
sections: DocsReadSection[];
|
|
87
|
-
};
|
|
88
74
|
/**
|
|
89
75
|
* The doc a link opens (spec:AST-047 FR9). A docs read resolves every link:
|
|
90
|
-
* an inline `{@link <target>}` reads as `link.command`, a `reference` block
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* section's `reference` block as the doc it includes, then a line naming where
|
|
94
|
-
* that comes from and the command that opens it.
|
|
76
|
+
* an inline `{@link <target>}` reads as `link.command`, a `reference` block
|
|
77
|
+
* carries `link` (null when the target names no doc), and each `workflow` step
|
|
78
|
+
* carries `links`, one per reference.
|
|
95
79
|
*/
|
|
96
80
|
export type DocLink = import("../../foundation/doc-compiler/links.mjs").DocLink;
|
|
97
81
|
/**
|
|
@@ -162,7 +146,7 @@ export type DocsDetailSectionResponse = {
|
|
|
162
146
|
* the section, and the moves from it: up to its topic's index, and across to
|
|
163
147
|
* the sections before and after it
|
|
164
148
|
*/
|
|
165
|
-
data:
|
|
149
|
+
data: import("@astryxdesign/cli/authoring").ReferenceSection & {
|
|
166
150
|
links: DocsLinks;
|
|
167
151
|
};
|
|
168
152
|
};
|
package/api/docs/docs.type.mjs
CHANGED
|
@@ -56,31 +56,15 @@
|
|
|
56
56
|
* astryx --json docs <topic>
|
|
57
57
|
* @typedef {object} DocsDetailResponse
|
|
58
58
|
* @property {'docs.detail'} type
|
|
59
|
-
* @property {
|
|
59
|
+
* @property {import('@astryxdesign/cli/authoring').ReferenceDoc & {links: DocsLinks}} data
|
|
60
60
|
* the whole doc, and the moves from it
|
|
61
61
|
*/
|
|
62
62
|
|
|
63
|
-
/**
|
|
64
|
-
* A topic section as a read returns it. A read inlines each token reference
|
|
65
|
-
* and each `reference` block the author wrote, so its content holds only the
|
|
66
|
-
* stable ReferenceContentBlock kinds.
|
|
67
|
-
* @typedef {Omit<import('@astryxdesign/cli/authoring').ReferenceSection, 'content'>
|
|
68
|
-
* & {content: import('@astryxdesign/cli/authoring').ReferenceContentBlock[]}} DocsReadSection
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* A topic as a read returns it: every section a {@link DocsReadSection}.
|
|
73
|
-
* @typedef {Omit<import('@astryxdesign/cli/authoring').ReferenceDoc, 'sections'>
|
|
74
|
-
* & {sections: DocsReadSection[]}} DocsReadDoc
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
63
|
/**
|
|
78
64
|
* The doc a link opens (spec:AST-047 FR9). A docs read resolves every link:
|
|
79
|
-
* an inline `{@link <target>}` reads as `link.command`, a `reference` block
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* section's `reference` block as the doc it includes, then a line naming where
|
|
83
|
-
* that comes from and the command that opens it.
|
|
65
|
+
* an inline `{@link <target>}` reads as `link.command`, a `reference` block
|
|
66
|
+
* carries `link` (null when the target names no doc), and each `workflow` step
|
|
67
|
+
* carries `links`, one per reference.
|
|
84
68
|
* @typedef {import('../../foundation/doc-compiler/links.mjs').DocLink} DocLink
|
|
85
69
|
*/
|
|
86
70
|
|
|
@@ -126,7 +110,7 @@
|
|
|
126
110
|
* astryx --json docs <topic> <section>
|
|
127
111
|
* @typedef {object} DocsDetailSectionResponse
|
|
128
112
|
* @property {'docs.detail.section'} type
|
|
129
|
-
* @property {
|
|
113
|
+
* @property {import('@astryxdesign/cli/authoring').ReferenceSection & {links: DocsLinks}} data
|
|
130
114
|
* the section, and the moves from it: up to its topic's index, and across to
|
|
131
115
|
* the sections before and after it
|
|
132
116
|
*/
|
|
@@ -151,15 +151,7 @@ describe('integration docs in the docs tree', () => {
|
|
|
151
151
|
title: 'Broken',
|
|
152
152
|
description: 'A topic whose block no topic may hold.',
|
|
153
153
|
sections: [
|
|
154
|
-
{
|
|
155
|
-
title: 'Only',
|
|
156
|
-
content: [
|
|
157
|
-
{
|
|
158
|
-
type: 'workflow',
|
|
159
|
-
steps: [{title: 'Set up', references: ['generic:setup']}],
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
},
|
|
154
|
+
{title: 'Only', content: [{type: 'reference', target: 'generic:setup'}]},
|
|
163
155
|
],
|
|
164
156
|
},
|
|
165
157
|
});
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -1032,17 +1032,13 @@ export async function checkDocsTree(_ctx, options = {}) {
|
|
|
1032
1032
|
}
|
|
1033
1033
|
}
|
|
1034
1034
|
// Every link between docs names a doc that exists (spec:AST-047 FR9):
|
|
1035
|
-
// typed fields, reference and workflow blocks, and inline links.
|
|
1036
|
-
// reference block also includes all it names.
|
|
1035
|
+
// typed fields, reference and workflow blocks, and inline links.
|
|
1037
1036
|
for (const node of tree.nodes.values()) {
|
|
1038
1037
|
for (const edge of typedEdges(tree, node).unresolved) {
|
|
1039
1038
|
problems.push(`${node.route}: ${edge}`);
|
|
1040
1039
|
}
|
|
1041
1040
|
}
|
|
1042
1041
|
problems.push(...(await docsLinkProblems(catalog, tree)));
|
|
1043
|
-
problems.push(
|
|
1044
|
-
...(await docsLinkProblems(catalog, tree, {references: true})),
|
|
1045
|
-
);
|
|
1046
1042
|
}
|
|
1047
1043
|
// New findings warn: a project that passed before keeps passing
|
|
1048
1044
|
// (0.6 compatibility), and the warning names what to fix.
|