@astryxdesign/cli 0.6.3-canary.aa04154 → 0.6.3-canary.abbb293
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 +49 -7
- package/api/docs/_adapter.mjs +284 -33
- package/api/docs/docs.doc.mjs +4 -3
- package/api/docs/docs.type.d.mts +21 -5
- package/api/docs/docs.type.mjs +21 -5
- package/api/docs/integration-tree.test.mjs +9 -1
- package/api/docs/reference-blocks.test.mjs +406 -0
- package/api/doctor/doctor.mjs +5 -1
- package/api/integration/authoring-checks.mjs +14 -1
- package/api/template/table-floating-bulk-actions.test.mjs +66 -0
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
- package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
- package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
- package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
- package/authoring/doctypes/_schema.d.mts +72 -0
- package/authoring/doctypes/_schema.mjs +25 -1
- package/authoring/doctypes/load-contract.test.mjs +25 -0
- package/authoring/doctypes/reference/reference.doc.mjs +31 -4
- package/authoring/doctypes/reference/type.ts +20 -5
- 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 +12 -0
- package/foundation/discovery/authoring-self-docs.mjs +20 -8
- package/foundation/discovery/authoring-self-docs.test.mjs +7 -2
- package/foundation/discovery/docs-discovery.d.mts +4 -1
- package/foundation/discovery/docs-discovery.mjs +40 -6
- package/foundation/discovery/docs-discovery.test.mjs +40 -0
- package/foundation/doc-compiler/lenses.d.mts +5 -3
- package/foundation/doc-compiler/lenses.mjs +48 -3
- package/foundation/doc-compiler/links.d.mts +30 -3
- package/foundation/doc-compiler/links.mjs +46 -5
- package/foundation/doc-compiler/links.test.mjs +53 -0
- package/foundation/integrations/cli-requirement.test.mjs +17 -42
- package/package.json +9 -9
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import {useState} from 'react';
|
|
6
|
+
import * as stylex from '@stylexjs/stylex';
|
|
7
|
+
import {Button} from '@astryxdesign/core/Button';
|
|
8
|
+
import {ScrollableArea} from '@astryxdesign/core/ScrollableArea';
|
|
9
|
+
import {
|
|
10
|
+
Table,
|
|
11
|
+
TableSelectionToolbar,
|
|
12
|
+
useTableSelection,
|
|
13
|
+
useTableSelectionState,
|
|
14
|
+
proportional,
|
|
15
|
+
} from '@astryxdesign/core/Table';
|
|
16
|
+
import type {TableColumn} from '@astryxdesign/core/Table';
|
|
17
|
+
import {
|
|
18
|
+
colorVars,
|
|
19
|
+
radiusVars,
|
|
20
|
+
shadowVars,
|
|
21
|
+
sizeVars,
|
|
22
|
+
spacingVars,
|
|
23
|
+
} from '@astryxdesign/core/theme/tokens.stylex';
|
|
24
|
+
|
|
25
|
+
interface User extends Record<string, unknown> {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
email: string;
|
|
29
|
+
role: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const baseUsers: Array<Pick<User, 'name' | 'email' | 'role'>> = [
|
|
33
|
+
{name: 'Alice', email: 'alice@example.com', role: 'Engineer'},
|
|
34
|
+
{name: 'Bob', email: 'bob@example.com', role: 'Designer'},
|
|
35
|
+
{name: 'Charlie', email: 'charlie@example.com', role: 'Manager'},
|
|
36
|
+
{name: 'Diana', email: 'diana@example.com', role: 'Engineer'},
|
|
37
|
+
{name: 'Eve', email: 'eve@example.com', role: 'Admin'},
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const users: User[] = Array.from({length: 40}, (_, index) => {
|
|
41
|
+
const user = baseUsers[index % baseUsers.length];
|
|
42
|
+
return {...user, id: String(index + 1), name: `${user.name} ${index + 1}`};
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const columns: TableColumn<User>[] = [
|
|
46
|
+
{key: 'name', header: 'Name', width: proportional(1)},
|
|
47
|
+
{key: 'email', header: 'Email', width: proportional(1)},
|
|
48
|
+
{key: 'role', header: 'Role', width: proportional(1)},
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const styles = stylex.create({
|
|
52
|
+
page: {
|
|
53
|
+
maxBlockSize: 640,
|
|
54
|
+
isolation: 'isolate',
|
|
55
|
+
scrollbarGutter: 'stable',
|
|
56
|
+
},
|
|
57
|
+
metrics: {
|
|
58
|
+
display: 'grid',
|
|
59
|
+
gridTemplateColumns: 'repeat(3, minmax(0, 1fr))',
|
|
60
|
+
gap: spacingVars['--spacing-3'],
|
|
61
|
+
marginBlockEnd: spacingVars['--spacing-6'],
|
|
62
|
+
},
|
|
63
|
+
metricCard: {
|
|
64
|
+
padding: spacingVars['--spacing-4'],
|
|
65
|
+
borderRadius: radiusVars['--radius-container'],
|
|
66
|
+
backgroundColor: colorVars['--color-background-muted'],
|
|
67
|
+
},
|
|
68
|
+
metricLabel: {
|
|
69
|
+
display: 'block',
|
|
70
|
+
color: colorVars['--color-text-secondary'],
|
|
71
|
+
},
|
|
72
|
+
metricValue: {
|
|
73
|
+
display: 'block',
|
|
74
|
+
marginBlockStart: spacingVars['--spacing-1'],
|
|
75
|
+
color: colorVars['--color-text-primary'],
|
|
76
|
+
},
|
|
77
|
+
tableRegion: {
|
|
78
|
+
'--table-bulk-actions-space': `calc(${sizeVars['--size-element-sm']} + ${spacingVars['--spacing-2']} + ${spacingVars['--spacing-2']} + ${spacingVars['--spacing-4']})`,
|
|
79
|
+
position: 'relative',
|
|
80
|
+
paddingBlockStart: 'var(--table-bulk-actions-space)',
|
|
81
|
+
},
|
|
82
|
+
toolbar: {
|
|
83
|
+
position: 'sticky',
|
|
84
|
+
insetBlockStart: `calc(var(--table-bulk-actions-space) + ${spacingVars['--spacing-4']})`,
|
|
85
|
+
transform: 'translateY(calc(0px - var(--table-bulk-actions-space)))',
|
|
86
|
+
marginBlockEnd: `calc(${spacingVars['--spacing-4']} - var(--table-bulk-actions-space))`,
|
|
87
|
+
zIndex: 1,
|
|
88
|
+
borderRadius: radiusVars['--radius-element'],
|
|
89
|
+
boxShadow: shadowVars['--shadow-med'],
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export default function TableFloatingBulkActionsTable() {
|
|
94
|
+
const [selectedKeys, setSelectedKeys] = useState<Set<string>>(new Set());
|
|
95
|
+
|
|
96
|
+
const {selectionConfig, selectionState} = useTableSelectionState<User>({
|
|
97
|
+
data: users,
|
|
98
|
+
idKey: 'id',
|
|
99
|
+
selectedKeys,
|
|
100
|
+
setSelectedKeys,
|
|
101
|
+
});
|
|
102
|
+
const selectionPlugin = useTableSelection<User>(selectionConfig);
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<ScrollableArea
|
|
106
|
+
axis="block"
|
|
107
|
+
label="Bulk actions example"
|
|
108
|
+
overscroll="contain"
|
|
109
|
+
xstyle={styles.page}>
|
|
110
|
+
<div {...stylex.props(styles.metrics)}>
|
|
111
|
+
{[
|
|
112
|
+
['Active users', '12,840'],
|
|
113
|
+
['Selection rate', '18.4%'],
|
|
114
|
+
['Pending reviews', '247'],
|
|
115
|
+
].map(([label, value]) => (
|
|
116
|
+
<div key={label} {...stylex.props(styles.metricCard)}>
|
|
117
|
+
<span {...stylex.props(styles.metricLabel)}>{label}</span>
|
|
118
|
+
<strong {...stylex.props(styles.metricValue)}>{value}</strong>
|
|
119
|
+
</div>
|
|
120
|
+
))}
|
|
121
|
+
</div>
|
|
122
|
+
<div {...stylex.props(styles.tableRegion)}>
|
|
123
|
+
<TableSelectionToolbar
|
|
124
|
+
selection={selectionState}
|
|
125
|
+
xstyle={styles.toolbar}
|
|
126
|
+
startContent={
|
|
127
|
+
<Button label="Approve" variant="ghost" onClick={() => {}} />
|
|
128
|
+
}
|
|
129
|
+
/>
|
|
130
|
+
<Table
|
|
131
|
+
data={users}
|
|
132
|
+
columns={columns}
|
|
133
|
+
idKey="id"
|
|
134
|
+
plugins={{selection: selectionPlugin}}
|
|
135
|
+
/>
|
|
136
|
+
</div>
|
|
137
|
+
</ScrollableArea>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
@@ -93,6 +93,52 @@ export const GraphContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
93
93
|
full: "full";
|
|
94
94
|
}>>;
|
|
95
95
|
}, z.core.$strict>], "type">;
|
|
96
|
+
/**
|
|
97
|
+
* A topic section's blocks: the stable union, plus a reference block, which a
|
|
98
|
+
* read inlines as the doc it includes.
|
|
99
|
+
*/
|
|
100
|
+
export const SectionContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
101
|
+
type: z.ZodLiteral<"prose">;
|
|
102
|
+
text: z.ZodString;
|
|
103
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
104
|
+
type: z.ZodLiteral<"heading">;
|
|
105
|
+
level: z.ZodUnion<readonly [z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<6>]>;
|
|
106
|
+
text: z.ZodString;
|
|
107
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
108
|
+
type: z.ZodLiteral<"code">;
|
|
109
|
+
lang: z.ZodString;
|
|
110
|
+
code: z.ZodString;
|
|
111
|
+
label: z.ZodOptional<z.ZodString>;
|
|
112
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
113
|
+
type: z.ZodLiteral<"table">;
|
|
114
|
+
headers: z.ZodArray<z.ZodString>;
|
|
115
|
+
rows: z.ZodArray<z.ZodArray<z.ZodString>>;
|
|
116
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
117
|
+
type: z.ZodLiteral<"list">;
|
|
118
|
+
style: z.ZodEnum<{
|
|
119
|
+
ordered: "ordered";
|
|
120
|
+
unordered: "unordered";
|
|
121
|
+
do: "do";
|
|
122
|
+
dont: "dont";
|
|
123
|
+
}>;
|
|
124
|
+
items: z.ZodArray<z.ZodString>;
|
|
125
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
126
|
+
type: z.ZodLiteral<"token-ref">;
|
|
127
|
+
topic: z.ZodString;
|
|
128
|
+
section: z.ZodString;
|
|
129
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
130
|
+
type: z.ZodLiteral<"reference">;
|
|
131
|
+
target: z.ZodString;
|
|
132
|
+
projection: z.ZodOptional<z.ZodObject<{
|
|
133
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
134
|
+
sections: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
135
|
+
}, z.core.$strict>>;
|
|
136
|
+
presentation: z.ZodOptional<z.ZodEnum<{
|
|
137
|
+
compact: "compact";
|
|
138
|
+
summary: "summary";
|
|
139
|
+
full: "full";
|
|
140
|
+
}>>;
|
|
141
|
+
}, z.core.$strict>], "type">;
|
|
96
142
|
/** Namespace content accepts both stable reference blocks and graph-only blocks. */
|
|
97
143
|
export const NamespaceContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
98
144
|
type: z.ZodLiteral<"prose">;
|
|
@@ -303,6 +349,18 @@ export const GenericDocKindSchema: z.ZodObject<{
|
|
|
303
349
|
type: z.ZodLiteral<"token-ref">;
|
|
304
350
|
topic: z.ZodString;
|
|
305
351
|
section: z.ZodString;
|
|
352
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
353
|
+
type: z.ZodLiteral<"reference">;
|
|
354
|
+
target: z.ZodString;
|
|
355
|
+
projection: z.ZodOptional<z.ZodObject<{
|
|
356
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
357
|
+
sections: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
358
|
+
}, z.core.$strict>>;
|
|
359
|
+
presentation: z.ZodOptional<z.ZodEnum<{
|
|
360
|
+
compact: "compact";
|
|
361
|
+
summary: "summary";
|
|
362
|
+
full: "full";
|
|
363
|
+
}>>;
|
|
306
364
|
}, z.core.$strict>], "type">>;
|
|
307
365
|
previewType: z.ZodOptional<z.ZodEnum<{
|
|
308
366
|
swatch: "swatch";
|
|
@@ -840,6 +898,18 @@ export const LegacyDocSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
840
898
|
type: z.ZodLiteral<"token-ref">;
|
|
841
899
|
topic: z.ZodString;
|
|
842
900
|
section: z.ZodString;
|
|
901
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
902
|
+
type: z.ZodLiteral<"reference">;
|
|
903
|
+
target: z.ZodString;
|
|
904
|
+
projection: z.ZodOptional<z.ZodObject<{
|
|
905
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
906
|
+
sections: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
907
|
+
}, z.core.$strict>>;
|
|
908
|
+
presentation: z.ZodOptional<z.ZodEnum<{
|
|
909
|
+
compact: "compact";
|
|
910
|
+
summary: "summary";
|
|
911
|
+
full: "full";
|
|
912
|
+
}>>;
|
|
843
913
|
}, z.core.$strict>], "type">>;
|
|
844
914
|
previewType: z.ZodOptional<z.ZodEnum<{
|
|
845
915
|
swatch: "swatch";
|
|
@@ -862,6 +932,7 @@ export type AuthoredDocKind = import("./base/type.js").AuthoredDocKind;
|
|
|
862
932
|
export type NamespaceDoc = import("./namespace/type.js").NamespaceDoc;
|
|
863
933
|
export type ReferenceContentBlock = import("./reference/type.js").ReferenceContentBlock;
|
|
864
934
|
export type GraphContentBlock = import("./reference/type.js").GraphContentBlock;
|
|
935
|
+
export type ReferenceSection = import("./reference/type.js").ReferenceSection;
|
|
865
936
|
export type ReferenceDoc = import("./reference/type.js").ReferenceDoc;
|
|
866
937
|
export type SingleComponentDoc = import("./component/type.js").SingleComponentDoc;
|
|
867
938
|
export type ComponentPropDoc = import("./base/type.js").ComponentPropDoc;
|
|
@@ -874,6 +945,7 @@ export type _AuthoredDocKindDriftLock = import("../_shared/contract.js").Expect<
|
|
|
874
945
|
export type _AuthoredDocGraphDriftLock = import("../_shared/contract.js").Expect<import("../_shared/contract.js").MutuallyAssignable<z.infer<typeof _AuthoredDocGraphSchema>, AuthoredDocGraphFieldsType>>;
|
|
875
946
|
export type _ReferenceContentBlockDriftLock = import("../_shared/contract.js").Expect<import("../_shared/contract.js").Equal<z.infer<typeof ReferenceContentBlockSchema>, ReferenceContentBlock>>;
|
|
876
947
|
export type _GraphContentBlockDriftLock = import("../_shared/contract.js").Expect<import("../_shared/contract.js").Equal<z.infer<typeof GraphContentBlockSchema>, GraphContentBlock>>;
|
|
948
|
+
export type _SectionContentBlockDriftLock = import("../_shared/contract.js").Expect<import("../_shared/contract.js").Equal<z.infer<typeof SectionContentBlockSchema>, ReferenceSection["content"][number]>>;
|
|
877
949
|
/**
|
|
878
950
|
* A stamped component doc as it loads. The loader accepts what the unstamped
|
|
879
951
|
* format always accepted, so stamping an existing doc never breaks it:
|
|
@@ -16,6 +16,7 @@ import {z} from 'zod';
|
|
|
16
16
|
/** @typedef {import('./namespace/type.js').NamespaceDoc} NamespaceDoc */
|
|
17
17
|
/** @typedef {import('./reference/type.js').ReferenceContentBlock} ReferenceContentBlock */
|
|
18
18
|
/** @typedef {import('./reference/type.js').GraphContentBlock} GraphContentBlock */
|
|
19
|
+
/** @typedef {import('./reference/type.js').ReferenceSection} ReferenceSection */
|
|
19
20
|
/** @typedef {import('./reference/type.js').ReferenceDoc} ReferenceDoc */
|
|
20
21
|
/** @typedef {import('./component/type.js').SingleComponentDoc} SingleComponentDoc */
|
|
21
22
|
/** @typedef {import('./base/type.js').ComponentPropDoc} ComponentPropDoc */
|
|
@@ -179,6 +180,20 @@ export const GraphContentBlockSchema = z.discriminatedUnion('type', [
|
|
|
179
180
|
ReferenceBlockSchema,
|
|
180
181
|
]);
|
|
181
182
|
|
|
183
|
+
/**
|
|
184
|
+
* A topic section's blocks: the stable union, plus a reference block, which a
|
|
185
|
+
* read inlines as the doc it includes.
|
|
186
|
+
*/
|
|
187
|
+
export const SectionContentBlockSchema = z.discriminatedUnion('type', [
|
|
188
|
+
ProseBlockSchema,
|
|
189
|
+
HeadingBlockSchema,
|
|
190
|
+
CodeBlockSchema,
|
|
191
|
+
TableBlockSchema,
|
|
192
|
+
ListBlockSchema,
|
|
193
|
+
TokenReferenceBlockSchema,
|
|
194
|
+
ReferenceBlockSchema,
|
|
195
|
+
]);
|
|
196
|
+
|
|
182
197
|
/** Namespace content accepts both stable reference blocks and graph-only blocks. */
|
|
183
198
|
export const NamespaceContentBlockSchema = z.discriminatedUnion('type', [
|
|
184
199
|
ProseBlockSchema,
|
|
@@ -210,12 +225,21 @@ export const NamespaceContentBlockSchema = z.discriminatedUnion('type', [
|
|
|
210
225
|
* >} _GraphContentBlockDriftLock
|
|
211
226
|
*/
|
|
212
227
|
|
|
228
|
+
/**
|
|
229
|
+
* @typedef {import('../_shared/contract.js').Expect<
|
|
230
|
+
* import('../_shared/contract.js').Equal<
|
|
231
|
+
* z.infer<typeof SectionContentBlockSchema>,
|
|
232
|
+
* ReferenceSection['content'][number]
|
|
233
|
+
* >
|
|
234
|
+
* >} _SectionContentBlockDriftLock
|
|
235
|
+
*/
|
|
236
|
+
|
|
213
237
|
const ReferenceSectionSchema = z
|
|
214
238
|
.object({
|
|
215
239
|
id: nonEmptyString.optional(),
|
|
216
240
|
title: nonEmptyString,
|
|
217
241
|
category: z.string().optional(),
|
|
218
|
-
content: z.array(
|
|
242
|
+
content: z.array(SectionContentBlockSchema),
|
|
219
243
|
previewType: z
|
|
220
244
|
.enum([
|
|
221
245
|
'swatch',
|
|
@@ -182,6 +182,31 @@ describe('unknown fields', () => {
|
|
|
182
182
|
);
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
+
it("are refused inside a section's reference block, which a section takes", () => {
|
|
186
|
+
const [section] = EXAMPLES.generic.sections;
|
|
187
|
+
const reference = {
|
|
188
|
+
type: 'reference',
|
|
189
|
+
target: '@astryxdesign/cli:schema:integration',
|
|
190
|
+
projection: {fields: ['docs']},
|
|
191
|
+
presentation: 'compact',
|
|
192
|
+
};
|
|
193
|
+
/** @param {object} block */
|
|
194
|
+
const withBlock = block =>
|
|
195
|
+
parseDoc(
|
|
196
|
+
{...EXAMPLES.generic, sections: [{...section, content: [block]}]},
|
|
197
|
+
'r.doc.mjs',
|
|
198
|
+
);
|
|
199
|
+
expect(() => withBlock(reference)).not.toThrow();
|
|
200
|
+
expect(() => withBlock({...reference, notAField: true})).toThrow();
|
|
201
|
+
expect(() =>
|
|
202
|
+
withBlock({...reference, projection: {fields: ['docs'], rows: []}}),
|
|
203
|
+
).toThrow();
|
|
204
|
+
// Workflow and collection blocks belong to a namespace doc.
|
|
205
|
+
expect(() =>
|
|
206
|
+
withBlock({type: 'collection', source: {slot: 'guides'}}),
|
|
207
|
+
).toThrow();
|
|
208
|
+
});
|
|
209
|
+
|
|
185
210
|
it('are refused inside sections and content blocks', () => {
|
|
186
211
|
const [section] = EXAMPLES.generic.sections;
|
|
187
212
|
expect(() =>
|
|
@@ -93,9 +93,9 @@ export const doc = {
|
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
name: 'sections[].content',
|
|
96
|
-
type: 'ReferenceContentBlock[]',
|
|
96
|
+
type: '(ReferenceContentBlock | ReferenceDocBlock)[]',
|
|
97
97
|
description:
|
|
98
|
-
|
|
98
|
+
"Ordered content blocks: prose, heading, code, table, list, token-ref, and reference. A `reference` block (`{type: 'reference', target, projection?, presentation?}`) includes another doc from its canonical source instead of a copy: a schema, command, function, or enum doc as `astryx docs` prints it, then the command that opens it. `projection.fields` keeps only those fields of a schema; `presentation` is `full` (the default), `compact` (no code blocks), or `summary` (only the doc's title, summary, and command). Any other doc shows as a summary. Graph-only workflow and collection blocks are available through GraphContentBlock on NamespaceDoc, without widening the stable ReferenceContentBlock union. Inside text, `{@link <target>}` links another doc by identity (`[<provider>:]<kind>:<name>`): the CLI prints the command that opens it, and `astryx doctor` warns on one that names no doc.",
|
|
99
99
|
required: true,
|
|
100
100
|
},
|
|
101
101
|
{
|
|
@@ -144,7 +144,27 @@ export const docs = {
|
|
|
144
144
|
},
|
|
145
145
|
{
|
|
146
146
|
type: 'prose',
|
|
147
|
-
text: 'Each `sections[].content` is an ordered array of ReferenceContentBlock, the stable discriminated union of prose, heading, code, table, list, and token-ref. Docs-graph-only workflow
|
|
147
|
+
text: 'Each `sections[].content` is an ordered array of ReferenceContentBlock, the stable discriminated union of prose, heading, code, table, list, and token-ref, plus the reference block (ReferenceDocBlock). A read inlines a reference block the way it inlines a token-ref, so `astryx docs`, in text and in `--json`, returns only the stable block kinds. Docs-graph-only workflow and collection blocks are exported separately as GraphContentBlock and accepted by NamespaceDoc. choice, callout, and checklist remain invalid. ReferenceContentBlock is also reused by the `notes` field on SchemaDoc and CommandDoc. Inside text, `{@link <target>}` links another doc by identity (`[<provider>:]<kind>:<name>`): the CLI prints the command that opens it, and `astryx doctor` warns on one that names no doc.',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
type: 'prose',
|
|
151
|
+
text: "A reference block includes content, where a link only points at it: `astryx doctor integration docs` fails when its target names no doc, when `projection.fields` names a field the schema does not have, or when the doc cannot take the projection or presentation it sets, and a read marks the missing content. A target without a provider names a doc of the package that wrote it, so an integration names the CLI's docs with the CLI's provider, as in `@astryxdesign/cli:schema:integration`.",
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
type: 'code',
|
|
155
|
+
lang: 'js',
|
|
156
|
+
label: 'A section that includes two fields of the integration manifest',
|
|
157
|
+
code: `{
|
|
158
|
+
title: 'Point the manifest at your folders',
|
|
159
|
+
content: [
|
|
160
|
+
{type: 'prose', text: 'Add these fields to astryx.integration.mjs.'},
|
|
161
|
+
{
|
|
162
|
+
type: 'reference',
|
|
163
|
+
target: '@astryxdesign/cli:schema:integration',
|
|
164
|
+
projection: {fields: ['components', 'docs']},
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
}`,
|
|
148
168
|
},
|
|
149
169
|
{
|
|
150
170
|
type: 'code',
|
|
@@ -158,10 +178,17 @@ export const docs = {
|
|
|
158
178
|
| { type: 'list'; style: 'ordered' | 'unordered' | 'do' | 'dont'; items: string[] }
|
|
159
179
|
| { type: 'token-ref'; topic: string; section: string };
|
|
160
180
|
|
|
181
|
+
type ReferenceDocBlock = {
|
|
182
|
+
type: 'reference';
|
|
183
|
+
target: string;
|
|
184
|
+
projection?: { fields?: string[]; sections?: string[] };
|
|
185
|
+
presentation?: 'summary' | 'compact' | 'full';
|
|
186
|
+
};
|
|
187
|
+
|
|
161
188
|
type GraphContentBlock =
|
|
162
189
|
| { type: 'workflow'; title?: string; steps: WorkflowStep[] }
|
|
163
190
|
| { type: 'collection'; source: {slot: string}; presentation?: 'list' | 'cards' | 'compact'; whenEmpty?: 'show' | 'omit' }
|
|
164
|
-
|
|
|
191
|
+
| ReferenceDocBlock;`,
|
|
165
192
|
},
|
|
166
193
|
{
|
|
167
194
|
type: 'prose',
|
|
@@ -30,19 +30,32 @@ export interface CollectionDocBlock {
|
|
|
30
30
|
whenEmpty?: 'show' | 'omit';
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* A bounded projection of one canonical doc. In a namespace doc's `blocks` it
|
|
35
|
+
* is layout the docs tree renders later. In a topic section, a read includes
|
|
36
|
+
* the doc it names in place of the block: a schema, command, function, or
|
|
37
|
+
* enum doc as `astryx docs` prints it (`projection.fields` keeps only those
|
|
38
|
+
* fields of a schema), then the command that opens that doc. Any other doc
|
|
39
|
+
* shows its title and summary.
|
|
40
|
+
*/
|
|
34
41
|
export interface ReferenceDocBlock {
|
|
35
42
|
type: 'reference';
|
|
43
|
+
/** The doc it names, by identity: `[<provider>:]<kind>:<name>`. */
|
|
36
44
|
target: string;
|
|
37
45
|
projection?: {
|
|
38
46
|
fields?: string[];
|
|
39
47
|
sections?: string[];
|
|
40
48
|
};
|
|
49
|
+
/** `summary`: only the doc's title, summary, and the command that opens it.
|
|
50
|
+
* `compact`: the included doc without its code blocks. `full`, the default:
|
|
51
|
+
* the included doc. */
|
|
41
52
|
presentation?: 'summary' | 'compact' | 'full';
|
|
42
53
|
}
|
|
43
54
|
|
|
44
|
-
/** Graph-only content blocks
|
|
45
|
-
* {@link ReferenceContentBlock} union
|
|
55
|
+
/** Graph-only content blocks, for a namespace doc's `blocks`. These are
|
|
56
|
+
* additive and do not widen the stable {@link ReferenceContentBlock} union
|
|
57
|
+
* consumed by existing exhaustive renderers. A topic section accepts the
|
|
58
|
+
* `reference` block too, and a read inlines it as stable blocks. */
|
|
46
59
|
export type GraphContentBlock =
|
|
47
60
|
WorkflowDocBlock | CollectionDocBlock | ReferenceDocBlock;
|
|
48
61
|
|
|
@@ -148,8 +161,10 @@ export interface ReferenceSection {
|
|
|
148
161
|
/** Navigation category ('guide' | 'foundations'). Mirrors the parent doc's
|
|
149
162
|
* category so sections can be grouped independently in the docsite nav. */
|
|
150
163
|
category?: string;
|
|
151
|
-
/** Ordered content blocks. Mix prose, code, tables, and lists freely.
|
|
152
|
-
|
|
164
|
+
/** Ordered content blocks. Mix prose, code, tables, and lists freely. A
|
|
165
|
+
* `reference` block includes another doc from its canonical source, so a
|
|
166
|
+
* guide never copies a schema's fields or a command's options. */
|
|
167
|
+
content: (ReferenceContentBlock | ReferenceDocBlock)[];
|
|
153
168
|
/** Preview type for token tables in this section. When set, the docsite
|
|
154
169
|
* renders a visual preview column using the token's computed CSS value
|
|
155
170
|
* from the current theme. Omit for non-token sections. */
|
|
@@ -115,7 +115,7 @@ function formatBlock(block, detail) {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
|
-
* @param {import('
|
|
118
|
+
* @param {import('../../../api/docs/docs.type.mjs').DocsReadSection} section
|
|
119
119
|
* @param {'full' | 'compact' | 'brief'} detail
|
|
120
120
|
* @returns {string}
|
|
121
121
|
*/
|
|
@@ -135,7 +135,7 @@ function formatSection(section, detail) {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
|
-
* @param {import('
|
|
138
|
+
* @param {import('../../../api/docs/docs.type.mjs').DocsReadDoc} docs
|
|
139
139
|
* @param {'full' | 'compact' | 'brief'} detail
|
|
140
140
|
* @returns {string}
|
|
141
141
|
*/
|
|
@@ -32,7 +32,7 @@ export const doc = {
|
|
|
32
32
|
],
|
|
33
33
|
exitCodes: [
|
|
34
34
|
{code: 0, when: 'all Core overlaps are explicitly declared or no overlap exists'},
|
|
35
|
-
{code: 1, when: 'an overlap is accidental, a doc is invalid,
|
|
35
|
+
{code: 1, when: 'an overlap is accidental, a doc is invalid, a namespace or placement fails, or a reference block cannot include what it names. A link that names no doc is a warning, and does not change the exit code'},
|
|
36
36
|
],
|
|
37
37
|
related: ['doctor integration validate', 'docs'],
|
|
38
38
|
};
|
|
@@ -24,6 +24,18 @@ export function loadAuthoringSelfDocs(sources?: string[], root?: string): Promis
|
|
|
24
24
|
error: string;
|
|
25
25
|
}[];
|
|
26
26
|
}>;
|
|
27
|
+
/**
|
|
28
|
+
* A schema's fields as the table its section prints, each nested field on the
|
|
29
|
+
* row after its parent; null when there are none. A reference block that
|
|
30
|
+
* names some of a schema's fields includes this table of just those.
|
|
31
|
+
* @param {any[]} fields
|
|
32
|
+
* @returns {{type: 'table', headers: string[], rows: string[][]} | null}
|
|
33
|
+
*/
|
|
34
|
+
export function schemaFieldTable(fields: any[]): {
|
|
35
|
+
type: "table";
|
|
36
|
+
headers: string[];
|
|
37
|
+
rows: string[][];
|
|
38
|
+
} | null;
|
|
27
39
|
/**
|
|
28
40
|
* One self-doc as a topic section, keyed by the doc's own name.
|
|
29
41
|
* @param {any} doc
|
|
@@ -133,6 +133,24 @@ function fieldRows(fields) {
|
|
|
133
133
|
]);
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* A schema's fields as the table its section prints, each nested field on the
|
|
138
|
+
* row after its parent; null when there are none. A reference block that
|
|
139
|
+
* names some of a schema's fields includes this table of just those.
|
|
140
|
+
* @param {any[]} fields
|
|
141
|
+
* @returns {{type: 'table', headers: string[], rows: string[][]} | null}
|
|
142
|
+
*/
|
|
143
|
+
export function schemaFieldTable(fields) {
|
|
144
|
+
const rows = fieldRows(fields);
|
|
145
|
+
return rows.length > 0
|
|
146
|
+
? {
|
|
147
|
+
type: 'table',
|
|
148
|
+
headers: ['Field', 'Type', 'Required', 'Description'],
|
|
149
|
+
rows,
|
|
150
|
+
}
|
|
151
|
+
: null;
|
|
152
|
+
}
|
|
153
|
+
|
|
136
154
|
/**
|
|
137
155
|
* One self-doc as a topic section, keyed by the doc's own name.
|
|
138
156
|
* @param {any} doc
|
|
@@ -144,14 +162,8 @@ export function selfDocSection(doc) {
|
|
|
144
162
|
if (doc.appliesTo) {
|
|
145
163
|
content.push({type: 'prose', text: `Applies to: ${doc.appliesTo}`});
|
|
146
164
|
}
|
|
147
|
-
const
|
|
148
|
-
if (
|
|
149
|
-
content.push({
|
|
150
|
-
type: 'table',
|
|
151
|
-
headers: ['Field', 'Type', 'Required', 'Description'],
|
|
152
|
-
rows,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
165
|
+
const table = schemaFieldTable(doc.fields ?? []);
|
|
166
|
+
if (table) content.push(table);
|
|
155
167
|
for (const example of doc.examples ?? []) {
|
|
156
168
|
if (typeof example?.code !== 'string' || example.code.trim() === '')
|
|
157
169
|
continue;
|
|
@@ -82,15 +82,20 @@ describe('what the authoring docs say about the docs tree', () => {
|
|
|
82
82
|
expect(graphFieldsDoc.description).toMatch(/not built yet/);
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
it('keeps graph blocks behind the separate GraphContentBlock type', () => {
|
|
85
|
+
it('keeps graph blocks behind the separate GraphContentBlock type, and a section takes a reference block', () => {
|
|
86
86
|
const content = referenceDoc.fields
|
|
87
87
|
.flatMap(field => [field, ...(field.fields ?? [])])
|
|
88
88
|
.find(field => field.name === 'sections[].content');
|
|
89
|
-
expect(content.type).toBe('ReferenceContentBlock[]');
|
|
89
|
+
expect(content.type).toBe('(ReferenceContentBlock | ReferenceDocBlock)[]');
|
|
90
90
|
expect(content.description).toContain('GraphContentBlock');
|
|
91
91
|
for (const type of GRAPH_BLOCK_TYPES) {
|
|
92
92
|
expect(content.description).toContain(type);
|
|
93
93
|
}
|
|
94
|
+
// A section's reference block reads as the doc it includes.
|
|
95
|
+
expect(GRAPH_BLOCK_TYPES.has('reference')).toBe(false);
|
|
96
|
+
expect(content.description).toMatch(
|
|
97
|
+
/A `reference` block .* includes another doc/,
|
|
98
|
+
);
|
|
94
99
|
});
|
|
95
100
|
|
|
96
101
|
it('says where namespace docs live: the CLI tree, and each integration', () => {
|
|
@@ -122,7 +122,10 @@ export { withSourceTitle };
|
|
|
122
122
|
* unlike component discovery, whose built-ins belong to core.
|
|
123
123
|
*/
|
|
124
124
|
export const BUILTIN_DOCS_PACKAGE: import("../../authoring/index.js").ProviderId;
|
|
125
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* Blocks that are valid authoring but require the compiled graph renderer: a
|
|
127
|
+
* namespace doc's `blocks` hold them, a topic section does not.
|
|
128
|
+
*/
|
|
126
129
|
export const GRAPH_BLOCK_TYPES: Set<string>;
|
|
127
130
|
/**
|
|
128
131
|
* Doc fields only the docs tree reads. A flat topic that sets one fails to
|
|
@@ -145,14 +145,15 @@ const BLOCK_FIELDS = {
|
|
|
145
145
|
table: ['headers', 'rows'],
|
|
146
146
|
list: ['style', 'items'],
|
|
147
147
|
'token-ref': ['topic', 'section'],
|
|
148
|
+
// A read inlines it as the doc it names includes (spec:AST-047 FR9).
|
|
149
|
+
reference: ['target'],
|
|
148
150
|
};
|
|
149
151
|
|
|
150
|
-
/**
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
]);
|
|
152
|
+
/**
|
|
153
|
+
* Blocks that are valid authoring but require the compiled graph renderer: a
|
|
154
|
+
* namespace doc's `blocks` hold them, a topic section does not.
|
|
155
|
+
*/
|
|
156
|
+
export const GRAPH_BLOCK_TYPES = new Set(['workflow', 'collection']);
|
|
156
157
|
|
|
157
158
|
/**
|
|
158
159
|
* Doc fields only the docs tree reads. A flat topic that sets one fails to
|
|
@@ -168,6 +169,7 @@ export const GRAPH_ONLY_FIELDS = ['placement', 'aliases', 'audience'];
|
|
|
168
169
|
/** @type {Record<string, string[]>} */
|
|
169
170
|
const OPTIONAL_BLOCK_FIELDS = {
|
|
170
171
|
code: ['label'],
|
|
172
|
+
reference: ['projection', 'presentation'],
|
|
171
173
|
};
|
|
172
174
|
|
|
173
175
|
/**
|
|
@@ -179,8 +181,12 @@ const OPTIONAL_BLOCK_FIELDS = {
|
|
|
179
181
|
const BLOCK_FIELD_VALUES = {
|
|
180
182
|
heading: {level: [3, 4, 5, 6]},
|
|
181
183
|
list: {style: ['ordered', 'unordered', 'do', 'dont']},
|
|
184
|
+
reference: {presentation: ['summary', 'compact', 'full']},
|
|
182
185
|
};
|
|
183
186
|
|
|
187
|
+
/** The parts of a doc a reference block's `projection` may select. */
|
|
188
|
+
const PROJECTION_FIELDS = ['fields', 'sections'];
|
|
189
|
+
|
|
184
190
|
/** Keys a section may carry. */
|
|
185
191
|
const SECTION_FIELDS = ['id', 'title', 'category', 'content', 'previewType'];
|
|
186
192
|
|
|
@@ -325,6 +331,34 @@ export function problemsInTopic(doc, {placement = false} = {}) {
|
|
|
325
331
|
);
|
|
326
332
|
}
|
|
327
333
|
}
|
|
334
|
+
// A projection names the parts of the doc to include, so each part
|
|
335
|
+
// it names is a non-empty list of names.
|
|
336
|
+
if (block.type === 'reference' && block.projection != null) {
|
|
337
|
+
const projection = block.projection;
|
|
338
|
+
if (typeof projection !== 'object' || Array.isArray(projection)) {
|
|
339
|
+
problems.push(
|
|
340
|
+
`${blockAt}.projection: expected {fields?, sections?}, naming the parts of the doc to include`,
|
|
341
|
+
);
|
|
342
|
+
} else {
|
|
343
|
+
for (const [key, names] of Object.entries(projection)) {
|
|
344
|
+
if (!PROJECTION_FIELDS.includes(key)) {
|
|
345
|
+
problems.push(
|
|
346
|
+
`${blockAt}.projection.${key}: not a field of a projection`,
|
|
347
|
+
);
|
|
348
|
+
} else if (
|
|
349
|
+
!Array.isArray(names) ||
|
|
350
|
+
names.length === 0 ||
|
|
351
|
+
names.some(
|
|
352
|
+
name => typeof name !== 'string' || name.trim() === '',
|
|
353
|
+
)
|
|
354
|
+
) {
|
|
355
|
+
problems.push(
|
|
356
|
+
`${blockAt}.projection.${key}: expected a non-empty array of names`,
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
328
362
|
},
|
|
329
363
|
);
|
|
330
364
|
},
|