@thedatagrid/docs-kit 0.2.0 → 0.2.2
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/CHANGELOG.md +13 -0
- package/README.md +22 -3
- package/dist/demos/build.d.ts.map +1 -1
- package/dist/demos/build.js +1 -0
- package/dist/demos/build.js.map +1 -1
- package/dist/demos/config.d.ts +7 -0
- package/dist/demos/config.d.ts.map +1 -1
- package/dist/demos/config.js.map +1 -1
- package/dist/demos/pages.d.ts +4 -1
- package/dist/demos/pages.d.ts.map +1 -1
- package/dist/demos/pages.js +32 -3
- package/dist/demos/pages.js.map +1 -1
- package/dist/react/DemoShell.js +21 -5
- package/dist/react/DemoShell.js.map +1 -1
- package/dist/react/styles.css +8 -0
- package/dist/remark/index.d.ts +1 -1
- package/dist/remark/index.d.ts.map +1 -1
- package/dist/remark/index.js +1 -1
- package/dist/remark/index.js.map +1 -1
- package/dist/remark/meta.d.ts +13 -0
- package/dist/remark/meta.d.ts.map +1 -1
- package/dist/remark/meta.js +13 -0
- package/dist/remark/meta.js.map +1 -1
- package/dist/remark/remarkDemoFences.d.ts +24 -5
- package/dist/remark/remarkDemoFences.d.ts.map +1 -1
- package/dist/remark/remarkDemoFences.js +66 -7
- package/dist/remark/remarkDemoFences.js.map +1 -1
- package/package.json +1 -1
- package/src/demos/build.ts +1 -0
- package/src/demos/config.ts +7 -0
- package/src/demos/pages.ts +30 -3
- package/src/react/DemoShell.tsx +64 -8
- package/src/react/styles.css +8 -0
- package/src/remark/index.ts +1 -1
- package/src/remark/meta.ts +26 -0
- package/src/remark/remarkDemoFences.ts +75 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type FenceProps } from './meta.ts';
|
|
1
|
+
import { type FenceDefaults, type FenceProps } from './meta.ts';
|
|
2
2
|
export type FenceInfo = {
|
|
3
3
|
lang: string | null;
|
|
4
4
|
meta: string;
|
|
@@ -41,7 +41,15 @@ export type RemarkDemoFencesOptions = {
|
|
|
41
41
|
componentName?: string;
|
|
42
42
|
/** Literal replacements applied to inlined source (see `applySourceReplacements`). */
|
|
43
43
|
sourceReplacements?: Record<string, string>;
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Site-wide fence props, so pages don't repeat them: `all` applies to every
|
|
46
|
+
* claimed fence, `demos` to fences of demo entries. E.g.
|
|
47
|
+
* `{ all: { lines: true }, demos: { live: true, height: 'default' } }`.
|
|
48
|
+
* A fence's own meta wins; `lines=false` / `live=false` turn a default off.
|
|
49
|
+
* Pass the same object to the demo builder (`DocsKitConfig.fenceDefaults`).
|
|
50
|
+
*/
|
|
51
|
+
fenceDefaults?: FenceDefaults;
|
|
52
|
+
/** `height` of a live fence that sets none (and no `fenceDefaults.demos.height`). Default `auto`. */
|
|
45
53
|
liveHeight?: string;
|
|
46
54
|
};
|
|
47
55
|
/**
|
|
@@ -69,9 +77,20 @@ export type RemarkDemoFencesOptions = {
|
|
|
69
77
|
* - `height="small|default|large|auto|<px>"`; a live fence defaults to
|
|
70
78
|
* `liveHeight` (`auto`).
|
|
71
79
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
80
|
+
* A `<DemoTitle>` and/or `<DemoDescription>` right before a fence become that
|
|
81
|
+
* fence's card header:
|
|
82
|
+
*
|
|
83
|
+
* <DemoDescription>
|
|
84
|
+
* What the demo shows.
|
|
85
|
+
* </DemoDescription>
|
|
86
|
+
*
|
|
87
|
+
* ```tsx file="basic.demo.tsx" live
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* That's the same as wrapping the three in `<Demo>`, which also works. The
|
|
91
|
+
* fence's props are hoisted onto the `<Demo>`; a fence without `live` there
|
|
92
|
+
* makes a code-only card. A `<DemoTitle>` / `<DemoDescription>` with no fence
|
|
93
|
+
* after it fails the build.
|
|
75
94
|
*/
|
|
76
95
|
export declare function remarkDemoFences(options: RemarkDemoFencesOptions): () => (tree: any) => void;
|
|
77
96
|
//# sourceMappingURL=remarkDemoFences.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remarkDemoFences.d.ts","sourceRoot":"","sources":["../../src/remark/remarkDemoFences.ts"],"names":[],"mappings":"AASA,OAAO,
|
|
1
|
+
{"version":3,"file":"remarkDemoFences.d.ts","sourceRoot":"","sources":["../../src/remark/remarkDemoFences.ts"],"names":[],"mappings":"AASA,OAAO,EAAsC,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAEpG,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,UAAU,CAAC;IAClB,gDAAgD;IAChD,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,2GAA2G;IAC3G,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B;;;;OAIG;IACH,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC;IACtC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IACrC,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sFAAsF;IACtF,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,qGAAqG;IACrG,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAYF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,UAsBjD,MAAM,GAAG,UAuKxB"}
|
|
@@ -6,7 +6,7 @@ import { formatHighlightSpec } from "../code/highlightSpec.js";
|
|
|
6
6
|
import { parseDemoHeight } from "../code/heights.js";
|
|
7
7
|
import { formatLineRanges } from "../code/lineRanges.js";
|
|
8
8
|
import { applySourceReplacements, extractCodeMarkers, sliceRegion, stripCodeMarkers } from "../code/regions.js";
|
|
9
|
-
import { parseFenceMeta } from "./meta.js";
|
|
9
|
+
import { applyFenceDefaults, parseFenceMeta } from "./meta.js";
|
|
10
10
|
const TYPECHECKED_LANGS = new Set(['ts', 'tsx', 'js', 'jsx', 'typescript', 'javascript']);
|
|
11
11
|
/**
|
|
12
12
|
* Remark plugin for file-based fences.
|
|
@@ -33,12 +33,23 @@ const TYPECHECKED_LANGS = new Set(['ts', 'tsx', 'js', 'jsx', 'typescript', 'java
|
|
|
33
33
|
* - `height="small|default|large|auto|<px>"`; a live fence defaults to
|
|
34
34
|
* `liveHeight` (`auto`).
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* A `<DemoTitle>` and/or `<DemoDescription>` right before a fence become that
|
|
37
|
+
* fence's card header:
|
|
38
|
+
*
|
|
39
|
+
* <DemoDescription>
|
|
40
|
+
* What the demo shows.
|
|
41
|
+
* </DemoDescription>
|
|
42
|
+
*
|
|
43
|
+
* ```tsx file="basic.demo.tsx" live
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* That's the same as wrapping the three in `<Demo>`, which also works. The
|
|
47
|
+
* fence's props are hoisted onto the `<Demo>`; a fence without `live` there
|
|
48
|
+
* makes a code-only card. A `<DemoTitle>` / `<DemoDescription>` with no fence
|
|
49
|
+
* after it fails the build.
|
|
39
50
|
*/
|
|
40
51
|
export function remarkDemoFences(options) {
|
|
41
|
-
const { contentDir, dependencies, claim, banInlineCode = true, staticFences = 'shiki-meta', demoSuffixes = ['.demo.tsx'], componentName = 'Demo', sourceReplacements, liveHeight = 'auto', } = options;
|
|
52
|
+
const { contentDir, dependencies, claim, banInlineCode = true, staticFences = 'shiki-meta', demoSuffixes = ['.demo.tsx'], componentName = 'Demo', sourceReplacements, fenceDefaults, liveHeight = 'auto', } = options;
|
|
42
53
|
const folder = options.folder.replace(/^\/+|\/+$/g, '');
|
|
43
54
|
const pageDir = path.join(contentDir, folder);
|
|
44
55
|
/** `/docs/x.tsx` is relative to the content root, anything else to the page. */
|
|
@@ -47,14 +58,17 @@ export function remarkDemoFences(options) {
|
|
|
47
58
|
dependencies?.add(path.relative(contentDir, absPath).split(path.sep).join('/'));
|
|
48
59
|
};
|
|
49
60
|
return () => (tree) => {
|
|
61
|
+
wrapLooseHeaders(tree, componentName, folder);
|
|
50
62
|
visit(tree, 'code', (node, index, parent) => {
|
|
51
63
|
if (index == null || !parent)
|
|
52
64
|
return;
|
|
53
65
|
const inDemo = parent.type === 'mdxJsxFlowElement' && parent.name === componentName;
|
|
54
66
|
const meta = node.meta || '';
|
|
55
|
-
const
|
|
56
|
-
if (!inDemo && claim && !claim({ lang: node.lang ?? null, meta, props, inDemo }))
|
|
67
|
+
const ownProps = parseFenceMeta(meta);
|
|
68
|
+
if (!inDemo && claim && !claim({ lang: node.lang ?? null, meta, props: ownProps, inDemo }))
|
|
57
69
|
return;
|
|
70
|
+
const isDemoFile = typeof ownProps.file === 'string' && demoSuffixes.some((s) => ownProps.file.endsWith(s));
|
|
71
|
+
const props = applyFenceDefaults(ownProps, fenceDefaults, isDemoFile);
|
|
58
72
|
const context = `\`\`\`${node.lang ?? ''} ${meta} in "${path.join(path.basename(contentDir), folder)}"`;
|
|
59
73
|
if (/\{[^}]*\}/.test(meta.replace(/"[^"]*"/g, '""'))) {
|
|
60
74
|
throw new Error(`${context}: \`{…}\` line highlights are not supported — mark the lines in the ` +
|
|
@@ -211,6 +225,51 @@ export function remarkDemoFences(options) {
|
|
|
211
225
|
});
|
|
212
226
|
};
|
|
213
227
|
}
|
|
228
|
+
const HEADER_PARTS = new Set(['DemoTitle', 'DemoDescription']);
|
|
229
|
+
const isHeaderPart = (node) => node?.type === 'mdxJsxFlowElement' && HEADER_PARTS.has(node.name);
|
|
230
|
+
/**
|
|
231
|
+
* Wraps each run of `<DemoTitle>` / `<DemoDescription>` (outside `<Demo>`)
|
|
232
|
+
* and the fence right after it in a `<Demo>`, so the fence handling below
|
|
233
|
+
* sees the same tree as for an explicit wrapper.
|
|
234
|
+
*/
|
|
235
|
+
function wrapLooseHeaders(tree, componentName, folder) {
|
|
236
|
+
visit(tree, (node) => {
|
|
237
|
+
if (!Array.isArray(node.children))
|
|
238
|
+
return;
|
|
239
|
+
if (node.type === 'mdxJsxFlowElement' && node.name === componentName)
|
|
240
|
+
return 'skip';
|
|
241
|
+
const children = node.children;
|
|
242
|
+
for (let index = 0; index < children.length; index++) {
|
|
243
|
+
if (!isHeaderPart(children[index]))
|
|
244
|
+
continue;
|
|
245
|
+
let end = index;
|
|
246
|
+
while (isHeaderPart(children[end]))
|
|
247
|
+
end++;
|
|
248
|
+
const parts = children.slice(index, end);
|
|
249
|
+
const where = `"${folder}"${parts[0].position ? ` line ${parts[0].position.start.line}` : ''}`;
|
|
250
|
+
const names = parts.map((part) => part.name);
|
|
251
|
+
const repeated = names.find((name, i) => names.indexOf(name) !== i);
|
|
252
|
+
if (repeated) {
|
|
253
|
+
throw new Error(`<${repeated}> in ${where}: one per demo (each fence gets its own title and description)`);
|
|
254
|
+
}
|
|
255
|
+
const fence = children[end];
|
|
256
|
+
if (fence?.type !== 'code') {
|
|
257
|
+
throw new Error(`<${names[0]}> in ${where} must come right before the code fence it describes ` +
|
|
258
|
+
`(or sit inside <${componentName}> with it)`);
|
|
259
|
+
}
|
|
260
|
+
const demo = {
|
|
261
|
+
type: 'mdxJsxFlowElement',
|
|
262
|
+
name: componentName,
|
|
263
|
+
attributes: [],
|
|
264
|
+
children: [...parts, fence],
|
|
265
|
+
};
|
|
266
|
+
if (parts[0].position && fence.position) {
|
|
267
|
+
demo.position = { start: parts[0].position.start, end: fence.position.end };
|
|
268
|
+
}
|
|
269
|
+
children.splice(index, end - index + 1, demo);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
214
273
|
function element(name, attrs) {
|
|
215
274
|
return {
|
|
216
275
|
type: 'mdxJsxFlowElement',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remarkDemoFences.js","sourceRoot":"","sources":["../../src/remark/remarkDemoFences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAChH,OAAO,EAAE,cAAc,EAAmB,MAAM,WAAW,CAAC;AAiD5D,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC;AAU1F;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgC;IAC/D,MAAM,EACJ,UAAU,EACV,YAAY,EACZ,KAAK,EACL,aAAa,GAAG,IAAI,EACpB,YAAY,GAAG,YAAY,EAC3B,YAAY,GAAG,CAAC,WAAW,CAAC,EAC5B,aAAa,GAAG,MAA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E,CAAC;QAC3E,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,4CAA4C,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAAC,IAAS;IACxB,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB;QAAE,OAAO,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;IACvF,OAAO,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACrD,CAAC;AAED,kFAAkF;AAClF,SAAS,oBAAoB,CAAC,WAAgB;IAC5C,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC;QAC/C,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAmB,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YACrE,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;YACnC,IAAI,IAAI;gBAAE,OAAO,IAAI,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
package/src/demos/build.ts
CHANGED
|
@@ -96,6 +96,7 @@ function resolveSettings(options: BuildDemosOptions) {
|
|
|
96
96
|
pageExtension: config.pageExtension ?? '.page.md',
|
|
97
97
|
routeForPage: config.routeForPage ?? defaultRouteForPage,
|
|
98
98
|
anchorPrefix: config.anchorPrefix ?? '',
|
|
99
|
+
fenceDefaults: config.fenceDefaults,
|
|
99
100
|
framework: config.framework ?? 'react',
|
|
100
101
|
libraries,
|
|
101
102
|
stubImports,
|
package/src/demos/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Plugin } from 'esbuild';
|
|
2
2
|
|
|
3
3
|
import type { CompilerConfig } from './client.ts';
|
|
4
|
+
import type { FenceDefaults } from '../remark/meta.ts';
|
|
4
5
|
import type { CompileOptions } from './compile/core.ts';
|
|
5
6
|
|
|
6
7
|
/** A package the demos import that is built from source instead of `node_modules`. */
|
|
@@ -40,6 +41,12 @@ export type DocsKitConfig = {
|
|
|
40
41
|
pageExtension?: string;
|
|
41
42
|
/** Prefix of the docs card anchors (the `<Demo>` context's `anchorPrefix`). Default `''`. */
|
|
42
43
|
anchorPrefix?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The site's fence defaults, the same object passed to `remarkDemoFences`
|
|
46
|
+
* (e.g. `{ demos: { live: true } }` makes every demo fence live), so the
|
|
47
|
+
* "see in docs" links find the live demos.
|
|
48
|
+
*/
|
|
49
|
+
fenceDefaults?: FenceDefaults;
|
|
43
50
|
/** Content-relative page path (without extension) → route. Default: `/<path>`, `index` dropped. */
|
|
44
51
|
routeForPage?: (pagePath: string) => string;
|
|
45
52
|
/** Only `react` for now. */
|
package/src/demos/pages.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
|
+
import { applyFenceDefaults, parseFenceMeta, type FenceDefaults } from '../remark/meta.ts';
|
|
4
5
|
import { slugifyDemoTitle } from './slug.ts';
|
|
5
6
|
|
|
6
7
|
function walk(dir: string, accept: (file: string) => boolean, out: string[] = []): string[] {
|
|
@@ -18,6 +19,26 @@ export function findFiles(dir: string, suffix: string): string[] {
|
|
|
18
19
|
return walk(dir, (name) => name.endsWith(suffix)).sort();
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
/**
|
|
23
|
+
* The `<DemoTitle>` among the `<DemoTitle>` / `<DemoDescription>` blocks
|
|
24
|
+
* that end right before a fence (no `<Demo>` wrapper), or null.
|
|
25
|
+
*/
|
|
26
|
+
function looseDemoTitle(before: string): string | null {
|
|
27
|
+
let rest = before.trimEnd();
|
|
28
|
+
for (let part = 0; part < 2; part++) {
|
|
29
|
+
const close = /<\/(DemoTitle|DemoDescription)>$/.exec(rest);
|
|
30
|
+
if (!close) return null;
|
|
31
|
+
const start = rest.lastIndexOf(`<${close[1]}>`);
|
|
32
|
+
if (start === -1) return null;
|
|
33
|
+
if (close[1] === 'DemoTitle') {
|
|
34
|
+
const text = rest.slice(start + '<DemoTitle>'.length, close.index);
|
|
35
|
+
return text.replace(/<[^>]+>/g, '').trim() || null;
|
|
36
|
+
}
|
|
37
|
+
rest = rest.slice(0, start).trimEnd();
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
21
42
|
const toPosix = (p: string) => p.split(path.sep).join('/');
|
|
22
43
|
|
|
23
44
|
export function defaultRouteForPage(pagePath: string): string {
|
|
@@ -28,7 +49,8 @@ export function defaultRouteForPage(pagePath: string): string {
|
|
|
28
49
|
/**
|
|
29
50
|
* Maps demo ids to the docs page (and card anchor) that shows them, so a demo
|
|
30
51
|
* opened on its own can link back. The anchor matches the `<Demo>` card's
|
|
31
|
-
* slug: `<DemoTitle>`
|
|
52
|
+
* slug: `<DemoTitle>` (inside `<Demo>`, or right before the fence) > `<Demo title>`
|
|
53
|
+
* > the fence's `title` > `<name>.demo.tsx`.
|
|
32
54
|
*/
|
|
33
55
|
export function findDocsLinks(options: {
|
|
34
56
|
contentDir: string;
|
|
@@ -36,8 +58,9 @@ export function findDocsLinks(options: {
|
|
|
36
58
|
demoSuffix: string;
|
|
37
59
|
routeForPage: (pagePath: string) => string;
|
|
38
60
|
anchorPrefix?: string;
|
|
61
|
+
fenceDefaults?: FenceDefaults;
|
|
39
62
|
}): Map<string, string> {
|
|
40
|
-
const { contentDir, pageExtension, demoSuffix, routeForPage, anchorPrefix = '' } = options;
|
|
63
|
+
const { contentDir, pageExtension, demoSuffix, routeForPage, anchorPrefix = '', fenceDefaults } = options;
|
|
41
64
|
const links = new Map<string, string>();
|
|
42
65
|
const fenceRe = /^```[^\n]*$/gm;
|
|
43
66
|
|
|
@@ -50,7 +73,9 @@ export function findDocsLinks(options: {
|
|
|
50
73
|
const info = match[0];
|
|
51
74
|
const file = /\bfile=(?:"([^"]+)"|'([^']+)')/.exec(info);
|
|
52
75
|
const fileName = file?.[1] ?? file?.[2];
|
|
53
|
-
if (!fileName || !fileName.endsWith(demoSuffix)
|
|
76
|
+
if (!fileName || !fileName.endsWith(demoSuffix)) continue;
|
|
77
|
+
const meta = info.replace(/^```\S*\s*/, '');
|
|
78
|
+
if (!applyFenceDefaults(parseFenceMeta(meta), fenceDefaults, true).live) continue;
|
|
54
79
|
const absPath = fileName.startsWith('/') ? path.join(contentDir, fileName) : path.resolve(pageDir, fileName);
|
|
55
80
|
const demoId = toPosix(path.relative(contentDir, absPath)).slice(0, -demoSuffix.length);
|
|
56
81
|
if (links.has(demoId)) continue;
|
|
@@ -67,6 +92,8 @@ export function findDocsLinks(options: {
|
|
|
67
92
|
const demoTitle = /<DemoTitle>\s*([\s\S]*?)\s*<\/DemoTitle>/.exec(block);
|
|
68
93
|
const titleAttr = /^<Demo\b[^>]*\btitle=(?:"([^"]*)"|'([^']*)')/.exec(block);
|
|
69
94
|
title = demoTitle?.[1].replace(/<[^>]+>/g, '').trim() || titleAttr?.[1] || titleAttr?.[2] || null;
|
|
95
|
+
} else {
|
|
96
|
+
title = looseDemoTitle(before);
|
|
70
97
|
}
|
|
71
98
|
if (!title) {
|
|
72
99
|
const fenceTitle = /\btitle=(?:"([^"]*)"|'([^']*)')/.exec(info);
|
package/src/react/DemoShell.tsx
CHANGED
|
@@ -339,11 +339,11 @@ export function DemoShell(props: DemoShellProps) {
|
|
|
339
339
|
<CompileStatusLabel status={status} errorCount={errorCount} />
|
|
340
340
|
{dirty ? (
|
|
341
341
|
<ToolbarButton title="Discard your changes and restore the original demo" onClick={resetEdits}>
|
|
342
|
-
reset
|
|
342
|
+
reset<ResetIcon />
|
|
343
343
|
</ToolbarButton>
|
|
344
344
|
) : null}
|
|
345
345
|
<ToolbarButton title={`Fork “${title}” in CodeSandbox (with your changes)`} onClick={fork}>
|
|
346
|
-
fork
|
|
346
|
+
fork<ForkIcon />
|
|
347
347
|
</ToolbarButton>
|
|
348
348
|
<ToolbarButton title="Stop editing (your changes stay until you reset or leave the page)" onClick={() => setEditing(false)}>
|
|
349
349
|
done
|
|
@@ -362,7 +362,7 @@ export function DemoShell(props: DemoShellProps) {
|
|
|
362
362
|
</ToolbarButton>
|
|
363
363
|
{editor && demoUrl ? (
|
|
364
364
|
<ToolbarButton title="Edit the code and see the preview update" onClick={startEditing}>
|
|
365
|
-
edit
|
|
365
|
+
edit<EditIcon />
|
|
366
366
|
</ToolbarButton>
|
|
367
367
|
) : null}
|
|
368
368
|
</>
|
|
@@ -370,17 +370,17 @@ export function DemoShell(props: DemoShellProps) {
|
|
|
370
370
|
<>
|
|
371
371
|
{editor ? (
|
|
372
372
|
<ToolbarButton title="Edit the code and see the preview update" onClick={startEditing}>
|
|
373
|
-
edit
|
|
373
|
+
edit<EditIcon />
|
|
374
374
|
</ToolbarButton>
|
|
375
375
|
) : null}
|
|
376
376
|
<ToolbarButton
|
|
377
377
|
title={dirty ? 'Discard your changes and restore the original demo' : 'Reset the demo to its initial state'}
|
|
378
378
|
onClick={dirty ? resetEdits : () => iframeRef.current?.reset()}
|
|
379
379
|
>
|
|
380
|
-
reset
|
|
380
|
+
reset<ResetIcon />
|
|
381
381
|
</ToolbarButton>
|
|
382
382
|
<ToolbarButton title={`Fork “${title}” in CodeSandbox`} onClick={fork}>
|
|
383
|
-
fork
|
|
383
|
+
fork<ForkIcon />
|
|
384
384
|
</ToolbarButton>
|
|
385
385
|
<OpenDemoLink demoUrl={demoUrl!} title={title} />
|
|
386
386
|
<IconButton title="Full screen" onClick={openOverlay}>
|
|
@@ -518,6 +518,62 @@ function IconButton(props: { title: string; onClick: () => void; children: React
|
|
|
518
518
|
);
|
|
519
519
|
}
|
|
520
520
|
|
|
521
|
+
/** Toolbar icons: sized by CSS (`--dk-action-icon-size`), drawn in the text color. */
|
|
522
|
+
function ActionIcon({ children }: { children: ReactNode }) {
|
|
523
|
+
return (
|
|
524
|
+
<svg
|
|
525
|
+
className="dk-demo-action-icon"
|
|
526
|
+
viewBox="0 0 24 24"
|
|
527
|
+
fill="none"
|
|
528
|
+
stroke="currentColor"
|
|
529
|
+
strokeWidth="2"
|
|
530
|
+
strokeLinecap="round"
|
|
531
|
+
strokeLinejoin="round"
|
|
532
|
+
aria-hidden="true"
|
|
533
|
+
>
|
|
534
|
+
{children}
|
|
535
|
+
</svg>
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function EditIcon() {
|
|
540
|
+
return (
|
|
541
|
+
<ActionIcon>
|
|
542
|
+
<path d="M12 20h9" />
|
|
543
|
+
<path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z" />
|
|
544
|
+
</ActionIcon>
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function ResetIcon() {
|
|
549
|
+
return (
|
|
550
|
+
<ActionIcon>
|
|
551
|
+
<path d="M3 12a9 9 0 1 0 3-6.7L3 8" />
|
|
552
|
+
<path d="M3 3v5h5" />
|
|
553
|
+
</ActionIcon>
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
function ForkIcon() {
|
|
558
|
+
return (
|
|
559
|
+
<ActionIcon>
|
|
560
|
+
<circle cx="6" cy="5" r="2" />
|
|
561
|
+
<circle cx="18" cy="5" r="2" />
|
|
562
|
+
<circle cx="12" cy="19" r="2" />
|
|
563
|
+
<path d="M6 7v1a4 4 0 0 0 4 4h4a4 4 0 0 0 4-4V7M12 12v5" />
|
|
564
|
+
</ActionIcon>
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
function OpenIcon() {
|
|
569
|
+
return (
|
|
570
|
+
<ActionIcon>
|
|
571
|
+
<path d="M14 4h6v6M20 4l-9 9" />
|
|
572
|
+
<path d="M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5" />
|
|
573
|
+
</ActionIcon>
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
|
|
521
577
|
function ExpandIcon() {
|
|
522
578
|
return (
|
|
523
579
|
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
|
|
@@ -548,7 +604,7 @@ function DemoOverlay(props: { title: string; demoUrl: string; onClose: () => voi
|
|
|
548
604
|
<span className="dk-demo-overlay-title">{props.title}</span>
|
|
549
605
|
<span className="dk-demo-spacer" />
|
|
550
606
|
<ToolbarButton title="Reset the demo to its initial state" onClick={() => iframeRef.current?.reset()}>
|
|
551
|
-
reset
|
|
607
|
+
reset<ResetIcon />
|
|
552
608
|
</ToolbarButton>
|
|
553
609
|
<IconButton title="Close" onClick={props.onClose}>
|
|
554
610
|
<CloseIcon />
|
|
@@ -586,7 +642,7 @@ function OpenDemoLink({ demoUrl, title }: { demoUrl: string; title: string }) {
|
|
|
586
642
|
}}
|
|
587
643
|
className="dk-demo-action"
|
|
588
644
|
>
|
|
589
|
-
open
|
|
645
|
+
open<OpenIcon />
|
|
590
646
|
</a>
|
|
591
647
|
);
|
|
592
648
|
}
|
package/src/react/styles.css
CHANGED
|
@@ -197,10 +197,18 @@
|
|
|
197
197
|
font-weight: 500;
|
|
198
198
|
}
|
|
199
199
|
.dk-demo-action {
|
|
200
|
+
display: inline-flex;
|
|
201
|
+
align-items: center;
|
|
202
|
+
gap: 5px;
|
|
200
203
|
padding: 4px 8px;
|
|
201
204
|
font-family: var(--dk-font-mono);
|
|
202
205
|
font-size: 12.5px;
|
|
203
206
|
}
|
|
207
|
+
.dk-demo-action-icon {
|
|
208
|
+
flex: none;
|
|
209
|
+
width: var(--dk-action-icon-size, 14px);
|
|
210
|
+
height: var(--dk-action-icon-size, 14px);
|
|
211
|
+
}
|
|
204
212
|
.dk-demo-icon {
|
|
205
213
|
display: inline-flex;
|
|
206
214
|
align-items: center;
|
package/src/remark/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { remarkDemoFences, type FenceInfo, type RemarkDemoFencesOptions } from './remarkDemoFences.ts';
|
|
2
|
-
export { parseFenceMeta, type FenceProps } from './meta.ts';
|
|
2
|
+
export { applyFenceDefaults, parseFenceMeta, type FenceDefaults, type FenceProps } from './meta.ts';
|
package/src/remark/meta.ts
CHANGED
|
@@ -18,3 +18,29 @@ export function parseFenceMeta(meta: string): FenceProps {
|
|
|
18
18
|
}
|
|
19
19
|
return props;
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Site-wide fence props, under each fence's own meta. Values are written as in
|
|
24
|
+
* the meta (`true` for a bare flag, strings otherwise); `false` leaves a prop
|
|
25
|
+
* unset. A fence turns a default off with `<prop>=false` (or `lines=off`).
|
|
26
|
+
*/
|
|
27
|
+
export type FenceDefaults = {
|
|
28
|
+
/** Every docs-kit fence, e.g. `{ lines: true }`. */
|
|
29
|
+
all?: Record<string, string | boolean>;
|
|
30
|
+
/** Fences of demo entries (`*.demo.tsx`), e.g. `{ live: true, height: 'default' }`. */
|
|
31
|
+
demos?: Record<string, string | boolean>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** Flags that `=false` / `=off` switch off. (`live=off` stays "live, code tab first".) */
|
|
35
|
+
const OFF_VALUES: Record<string, string[]> = { lines: ['false', 'off'], live: ['false'] };
|
|
36
|
+
|
|
37
|
+
/** The fence's props over the defaults, with switched-off flags removed. */
|
|
38
|
+
export function applyFenceDefaults(props: FenceProps, defaults: FenceDefaults | undefined, isDemo: boolean): FenceProps {
|
|
39
|
+
const merged: Record<string, string | boolean> = { ...defaults?.all, ...(isDemo ? defaults?.demos : undefined), ...props };
|
|
40
|
+
const result: FenceProps = {};
|
|
41
|
+
for (const [name, value] of Object.entries(merged)) {
|
|
42
|
+
if (value === false || (typeof value === 'string' && OFF_VALUES[name]?.includes(value))) continue;
|
|
43
|
+
result[name] = value;
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
@@ -7,7 +7,7 @@ import { formatHighlightSpec } from '../code/highlightSpec.ts';
|
|
|
7
7
|
import { parseDemoHeight } from '../code/heights.ts';
|
|
8
8
|
import { formatLineRanges } from '../code/lineRanges.ts';
|
|
9
9
|
import { applySourceReplacements, extractCodeMarkers, sliceRegion, stripCodeMarkers } from '../code/regions.ts';
|
|
10
|
-
import { parseFenceMeta, type FenceProps } from './meta.ts';
|
|
10
|
+
import { applyFenceDefaults, parseFenceMeta, type FenceDefaults, type FenceProps } from './meta.ts';
|
|
11
11
|
|
|
12
12
|
export type FenceInfo = {
|
|
13
13
|
lang: string | null;
|
|
@@ -52,7 +52,15 @@ export type RemarkDemoFencesOptions = {
|
|
|
52
52
|
componentName?: string;
|
|
53
53
|
/** Literal replacements applied to inlined source (see `applySourceReplacements`). */
|
|
54
54
|
sourceReplacements?: Record<string, string>;
|
|
55
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Site-wide fence props, so pages don't repeat them: `all` applies to every
|
|
57
|
+
* claimed fence, `demos` to fences of demo entries. E.g.
|
|
58
|
+
* `{ all: { lines: true }, demos: { live: true, height: 'default' } }`.
|
|
59
|
+
* A fence's own meta wins; `lines=false` / `live=false` turn a default off.
|
|
60
|
+
* Pass the same object to the demo builder (`DocsKitConfig.fenceDefaults`).
|
|
61
|
+
*/
|
|
62
|
+
fenceDefaults?: FenceDefaults;
|
|
63
|
+
/** `height` of a live fence that sets none (and no `fenceDefaults.demos.height`). Default `auto`. */
|
|
56
64
|
liveHeight?: string;
|
|
57
65
|
};
|
|
58
66
|
|
|
@@ -91,9 +99,20 @@ type MdxElement = {
|
|
|
91
99
|
* - `height="small|default|large|auto|<px>"`; a live fence defaults to
|
|
92
100
|
* `liveHeight` (`auto`).
|
|
93
101
|
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
102
|
+
* A `<DemoTitle>` and/or `<DemoDescription>` right before a fence become that
|
|
103
|
+
* fence's card header:
|
|
104
|
+
*
|
|
105
|
+
* <DemoDescription>
|
|
106
|
+
* What the demo shows.
|
|
107
|
+
* </DemoDescription>
|
|
108
|
+
*
|
|
109
|
+
* ```tsx file="basic.demo.tsx" live
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* That's the same as wrapping the three in `<Demo>`, which also works. The
|
|
113
|
+
* fence's props are hoisted onto the `<Demo>`; a fence without `live` there
|
|
114
|
+
* makes a code-only card. A `<DemoTitle>` / `<DemoDescription>` with no fence
|
|
115
|
+
* after it fails the build.
|
|
97
116
|
*/
|
|
98
117
|
export function remarkDemoFences(options: RemarkDemoFencesOptions) {
|
|
99
118
|
const {
|
|
@@ -105,6 +124,7 @@ export function remarkDemoFences(options: RemarkDemoFencesOptions) {
|
|
|
105
124
|
demoSuffixes = ['.demo.tsx'],
|
|
106
125
|
componentName = 'Demo',
|
|
107
126
|
sourceReplacements,
|
|
127
|
+
fenceDefaults,
|
|
108
128
|
liveHeight = 'auto',
|
|
109
129
|
} = options;
|
|
110
130
|
const folder = options.folder.replace(/^\/+|\/+$/g, '');
|
|
@@ -117,13 +137,16 @@ export function remarkDemoFences(options: RemarkDemoFencesOptions) {
|
|
|
117
137
|
};
|
|
118
138
|
|
|
119
139
|
return () => (tree: any) => {
|
|
140
|
+
wrapLooseHeaders(tree, componentName, folder);
|
|
120
141
|
visit(tree, 'code', (node: any, index: number | undefined, parent: any) => {
|
|
121
142
|
if (index == null || !parent) return;
|
|
122
143
|
|
|
123
144
|
const inDemo = parent.type === 'mdxJsxFlowElement' && parent.name === componentName;
|
|
124
145
|
const meta: string = node.meta || '';
|
|
125
|
-
const
|
|
126
|
-
if (!inDemo && claim && !claim({ lang: node.lang ?? null, meta, props, inDemo })) return;
|
|
146
|
+
const ownProps = parseFenceMeta(meta);
|
|
147
|
+
if (!inDemo && claim && !claim({ lang: node.lang ?? null, meta, props: ownProps, inDemo })) return;
|
|
148
|
+
const isDemoFile = typeof ownProps.file === 'string' && demoSuffixes.some((s) => (ownProps.file as string).endsWith(s));
|
|
149
|
+
const props = applyFenceDefaults(ownProps, fenceDefaults, isDemoFile);
|
|
127
150
|
|
|
128
151
|
const context = `\`\`\`${node.lang ?? ''} ${meta} in "${path.join(path.basename(contentDir), folder)}"`;
|
|
129
152
|
|
|
@@ -282,6 +305,51 @@ export function remarkDemoFences(options: RemarkDemoFencesOptions) {
|
|
|
282
305
|
};
|
|
283
306
|
}
|
|
284
307
|
|
|
308
|
+
const HEADER_PARTS = new Set(['DemoTitle', 'DemoDescription']);
|
|
309
|
+
const isHeaderPart = (node: any) => node?.type === 'mdxJsxFlowElement' && HEADER_PARTS.has(node.name);
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Wraps each run of `<DemoTitle>` / `<DemoDescription>` (outside `<Demo>`)
|
|
313
|
+
* and the fence right after it in a `<Demo>`, so the fence handling below
|
|
314
|
+
* sees the same tree as for an explicit wrapper.
|
|
315
|
+
*/
|
|
316
|
+
function wrapLooseHeaders(tree: any, componentName: string, folder: string) {
|
|
317
|
+
visit(tree, (node: any) => {
|
|
318
|
+
if (!Array.isArray(node.children)) return;
|
|
319
|
+
if (node.type === 'mdxJsxFlowElement' && node.name === componentName) return 'skip';
|
|
320
|
+
const children: any[] = node.children;
|
|
321
|
+
for (let index = 0; index < children.length; index++) {
|
|
322
|
+
if (!isHeaderPart(children[index])) continue;
|
|
323
|
+
let end = index;
|
|
324
|
+
while (isHeaderPart(children[end])) end++;
|
|
325
|
+
const parts = children.slice(index, end);
|
|
326
|
+
const where = `"${folder}"${parts[0].position ? ` line ${parts[0].position.start.line}` : ''}`;
|
|
327
|
+
const names = parts.map((part) => part.name as string);
|
|
328
|
+
const repeated = names.find((name, i) => names.indexOf(name) !== i);
|
|
329
|
+
if (repeated) {
|
|
330
|
+
throw new Error(`<${repeated}> in ${where}: one per demo (each fence gets its own title and description)`);
|
|
331
|
+
}
|
|
332
|
+
const fence = children[end];
|
|
333
|
+
if (fence?.type !== 'code') {
|
|
334
|
+
throw new Error(
|
|
335
|
+
`<${names[0]}> in ${where} must come right before the code fence it describes ` +
|
|
336
|
+
`(or sit inside <${componentName}> with it)`,
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
const demo: MdxElement & { position?: unknown } = {
|
|
340
|
+
type: 'mdxJsxFlowElement',
|
|
341
|
+
name: componentName,
|
|
342
|
+
attributes: [],
|
|
343
|
+
children: [...parts, fence],
|
|
344
|
+
};
|
|
345
|
+
if (parts[0].position && fence.position) {
|
|
346
|
+
demo.position = { start: parts[0].position.start, end: fence.position.end };
|
|
347
|
+
}
|
|
348
|
+
children.splice(index, end - index + 1, demo);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
|
|
285
353
|
function element(name: string, attrs: Record<string, string>): MdxElement {
|
|
286
354
|
return {
|
|
287
355
|
type: 'mdxJsxFlowElement',
|