@razorwind/docgen 0.0.4 → 0.0.5
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/dist/extract.cjs +1 -0
- package/dist/extract.d.cts +21 -0
- package/dist/extract.d.cts.map +1 -0
- package/dist/extract.d.mts +21 -0
- package/dist/extract.d.mts.map +1 -0
- package/dist/extract.mjs +2 -0
- package/dist/extract.mjs.map +1 -0
- package/dist/generate-BVV7jy8B.d.cts +169 -0
- package/dist/generate-BVV7jy8B.d.cts.map +1 -0
- package/dist/generate-BVV7jy8B.d.mts +169 -0
- package/dist/generate-BVV7jy8B.d.mts.map +1 -0
- package/dist/generate-BaetoMHt.mjs +18 -0
- package/dist/generate-BaetoMHt.mjs.map +1 -0
- package/dist/generate-CPxzlB2Y.cjs +17 -0
- package/dist/generate.cjs +1 -0
- package/dist/generate.d.cts +2 -0
- package/dist/generate.d.mts +2 -0
- package/dist/generate.mjs +1 -0
- package/dist/index.cjs +1 -17
- package/dist/index.d.cts +3 -197
- package/dist/index.d.mts +3 -197
- package/dist/index.mjs +1 -18
- package/dist/rolldown-runtime-BIInC43l.cjs +1 -0
- package/dist/rolldown-runtime-DK3Fl9T5.mjs +1 -0
- package/package.json +32 -4
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/extract.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime-BIInC43l.cjs");let t=require("@razorwind/core/plugin");var n=e.t({default:()=>r}),r=(0,t.definePlugin)((e={})=>({name:`docgen:extract`,extract:async e=>e}));exports.default=r,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare namespace extract_d_exports {
|
|
2
|
+
export { _default as default };
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Razorwind plugin that passes through the design-system specification during
|
|
6
|
+
* extract. Documentation pages are produced by the generate plugin.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { defineConfig } from "@razorwind/core";
|
|
11
|
+
* import docgen from "@razorwind/docgen/extract";
|
|
12
|
+
*
|
|
13
|
+
* export default defineConfig({
|
|
14
|
+
* plugins: [docgen()]
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare const _default: any;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { _default as default, extract_d_exports as t };
|
|
21
|
+
//# sourceMappingURL=extract.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.d.cts","names":[],"sources":["../src/extract.ts"],"mappings":";;;;;;;;;;;;;;;;;cAqBA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare namespace extract_d_exports {
|
|
2
|
+
export { _default as default };
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Razorwind plugin that passes through the design-system specification during
|
|
6
|
+
* extract. Documentation pages are produced by the generate plugin.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { defineConfig } from "@razorwind/core";
|
|
11
|
+
* import docgen from "@razorwind/docgen/extract";
|
|
12
|
+
*
|
|
13
|
+
* export default defineConfig({
|
|
14
|
+
* plugins: [docgen()]
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare const _default: any;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { _default as default, extract_d_exports as t };
|
|
21
|
+
//# sourceMappingURL=extract.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.d.mts","names":[],"sources":["../src/extract.ts"],"mappings":""}
|
package/dist/extract.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
2
|
+
import { Schema } from "@razorwind/core/schema";
|
|
3
|
+
import { TokenType } from "@power-plant/dtcg-schema";
|
|
4
|
+
//#region src/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Options for the Razorwind MDX documentation generator.
|
|
7
|
+
*/
|
|
8
|
+
interface DocgenGeneratePluginOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Directory (relative to the execution cwd) where generated docs are written.
|
|
11
|
+
*
|
|
12
|
+
* @defaultValue `"docs/design-system"`
|
|
13
|
+
*/
|
|
14
|
+
outDir?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Title used on the generated documentation index page.
|
|
17
|
+
*
|
|
18
|
+
* @defaultValue `"Design System"`
|
|
19
|
+
*/
|
|
20
|
+
title?: string;
|
|
21
|
+
/**
|
|
22
|
+
* CSS custom-property prefix used when emitting `var(--…)` references.
|
|
23
|
+
*
|
|
24
|
+
* @defaultValue `"rw"`
|
|
25
|
+
*/
|
|
26
|
+
cssVarPrefix?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Restrict generated docs to these DTCG `$type` values.
|
|
29
|
+
* When omitted, all supported types are included.
|
|
30
|
+
*/
|
|
31
|
+
includeTypes?: TokenType[];
|
|
32
|
+
/**
|
|
33
|
+
* Skip generating component documentation pages.
|
|
34
|
+
*
|
|
35
|
+
* @defaultValue `false`
|
|
36
|
+
*/
|
|
37
|
+
skipRegistry?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A flattened design token ready for documentation rendering.
|
|
41
|
+
*/
|
|
42
|
+
interface FlatToken {
|
|
43
|
+
/** Dot-separated token path (e.g. `color.primary`). */
|
|
44
|
+
path: string;
|
|
45
|
+
/** DTCG `$type`, when known. */
|
|
46
|
+
type?: TokenType | string;
|
|
47
|
+
/** Raw `$value` from the token document. */
|
|
48
|
+
value: unknown;
|
|
49
|
+
/** CSS-friendly string form of {@link value}. */
|
|
50
|
+
cssValue: string;
|
|
51
|
+
/** Stable CSS custom property name for this path. */
|
|
52
|
+
cssVar: string;
|
|
53
|
+
/** Optional DTCG `$description`. */
|
|
54
|
+
description?: string;
|
|
55
|
+
/** Theme / set id when tokens are a `Record<string, Tokens>`. */
|
|
56
|
+
theme?: string;
|
|
57
|
+
}
|
|
58
|
+
declare namespace generate_d_exports {
|
|
59
|
+
export { COMPONENT_TYPES, ComponentDocType, REGISTRY_ITEM_TYPES, RegistryItemPage, RegistryItemType, _default as default, extractRegistryItems, generateDocs, groupTokens, renderGroupMdx, renderIndexMdx, renderRegistryItemsMdx, renderTokenTable, tokenGroup };
|
|
60
|
+
}
|
|
61
|
+
/** Top-level path segment used to group tokens into pages. */
|
|
62
|
+
declare function tokenGroup(token: FlatToken): string;
|
|
63
|
+
/**
|
|
64
|
+
* Group flattened tokens by their top-level path segment.
|
|
65
|
+
*/
|
|
66
|
+
declare function groupTokens(tokens: FlatToken[]): Map<string, FlatToken[]>;
|
|
67
|
+
/**
|
|
68
|
+
* Render a markdown token table for a set of flattened tokens.
|
|
69
|
+
*/
|
|
70
|
+
declare function renderTokenTable(tokens: FlatToken[]): string;
|
|
71
|
+
/**
|
|
72
|
+
* Render an MDX documentation page for a single token group.
|
|
73
|
+
*/
|
|
74
|
+
declare function renderGroupMdx(group: string, tokens: FlatToken[]): string;
|
|
75
|
+
/**
|
|
76
|
+
* Render the documentation index page linking to every generated page.
|
|
77
|
+
*/
|
|
78
|
+
declare function renderIndexMdx(input: {
|
|
79
|
+
title: string;
|
|
80
|
+
groups: Map<string, FlatToken[]>;
|
|
81
|
+
hasComponents: boolean;
|
|
82
|
+
componentPages?: {
|
|
83
|
+
slug: string;
|
|
84
|
+
title: string;
|
|
85
|
+
count: number;
|
|
86
|
+
}[];
|
|
87
|
+
}): string;
|
|
88
|
+
/** Component types that receive a dedicated documentation page. */
|
|
89
|
+
declare const COMPONENT_TYPES: {
|
|
90
|
+
readonly ui: {
|
|
91
|
+
readonly slug: "ui";
|
|
92
|
+
readonly title: "UI Primitives";
|
|
93
|
+
};
|
|
94
|
+
readonly component: {
|
|
95
|
+
readonly slug: "components";
|
|
96
|
+
readonly title: "Components";
|
|
97
|
+
};
|
|
98
|
+
readonly page: {
|
|
99
|
+
readonly slug: "pages";
|
|
100
|
+
readonly title: "Pages";
|
|
101
|
+
};
|
|
102
|
+
readonly block: {
|
|
103
|
+
readonly slug: "blocks";
|
|
104
|
+
readonly title: "Blocks";
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/** @deprecated Use {@link COMPONENT_TYPES}. */
|
|
108
|
+
declare const REGISTRY_ITEM_TYPES: {
|
|
109
|
+
readonly "registry:ui": {
|
|
110
|
+
readonly slug: "ui";
|
|
111
|
+
readonly title: "UI Primitives";
|
|
112
|
+
};
|
|
113
|
+
readonly "registry:component": {
|
|
114
|
+
readonly slug: "components";
|
|
115
|
+
readonly title: "Components";
|
|
116
|
+
};
|
|
117
|
+
readonly "registry:page": {
|
|
118
|
+
readonly slug: "pages";
|
|
119
|
+
readonly title: "Pages";
|
|
120
|
+
};
|
|
121
|
+
readonly "registry:block": {
|
|
122
|
+
readonly slug: "blocks";
|
|
123
|
+
readonly title: "Blocks";
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
type ComponentDocType = keyof typeof COMPONENT_TYPES;
|
|
127
|
+
type RegistryItemType = keyof typeof REGISTRY_ITEM_TYPES;
|
|
128
|
+
/** A documented component type together with its matching items. */
|
|
129
|
+
interface RegistryItemPage {
|
|
130
|
+
type: ComponentDocType;
|
|
131
|
+
slug: string;
|
|
132
|
+
title: string;
|
|
133
|
+
items: Record<string, unknown>[];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Extract documented components from `schema.components`, grouped by type.
|
|
137
|
+
*
|
|
138
|
+
* Only `ui`, `component`, `page` and `block` items are documented — one page
|
|
139
|
+
* per type.
|
|
140
|
+
*/
|
|
141
|
+
declare function extractRegistryItems(components: unknown): RegistryItemPage[];
|
|
142
|
+
/**
|
|
143
|
+
* Render an MDX documentation page for all components of a single type.
|
|
144
|
+
*/
|
|
145
|
+
declare function renderRegistryItemsMdx(page: RegistryItemPage): string;
|
|
146
|
+
/**
|
|
147
|
+
* Generate MDX documentation pages from a Razorwind schema.
|
|
148
|
+
*
|
|
149
|
+
* Produces an index page, one page per top-level token group, component
|
|
150
|
+
* pages grouped by type, and a flattened `tokens.json` manifest.
|
|
151
|
+
*/
|
|
152
|
+
declare function generateDocs(spec: Schema, options?: DocgenGeneratePluginOptions): GeneratorFunctionResult<Schema, DocgenGeneratePluginOptions>;
|
|
153
|
+
/**
|
|
154
|
+
* Generate MDX documentation pages from a Razorwind schema.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* import { defineConfig } from "@razorwind/core";
|
|
159
|
+
* import docgen from "@razorwind/docgen/generate";
|
|
160
|
+
*
|
|
161
|
+
* export default defineConfig({
|
|
162
|
+
* plugins: [docgen()]
|
|
163
|
+
* });
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
declare const _default: any;
|
|
167
|
+
//#endregion
|
|
168
|
+
export { RegistryItemType as a, generateDocs as c, renderGroupMdx as d, renderIndexMdx as f, tokenGroup as h, RegistryItemPage as i, generate_d_exports as l, renderTokenTable as m, ComponentDocType as n, _default as o, renderRegistryItemsMdx as p, REGISTRY_ITEM_TYPES as r, extractRegistryItems as s, COMPONENT_TYPES as t, groupTokens as u };
|
|
169
|
+
//# sourceMappingURL=generate-BVV7jy8B.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-BVV7jy8B.d.cts","names":[],"sources":["../src/types.ts","../src/generate.ts"],"mappings":";;;;;;;UA4BiB;;;;;;EAMf;;;;;;EAOA;;;;;;EAOA;;;;;EAMA,eAAe;;;;;;EAOf;;;;;UAMe;;EAEf;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;iBCjCc,WAAW,OAAO;;;;iBAOlB,YAAY,QAAQ,cAAc,YAAY;;;;iBAoB9C,iBAAiB,QAAQ;;;;iBAiDzB,eAAe,eAAe,QAAQ;;;;iBA8BtC,eAAe;EAC7B;EACA,QAAQ,YAAY;EACpB;EACA;IAAmB;IAAc;IAAe;;;;cA8CrC;;;;;;;;;;;;;;;;;;;cAQA;;;;;;;;;;;;;;;;;;KAOD,gCAAgC;KAChC,gCAAgC;;UAG3B;EACf,MAAM;EACN;EACA;EACA,OAAO;;;;;;;;iBA8DO,qBAAqB,sBAAsB;;;;iBAmH3C,uBAAuB,MAAM;;;;;;;iBAwC7B,aACd,MAAM,QACN,UAAS,8BACR,wBAAwB,QAAQ"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
2
|
+
import { Schema } from "@razorwind/core/schema";
|
|
3
|
+
import { TokenType } from "@power-plant/dtcg-schema";
|
|
4
|
+
//#region src/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Options for the Razorwind MDX documentation generator.
|
|
7
|
+
*/
|
|
8
|
+
interface DocgenGeneratePluginOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Directory (relative to the execution cwd) where generated docs are written.
|
|
11
|
+
*
|
|
12
|
+
* @defaultValue `"docs/design-system"`
|
|
13
|
+
*/
|
|
14
|
+
outDir?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Title used on the generated documentation index page.
|
|
17
|
+
*
|
|
18
|
+
* @defaultValue `"Design System"`
|
|
19
|
+
*/
|
|
20
|
+
title?: string;
|
|
21
|
+
/**
|
|
22
|
+
* CSS custom-property prefix used when emitting `var(--…)` references.
|
|
23
|
+
*
|
|
24
|
+
* @defaultValue `"rw"`
|
|
25
|
+
*/
|
|
26
|
+
cssVarPrefix?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Restrict generated docs to these DTCG `$type` values.
|
|
29
|
+
* When omitted, all supported types are included.
|
|
30
|
+
*/
|
|
31
|
+
includeTypes?: TokenType[];
|
|
32
|
+
/**
|
|
33
|
+
* Skip generating component documentation pages.
|
|
34
|
+
*
|
|
35
|
+
* @defaultValue `false`
|
|
36
|
+
*/
|
|
37
|
+
skipRegistry?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A flattened design token ready for documentation rendering.
|
|
41
|
+
*/
|
|
42
|
+
interface FlatToken {
|
|
43
|
+
/** Dot-separated token path (e.g. `color.primary`). */
|
|
44
|
+
path: string;
|
|
45
|
+
/** DTCG `$type`, when known. */
|
|
46
|
+
type?: TokenType | string;
|
|
47
|
+
/** Raw `$value` from the token document. */
|
|
48
|
+
value: unknown;
|
|
49
|
+
/** CSS-friendly string form of {@link value}. */
|
|
50
|
+
cssValue: string;
|
|
51
|
+
/** Stable CSS custom property name for this path. */
|
|
52
|
+
cssVar: string;
|
|
53
|
+
/** Optional DTCG `$description`. */
|
|
54
|
+
description?: string;
|
|
55
|
+
/** Theme / set id when tokens are a `Record<string, Tokens>`. */
|
|
56
|
+
theme?: string;
|
|
57
|
+
}
|
|
58
|
+
declare namespace generate_d_exports {
|
|
59
|
+
export { COMPONENT_TYPES, ComponentDocType, REGISTRY_ITEM_TYPES, RegistryItemPage, RegistryItemType, _default as default, extractRegistryItems, generateDocs, groupTokens, renderGroupMdx, renderIndexMdx, renderRegistryItemsMdx, renderTokenTable, tokenGroup };
|
|
60
|
+
}
|
|
61
|
+
/** Top-level path segment used to group tokens into pages. */
|
|
62
|
+
declare function tokenGroup(token: FlatToken): string;
|
|
63
|
+
/**
|
|
64
|
+
* Group flattened tokens by their top-level path segment.
|
|
65
|
+
*/
|
|
66
|
+
declare function groupTokens(tokens: FlatToken[]): Map<string, FlatToken[]>;
|
|
67
|
+
/**
|
|
68
|
+
* Render a markdown token table for a set of flattened tokens.
|
|
69
|
+
*/
|
|
70
|
+
declare function renderTokenTable(tokens: FlatToken[]): string;
|
|
71
|
+
/**
|
|
72
|
+
* Render an MDX documentation page for a single token group.
|
|
73
|
+
*/
|
|
74
|
+
declare function renderGroupMdx(group: string, tokens: FlatToken[]): string;
|
|
75
|
+
/**
|
|
76
|
+
* Render the documentation index page linking to every generated page.
|
|
77
|
+
*/
|
|
78
|
+
declare function renderIndexMdx(input: {
|
|
79
|
+
title: string;
|
|
80
|
+
groups: Map<string, FlatToken[]>;
|
|
81
|
+
hasComponents: boolean;
|
|
82
|
+
componentPages?: {
|
|
83
|
+
slug: string;
|
|
84
|
+
title: string;
|
|
85
|
+
count: number;
|
|
86
|
+
}[];
|
|
87
|
+
}): string;
|
|
88
|
+
/** Component types that receive a dedicated documentation page. */
|
|
89
|
+
declare const COMPONENT_TYPES: {
|
|
90
|
+
readonly ui: {
|
|
91
|
+
readonly slug: "ui";
|
|
92
|
+
readonly title: "UI Primitives";
|
|
93
|
+
};
|
|
94
|
+
readonly component: {
|
|
95
|
+
readonly slug: "components";
|
|
96
|
+
readonly title: "Components";
|
|
97
|
+
};
|
|
98
|
+
readonly page: {
|
|
99
|
+
readonly slug: "pages";
|
|
100
|
+
readonly title: "Pages";
|
|
101
|
+
};
|
|
102
|
+
readonly block: {
|
|
103
|
+
readonly slug: "blocks";
|
|
104
|
+
readonly title: "Blocks";
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/** @deprecated Use {@link COMPONENT_TYPES}. */
|
|
108
|
+
declare const REGISTRY_ITEM_TYPES: {
|
|
109
|
+
readonly "registry:ui": {
|
|
110
|
+
readonly slug: "ui";
|
|
111
|
+
readonly title: "UI Primitives";
|
|
112
|
+
};
|
|
113
|
+
readonly "registry:component": {
|
|
114
|
+
readonly slug: "components";
|
|
115
|
+
readonly title: "Components";
|
|
116
|
+
};
|
|
117
|
+
readonly "registry:page": {
|
|
118
|
+
readonly slug: "pages";
|
|
119
|
+
readonly title: "Pages";
|
|
120
|
+
};
|
|
121
|
+
readonly "registry:block": {
|
|
122
|
+
readonly slug: "blocks";
|
|
123
|
+
readonly title: "Blocks";
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
type ComponentDocType = keyof typeof COMPONENT_TYPES;
|
|
127
|
+
type RegistryItemType = keyof typeof REGISTRY_ITEM_TYPES;
|
|
128
|
+
/** A documented component type together with its matching items. */
|
|
129
|
+
interface RegistryItemPage {
|
|
130
|
+
type: ComponentDocType;
|
|
131
|
+
slug: string;
|
|
132
|
+
title: string;
|
|
133
|
+
items: Record<string, unknown>[];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Extract documented components from `schema.components`, grouped by type.
|
|
137
|
+
*
|
|
138
|
+
* Only `ui`, `component`, `page` and `block` items are documented — one page
|
|
139
|
+
* per type.
|
|
140
|
+
*/
|
|
141
|
+
declare function extractRegistryItems(components: unknown): RegistryItemPage[];
|
|
142
|
+
/**
|
|
143
|
+
* Render an MDX documentation page for all components of a single type.
|
|
144
|
+
*/
|
|
145
|
+
declare function renderRegistryItemsMdx(page: RegistryItemPage): string;
|
|
146
|
+
/**
|
|
147
|
+
* Generate MDX documentation pages from a Razorwind schema.
|
|
148
|
+
*
|
|
149
|
+
* Produces an index page, one page per top-level token group, component
|
|
150
|
+
* pages grouped by type, and a flattened `tokens.json` manifest.
|
|
151
|
+
*/
|
|
152
|
+
declare function generateDocs(spec: Schema, options?: DocgenGeneratePluginOptions): GeneratorFunctionResult<Schema, DocgenGeneratePluginOptions>;
|
|
153
|
+
/**
|
|
154
|
+
* Generate MDX documentation pages from a Razorwind schema.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* import { defineConfig } from "@razorwind/core";
|
|
159
|
+
* import docgen from "@razorwind/docgen/generate";
|
|
160
|
+
*
|
|
161
|
+
* export default defineConfig({
|
|
162
|
+
* plugins: [docgen()]
|
|
163
|
+
* });
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
declare const _default: any;
|
|
167
|
+
//#endregion
|
|
168
|
+
export { RegistryItemType as a, generateDocs as c, renderGroupMdx as d, renderIndexMdx as f, tokenGroup as h, RegistryItemPage as i, generate_d_exports as l, renderTokenTable as m, ComponentDocType as n, _default as o, renderRegistryItemsMdx as p, REGISTRY_ITEM_TYPES as r, extractRegistryItems as s, COMPONENT_TYPES as t, groupTokens as u };
|
|
169
|
+
//# sourceMappingURL=generate-BVV7jy8B.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-BVV7jy8B.d.mts","names":[],"sources":["../src/types.ts","../src/generate.ts"],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{t as e}from"./rolldown-runtime-DK3Fl9T5.mjs";import{definePlugin as t}from"@razorwind/core/plugin";import{createDocument as n,formatTokenValue as r,toCssVar as i}from"@razorwind/core/utils";import{join as a}from"node:path";function o(e){return e.trim().replaceAll(/[^\w-]+/g,`-`).replaceAll(/-{2,}/g,`-`).replaceAll(/^-|-$/g,``).toLowerCase()}function s(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`|`,`\\|`).replaceAll(`<`,`\\<`).replaceAll(`{`,`\\{`).replaceAll(/\r?\n/g,` `)}const c=/^(?:light|dark|dim|high-contrast|hc|default|base|theme)(?:[._-].+)?$/i;function l(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function u(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function d(e){if(typeof e.$description==`string`)return e.$description;if(typeof e.description==`string`)return e.description}function f(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function p(e){if(`$value`in e)return e.$value;if(`value`in e)return e.value;if(typeof e.$ref==`string`)return e.$ref;if(typeof e.ref==`string`)return e.ref}function m(e,t,n,a,o,s){if(!l(e))return;let c=f(e,n);if(u(e)){let n=p(e),l=t.join(`.`);s.push({path:l,type:c,value:n,cssValue:r(n,c),cssVar:i(l,o),description:d(e),theme:a});return}for(let[n,r]of Object.entries(e))n.startsWith(`$`)||m(r,[...t,n],c,a,o,s)}function h(e){if(!l(e))return[];let t=Object.keys(e).filter(e=>!e.startsWith(`$`));return t.length>0&&t.every(e=>c.test(e))?t.map(t=>({id:t,tokens:e[t]})):[{id:`default`,tokens:e}]}function g(e,t={}){let n=t.cssVarPrefix??`rw`,r=t.includeTypes?new Set(t.includeTypes):void 0,i=[];for(let t of h(e)){let e=t.id==="default"?void 0:t.id;m(t.tokens,[],void 0,e,n,i)}return r?i.filter(e=>!e.type||r.has(e.type)):i}var _=e({COMPONENT_TYPES:()=>D,REGISTRY_ITEM_TYPES:()=>O,default:()=>z,extractRegistryItems:()=>N,generateDocs:()=>R,groupTokens:()=>S,renderGroupMdx:()=>T,renderIndexMdx:()=>E,renderRegistryItemsMdx:()=>I,renderTokenTable:()=>w,tokenGroup:()=>x});function v(e){return`---\n${Object.entries(e).map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(`
|
|
2
|
+
`)}\n---`}function y(e){return e.split(/[._-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function b(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function x(e){return e.path.split(`.`)[0]||`tokens`}function S(e){let t=new Map;for(let n of e){let e=x(n),r=t.get(e)??[];r.push(n),t.set(e,r)}return t}function C(e){return`<span style={{ display: "inline-block", width: "1.25em", height: "1.25em", borderRadius: "4px", verticalAlign: "middle", border: "1px solid rgba(128, 128, 128, 0.35)", background: ${JSON.stringify(e)} }} />`}function w(e){let t=e.some(e=>e.theme),n=e.some(e=>e.description),r=e.some(e=>e.type===`color`),i=[...r?[`Preview`]:[],`Token`,`Type`,`Value`,`CSS Variable`,...t?[`Theme`]:[],...n?[`Description`]:[]],a=e.toSorted((e,t)=>(e.theme??``).localeCompare(t.theme??``)||e.path.localeCompare(t.path)).map(e=>`| ${[...r?[e.type===`color`?C(e.cssValue):``]:[],`\`${s(e.path)}\``,e.type?`\`${s(String(e.type))}\``:`—`,`\`${s(e.cssValue)}\``,`\`${s(e.cssVar)}\``,...t?[e.theme?s(e.theme):`—`]:[],...n?[e.description?s(e.description):`—`]:[]].join(` | `)} |`);return[`| ${i.join(` | `)} |`,`| ${i.map(()=>`---`).join(` | `)} |`,...a].join(`
|
|
3
|
+
`)}function T(e,t){let n=y(e),r=[...new Set(t.map(e=>e.theme).filter(Boolean))],i=[v({title:n,description:`${n} design tokens for the Razorwind design system.`}),`# ${n}`,`${t.length} token${t.length===1?``:`s`} in the \`${e}\` group.`];if(r.length>1)for(let e of r.toSorted((e,t)=>e.localeCompare(t))){let n=t.filter(t=>t.theme===e);i.push(`## ${y(e)}`,w(n))}else i.push(w(t));return`${i.join(`
|
|
4
|
+
|
|
5
|
+
`)}\n`}function E(e){let{title:t,groups:n,hasComponents:r,componentPages:i=[]}=e,a=[...n.values()].reduce((e,t)=>e+t.length,0),s=[...n.keys()].toSorted((e,t)=>e.localeCompare(t)).map(e=>{let t=n.get(e)?.length??0;return`- [${y(e)}](./tokens/${o(e)}.mdx) — ${t} token${t===1?``:`s`}`}),c=[v({title:t,description:`Generated reference documentation for the ${t} design tokens and components.`}),`# ${t}`,`This documentation is generated from the design system specification. It covers ${a} design token${a===1?``:`s`} across ${n.size} group${n.size===1?``:`s`}.`,`## Design Tokens`,s.length>0?s.join(`
|
|
6
|
+
`):`_No design tokens found._`];if(r||i.length>0){let e=i.map(e=>`- [${e.title}](./registry/${e.slug}.mdx) — ${e.count} item${e.count===1?``:`s`}`);c.push(`## Components`,e.length>0?e.join(`
|
|
7
|
+
`):`_No components found._`)}return`${c.join(`
|
|
8
|
+
|
|
9
|
+
`)}\n`}const D={ui:{slug:`ui`,title:`UI Primitives`},component:{slug:`components`,title:`Components`},page:{slug:`pages`,title:`Pages`},block:{slug:`blocks`,title:`Blocks`}},O={"registry:ui":D.ui,"registry:component":D.component,"registry:page":D.page,"registry:block":D.block};function k(e,t){let n=e[t];return typeof n==`string`?n:void 0}function A(e,t){let n=e[t];return Array.isArray(n)?n.filter(e=>typeof e==`string`):[]}function j(e,t){let n=e[t];return Array.isArray(n)?n.filter(e=>typeof e==`string`):b(n)?Object.entries(n).map(([e,t])=>typeof t==`string`&&t!==`*`?`${e}@${t}`:e):[]}function M(e){let t=A(e,`categories`);if(t.length>0)return t;let n=A(e,`tags`),r=k(e,`category`);return[...r?[r]:[],...n.filter(e=>e!==r)]}function N(e){if(!b(e))return[];let t=Object.values(e).filter(b),n=[];for(let[e,r]of Object.entries(D)){let i=t.filter(t=>t.type===e);i.length>0&&n.push({type:e,slug:r.slug,title:r.title,items:i})}return n}function P(e){let t=(Array.isArray(e.files)?e.files:[]).map(e=>{if(typeof e==`string`)return`| \`${s(e)}\` | — | — |`;if(!b(e))return;let t=k(e,`path`);if(!t)return;let n=k(e,`type`),r=k(e,`target`);return`| \`${s(t)}\` | ${n?`\`${s(n)}\``:`—`} | ${r?`\`${s(r)}\``:`—`} |`}).filter(e=>e!==void 0);return t.length===0?``:[`| Path | Type | Target |`,`| --- | --- | --- |`,...t].join(`
|
|
10
|
+
`)}function F(e){let t=k(e,`name`)??`unknown`,n=k(e,`title`)??y(t),r=k(e,`description`),i=k(e,`author`),a=M(e),o=j(e,`dependencies`),c=j(e,`registryDependencies`),l=[`## ${n}`];r&&l.push(r);let u=[`- **Name:** \`${t}\``,`- **Type:** \`${String(e.type)}\``,...i?[`- **Author:** ${s(i)}`]:[],...a.length>0?[`- **Categories:** ${a.map(e=>`\`${e}\``).join(`, `)}`]:[]];l.push(u.join(`
|
|
11
|
+
`)),o.length>0&&l.push(`### Dependencies`,o.map(e=>`- \`${e}\``).join(`
|
|
12
|
+
`)),c.length>0&&l.push(`### Registry Dependencies`,c.map(e=>`- \`${e}\``).join(`
|
|
13
|
+
`));let d=P(e);return d&&l.push(`### Files`,d),l.join(`
|
|
14
|
+
|
|
15
|
+
`)}function I(e){let t=[v({title:e.title,description:`${e.title} available in the Razorwind component registry.`}),`# ${e.title}`,`${e.items.length} \`${e.type}\` item${e.items.length===1?``:`s`} in the component registry.`],n=e.items.toSorted((e,t)=>(k(e,`name`)??``).localeCompare(k(t,`name`)??``));for(let e of n)t.push(F(e));return`${t.join(`
|
|
16
|
+
|
|
17
|
+
`)}\n`}function L(e,t,r){return n(e,t,{name:`docgen`},r)}function R(e,t={}){let n=t.outDir??`docs/design-system`,r=t.title??`Design System`,i=g(e.tokens,t),s=S(i),c=t.skipRegistry?[]:N(e.components),l=c.length>0,u={[a(n,`index.mdx`)]:L(a(n,`index.mdx`),E({title:r,groups:s,hasComponents:l,componentPages:c.map(e=>({slug:e.slug,title:e.title,count:e.items.length}))}),`mdx`)};for(let[e,t]of s){let r=a(n,`tokens`,`${o(e)}.mdx`);u[r]=L(r,T(e,t),`mdx`)}for(let e of c){let t=a(n,`registry`,`${e.slug}.mdx`);u[t]=L(t,I(e),`mdx`)}return u[a(n,`tokens.json`)]=L(a(n,`tokens.json`),`${JSON.stringify(i,null,2)}\n`,`json`),u}var z=t((e={})=>({name:`docgen:generate`,generate:async t=>R(t,e)}));export{z as a,T as c,w as d,x as f,R as i,E as l,O as n,_ as o,N as r,S as s,D as t,I as u};
|
|
18
|
+
//# sourceMappingURL=generate-BaetoMHt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-BaetoMHt.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-BIInC43l.cjs");let t=require("@razorwind/core/plugin"),n=require("@razorwind/core/utils"),r=require("node:path");function i(e){return e.trim().replaceAll(/[^\w-]+/g,`-`).replaceAll(/-{2,}/g,`-`).replaceAll(/^-|-$/g,``).toLowerCase()}function a(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`|`,`\\|`).replaceAll(`<`,`\\<`).replaceAll(`{`,`\\{`).replaceAll(/\r?\n/g,` `)}const o=/^(?:light|dark|dim|high-contrast|hc|default|base|theme)(?:[._-].+)?$/i;function s(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function c(e){return`$value`in e||`value`in e||`$ref`in e||`ref`in e}function l(e){if(typeof e.$description==`string`)return e.$description;if(typeof e.description==`string`)return e.description}function u(e,t){return typeof e.$type==`string`?e.$type:typeof e.type==`string`?e.type:t}function d(e){if(`$value`in e)return e.$value;if(`value`in e)return e.value;if(typeof e.$ref==`string`)return e.$ref;if(typeof e.ref==`string`)return e.ref}function f(e,t,r,i,a,o){if(!s(e))return;let p=u(e,r);if(c(e)){let r=d(e),s=t.join(`.`);o.push({path:s,type:p,value:r,cssValue:(0,n.formatTokenValue)(r,p),cssVar:(0,n.toCssVar)(s,a),description:l(e),theme:i});return}for(let[n,r]of Object.entries(e))n.startsWith(`$`)||f(r,[...t,n],p,i,a,o)}function p(e){if(!s(e))return[];let t=Object.keys(e).filter(e=>!e.startsWith(`$`));return t.length>0&&t.every(e=>o.test(e))?t.map(t=>({id:t,tokens:e[t]})):[{id:`default`,tokens:e}]}function m(e,t={}){let n=t.cssVarPrefix??`rw`,r=t.includeTypes?new Set(t.includeTypes):void 0,i=[];for(let t of p(e)){let e=t.id==="default"?void 0:t.id;f(t.tokens,[],void 0,e,n,i)}return r?i.filter(e=>!e.type||r.has(e.type)):i}var h=e.t({COMPONENT_TYPES:()=>T,REGISTRY_ITEM_TYPES:()=>E,default:()=>L,extractRegistryItems:()=>j,generateDocs:()=>I,groupTokens:()=>b,renderGroupMdx:()=>C,renderIndexMdx:()=>w,renderRegistryItemsMdx:()=>P,renderTokenTable:()=>S,tokenGroup:()=>y});function g(e){return`---\n${Object.entries(e).map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(`
|
|
2
|
+
`)}\n---`}function _(e){return e.split(/[._-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function y(e){return e.path.split(`.`)[0]||`tokens`}function b(e){let t=new Map;for(let n of e){let e=y(n),r=t.get(e)??[];r.push(n),t.set(e,r)}return t}function x(e){return`<span style={{ display: "inline-block", width: "1.25em", height: "1.25em", borderRadius: "4px", verticalAlign: "middle", border: "1px solid rgba(128, 128, 128, 0.35)", background: ${JSON.stringify(e)} }} />`}function S(e){let t=e.some(e=>e.theme),n=e.some(e=>e.description),r=e.some(e=>e.type===`color`),i=[...r?[`Preview`]:[],`Token`,`Type`,`Value`,`CSS Variable`,...t?[`Theme`]:[],...n?[`Description`]:[]],o=e.toSorted((e,t)=>(e.theme??``).localeCompare(t.theme??``)||e.path.localeCompare(t.path)).map(e=>`| ${[...r?[e.type===`color`?x(e.cssValue):``]:[],`\`${a(e.path)}\``,e.type?`\`${a(String(e.type))}\``:`—`,`\`${a(e.cssValue)}\``,`\`${a(e.cssVar)}\``,...t?[e.theme?a(e.theme):`—`]:[],...n?[e.description?a(e.description):`—`]:[]].join(` | `)} |`);return[`| ${i.join(` | `)} |`,`| ${i.map(()=>`---`).join(` | `)} |`,...o].join(`
|
|
3
|
+
`)}function C(e,t){let n=_(e),r=[...new Set(t.map(e=>e.theme).filter(Boolean))],i=[g({title:n,description:`${n} design tokens for the Razorwind design system.`}),`# ${n}`,`${t.length} token${t.length===1?``:`s`} in the \`${e}\` group.`];if(r.length>1)for(let e of r.toSorted((e,t)=>e.localeCompare(t))){let n=t.filter(t=>t.theme===e);i.push(`## ${_(e)}`,S(n))}else i.push(S(t));return`${i.join(`
|
|
4
|
+
|
|
5
|
+
`)}\n`}function w(e){let{title:t,groups:n,hasComponents:r,componentPages:a=[]}=e,o=[...n.values()].reduce((e,t)=>e+t.length,0),s=[...n.keys()].toSorted((e,t)=>e.localeCompare(t)).map(e=>{let t=n.get(e)?.length??0;return`- [${_(e)}](./tokens/${i(e)}.mdx) — ${t} token${t===1?``:`s`}`}),c=[g({title:t,description:`Generated reference documentation for the ${t} design tokens and components.`}),`# ${t}`,`This documentation is generated from the design system specification. It covers ${o} design token${o===1?``:`s`} across ${n.size} group${n.size===1?``:`s`}.`,`## Design Tokens`,s.length>0?s.join(`
|
|
6
|
+
`):`_No design tokens found._`];if(r||a.length>0){let e=a.map(e=>`- [${e.title}](./registry/${e.slug}.mdx) — ${e.count} item${e.count===1?``:`s`}`);c.push(`## Components`,e.length>0?e.join(`
|
|
7
|
+
`):`_No components found._`)}return`${c.join(`
|
|
8
|
+
|
|
9
|
+
`)}\n`}const T={ui:{slug:`ui`,title:`UI Primitives`},component:{slug:`components`,title:`Components`},page:{slug:`pages`,title:`Pages`},block:{slug:`blocks`,title:`Blocks`}},E={"registry:ui":T.ui,"registry:component":T.component,"registry:page":T.page,"registry:block":T.block};function D(e,t){let n=e[t];return typeof n==`string`?n:void 0}function O(e,t){let n=e[t];return Array.isArray(n)?n.filter(e=>typeof e==`string`):[]}function k(e,t){let n=e[t];return Array.isArray(n)?n.filter(e=>typeof e==`string`):v(n)?Object.entries(n).map(([e,t])=>typeof t==`string`&&t!==`*`?`${e}@${t}`:e):[]}function A(e){let t=O(e,`categories`);if(t.length>0)return t;let n=O(e,`tags`),r=D(e,`category`);return[...r?[r]:[],...n.filter(e=>e!==r)]}function j(e){if(!v(e))return[];let t=Object.values(e).filter(v),n=[];for(let[e,r]of Object.entries(T)){let i=t.filter(t=>t.type===e);i.length>0&&n.push({type:e,slug:r.slug,title:r.title,items:i})}return n}function M(e){let t=(Array.isArray(e.files)?e.files:[]).map(e=>{if(typeof e==`string`)return`| \`${a(e)}\` | — | — |`;if(!v(e))return;let t=D(e,`path`);if(!t)return;let n=D(e,`type`),r=D(e,`target`);return`| \`${a(t)}\` | ${n?`\`${a(n)}\``:`—`} | ${r?`\`${a(r)}\``:`—`} |`}).filter(e=>e!==void 0);return t.length===0?``:[`| Path | Type | Target |`,`| --- | --- | --- |`,...t].join(`
|
|
10
|
+
`)}function N(e){let t=D(e,`name`)??`unknown`,n=D(e,`title`)??_(t),r=D(e,`description`),i=D(e,`author`),o=A(e),s=k(e,`dependencies`),c=k(e,`registryDependencies`),l=[`## ${n}`];r&&l.push(r);let u=[`- **Name:** \`${t}\``,`- **Type:** \`${String(e.type)}\``,...i?[`- **Author:** ${a(i)}`]:[],...o.length>0?[`- **Categories:** ${o.map(e=>`\`${e}\``).join(`, `)}`]:[]];l.push(u.join(`
|
|
11
|
+
`)),s.length>0&&l.push(`### Dependencies`,s.map(e=>`- \`${e}\``).join(`
|
|
12
|
+
`)),c.length>0&&l.push(`### Registry Dependencies`,c.map(e=>`- \`${e}\``).join(`
|
|
13
|
+
`));let d=M(e);return d&&l.push(`### Files`,d),l.join(`
|
|
14
|
+
|
|
15
|
+
`)}function P(e){let t=[g({title:e.title,description:`${e.title} available in the Razorwind component registry.`}),`# ${e.title}`,`${e.items.length} \`${e.type}\` item${e.items.length===1?``:`s`} in the component registry.`],n=e.items.toSorted((e,t)=>(D(e,`name`)??``).localeCompare(D(t,`name`)??``));for(let e of n)t.push(N(e));return`${t.join(`
|
|
16
|
+
|
|
17
|
+
`)}\n`}function F(e,t,r){return(0,n.createDocument)(e,t,{name:`docgen`},r)}function I(e,t={}){let n=t.outDir??`docs/design-system`,a=t.title??`Design System`,o=m(e.tokens,t),s=b(o),c=t.skipRegistry?[]:j(e.components),l=c.length>0,u={[(0,r.join)(n,`index.mdx`)]:F((0,r.join)(n,`index.mdx`),w({title:a,groups:s,hasComponents:l,componentPages:c.map(e=>({slug:e.slug,title:e.title,count:e.items.length}))}),`mdx`)};for(let[e,t]of s){let a=(0,r.join)(n,`tokens`,`${i(e)}.mdx`);u[a]=F(a,C(e,t),`mdx`)}for(let e of c){let t=(0,r.join)(n,`registry`,`${e.slug}.mdx`);u[t]=F(t,P(e),`mdx`)}return u[(0,r.join)(n,`tokens.json`)]=F((0,r.join)(n,`tokens.json`),`${JSON.stringify(o,null,2)}\n`,`json`),u}var L=(0,t.definePlugin)((e={})=>({name:`docgen:generate`,generate:async t=>I(t,e)}));Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return P}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./generate-CPxzlB2Y.cjs");exports.COMPONENT_TYPES=e.t,exports.REGISTRY_ITEM_TYPES=e.n,exports.default=e.a,exports.extractRegistryItems=e.r,exports.generateDocs=e.i,exports.groupTokens=e.s,exports.renderGroupMdx=e.c,exports.renderIndexMdx=e.l,exports.renderRegistryItemsMdx=e.u,exports.renderTokenTable=e.d,exports.tokenGroup=e.f;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as RegistryItemType, c as generateDocs, d as renderGroupMdx, f as renderIndexMdx, h as tokenGroup, i as RegistryItemPage, m as renderTokenTable, n as ComponentDocType, o as _default, p as renderRegistryItemsMdx, r as REGISTRY_ITEM_TYPES, s as extractRegistryItems, t as COMPONENT_TYPES, u as groupTokens } from "./generate-BVV7jy8B.cjs";
|
|
2
|
+
export { COMPONENT_TYPES, ComponentDocType, REGISTRY_ITEM_TYPES, RegistryItemPage, RegistryItemType, _default as default, extractRegistryItems, generateDocs, groupTokens, renderGroupMdx, renderIndexMdx, renderRegistryItemsMdx, renderTokenTable, tokenGroup };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as RegistryItemType, c as generateDocs, d as renderGroupMdx, f as renderIndexMdx, h as tokenGroup, i as RegistryItemPage, m as renderTokenTable, n as ComponentDocType, o as _default, p as renderRegistryItemsMdx, r as REGISTRY_ITEM_TYPES, s as extractRegistryItems, t as COMPONENT_TYPES, u as groupTokens } from "./generate-BVV7jy8B.mjs";
|
|
2
|
+
export { COMPONENT_TYPES, ComponentDocType, REGISTRY_ITEM_TYPES, RegistryItemPage, RegistryItemType, _default as default, extractRegistryItems, generateDocs, groupTokens, renderGroupMdx, renderIndexMdx, renderRegistryItemsMdx, renderTokenTable, tokenGroup };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,c as t,d as n,f as r,i,l as a,n as o,r as s,s as c,t as l,u}from"./generate-BaetoMHt.mjs";export{l as COMPONENT_TYPES,o as REGISTRY_ITEM_TYPES,e as default,s as extractRegistryItems,i as generateDocs,c as groupTokens,t as renderGroupMdx,a as renderIndexMdx,u as renderRegistryItemsMdx,n as renderTokenTable,r as tokenGroup};
|
package/dist/index.cjs
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
`)}\n---`}function h(e){return e.split(/[._-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function g(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _(e){return e.path.split(`.`)[0]||`tokens`}function v(e){let t=new Map;for(let n of e){let e=_(n),r=t.get(e)??[];r.push(n),t.set(e,r)}return t}function y(e){return`<span style={{ display: "inline-block", width: "1.25em", height: "1.25em", borderRadius: "4px", verticalAlign: "middle", border: "1px solid rgba(128, 128, 128, 0.35)", background: ${JSON.stringify(e)} }} />`}function b(e){let t=e.some(e=>e.theme),n=e.some(e=>e.description),r=e.some(e=>e.type===`color`),a=[...r?[`Preview`]:[],`Token`,`Type`,`Value`,`CSS Variable`,...t?[`Theme`]:[],...n?[`Description`]:[]],o=e.toSorted((e,t)=>(e.theme??``).localeCompare(t.theme??``)||e.path.localeCompare(t.path)).map(e=>`| ${[...r?[e.type===`color`?y(e.cssValue):``]:[],`\`${i(e.path)}\``,e.type?`\`${i(String(e.type))}\``:`—`,`\`${i(e.cssValue)}\``,`\`${i(e.cssVar)}\``,...t?[e.theme?i(e.theme):`—`]:[],...n?[e.description?i(e.description):`—`]:[]].join(` | `)} |`);return[`| ${a.join(` | `)} |`,`| ${a.map(()=>`---`).join(` | `)} |`,...o].join(`
|
|
3
|
-
`)}function x(e,t){let n=h(e),r=[...new Set(t.map(e=>e.theme).filter(Boolean))],i=[m({title:n,description:`${n} design tokens for the Razorwind design system.`}),`# ${n}`,`${t.length} token${t.length===1?``:`s`} in the \`${e}\` group.`];if(r.length>1)for(let e of r.toSorted((e,t)=>e.localeCompare(t))){let n=t.filter(t=>t.theme===e);i.push(`## ${h(e)}`,b(n))}else i.push(b(t));return`${i.join(`
|
|
4
|
-
|
|
5
|
-
`)}\n`}function S(e){let{title:t,groups:n,hasComponents:i,componentPages:a=[]}=e,o=[...n.values()].reduce((e,t)=>e+t.length,0),s=[...n.keys()].toSorted((e,t)=>e.localeCompare(t)).map(e=>{let t=n.get(e)?.length??0;return`- [${h(e)}](./tokens/${r(e)}.mdx) — ${t} token${t===1?``:`s`}`}),c=[m({title:t,description:`Generated reference documentation for the ${t} design tokens and components.`}),`# ${t}`,`This documentation is generated from the design system specification. It covers ${o} design token${o===1?``:`s`} across ${n.size} group${n.size===1?``:`s`}.`,`## Design Tokens`,s.length>0?s.join(`
|
|
6
|
-
`):`_No design tokens found._`];if(i||a.length>0){let e=a.map(e=>`- [${e.title}](./registry/${e.slug}.mdx) — ${e.count} item${e.count===1?``:`s`}`);c.push(`## Components`,e.length>0?e.join(`
|
|
7
|
-
`):`_No components found._`)}return`${c.join(`
|
|
8
|
-
|
|
9
|
-
`)}\n`}const C={ui:{slug:`ui`,title:`UI Primitives`},component:{slug:`components`,title:`Components`},page:{slug:`pages`,title:`Pages`},block:{slug:`blocks`,title:`Blocks`}},w={"registry:ui":C.ui,"registry:component":C.component,"registry:page":C.page,"registry:block":C.block};function T(e,t){let n=e[t];return typeof n==`string`?n:void 0}function E(e,t){let n=e[t];return Array.isArray(n)?n.filter(e=>typeof e==`string`):[]}function D(e,t){let n=e[t];return Array.isArray(n)?n.filter(e=>typeof e==`string`):g(n)?Object.entries(n).map(([e,t])=>typeof t==`string`&&t!==`*`?`${e}@${t}`:e):[]}function O(e){let t=E(e,`categories`);if(t.length>0)return t;let n=E(e,`tags`),r=T(e,`category`);return[...r?[r]:[],...n.filter(e=>e!==r)]}function k(e){if(!g(e))return[];let t=Object.values(e).filter(g),n=[];for(let[e,r]of Object.entries(C)){let i=t.filter(t=>t.type===e);i.length>0&&n.push({type:e,slug:r.slug,title:r.title,items:i})}return n}function A(e){let t=(Array.isArray(e.files)?e.files:[]).map(e=>{if(typeof e==`string`)return`| \`${i(e)}\` | — | — |`;if(!g(e))return;let t=T(e,`path`);if(!t)return;let n=T(e,`type`),r=T(e,`target`);return`| \`${i(t)}\` | ${n?`\`${i(n)}\``:`—`} | ${r?`\`${i(r)}\``:`—`} |`}).filter(e=>e!==void 0);return t.length===0?``:[`| Path | Type | Target |`,`| --- | --- | --- |`,...t].join(`
|
|
10
|
-
`)}function j(e){let t=T(e,`name`)??`unknown`,n=T(e,`title`)??h(t),r=T(e,`description`),a=T(e,`author`),o=O(e),s=D(e,`dependencies`),c=D(e,`registryDependencies`),l=[`## ${n}`];r&&l.push(r);let u=[`- **Name:** \`${t}\``,`- **Type:** \`${String(e.type)}\``,...a?[`- **Author:** ${i(a)}`]:[],...o.length>0?[`- **Categories:** ${o.map(e=>`\`${e}\``).join(`, `)}`]:[]];l.push(u.join(`
|
|
11
|
-
`)),s.length>0&&l.push(`### Dependencies`,s.map(e=>`- \`${e}\``).join(`
|
|
12
|
-
`)),c.length>0&&l.push(`### Registry Dependencies`,c.map(e=>`- \`${e}\``).join(`
|
|
13
|
-
`));let d=A(e);return d&&l.push(`### Files`,d),l.join(`
|
|
14
|
-
|
|
15
|
-
`)}function M(e){let t=[m({title:e.title,description:`${e.title} available in the Razorwind component registry.`}),`# ${e.title}`,`${e.items.length} \`${e.type}\` item${e.items.length===1?``:`s`} in the component registry.`],n=e.items.toSorted((e,t)=>(T(e,`name`)??``).localeCompare(T(t,`name`)??``));for(let e of n)t.push(j(e));return`${t.join(`
|
|
16
|
-
|
|
17
|
-
`)}\n`}function N(e,n,r){return(0,t.createDocument)(e,n,{name:`razorwind-docs`},r)}function P(e,t={}){let i=t.outDir??`docs/design-system`,a=t.title??`Design System`,o=p(e.tokens,t),s=v(o),c=t.skipRegistry?[]:k(e.components),l=c.length>0,u={[(0,n.join)(i,`index.mdx`)]:N((0,n.join)(i,`index.mdx`),S({title:a,groups:s,hasComponents:l,componentPages:c.map(e=>({slug:e.slug,title:e.title,count:e.items.length}))}),`mdx`)};for(let[e,t]of s){let a=(0,n.join)(i,`tokens`,`${r(e)}.mdx`);u[a]=N(a,x(e,t),`mdx`)}for(let e of c){let t=(0,n.join)(i,`registry`,`${e.slug}.mdx`);u[t]=N(t,M(e),`mdx`)}return u[(0,n.join)(i,`tokens.json`)]=N((0,n.join)(i,`tokens.json`),`${JSON.stringify(o,null,2)}\n`,`json`),u}var F=(0,e.definePlugin)({name:`razorwind-docs`,extract:async e=>e,validate:async()=>void 0,generate:async(e,t)=>P(e,t)});exports.COMPONENT_TYPES=C,exports.REGISTRY_ITEM_TYPES=w,exports.default=F,exports.escapeTableCell=i,exports.extractRegistryItems=k,exports.flattenTokens=p,Object.defineProperty(exports,"formatTokenValue",{enumerable:!0,get:function(){return t.formatTokenValue}}),exports.generateDocs=P,exports.groupTokens=v,exports.renderGroupMdx=x,exports.renderIndexMdx=S,exports.renderRegistryItemsMdx=M,exports.renderTokenTable=b,exports.resolveTokenSets=f,Object.defineProperty(exports,"toCssVar",{enumerable:!0,get:function(){return t.toCssVar}}),exports.toSlug=r;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./extract.cjs"),t=require("./generate-CPxzlB2Y.cjs");Object.defineProperty(exports,"extract",{enumerable:!0,get:function(){return e.t}}),Object.defineProperty(exports,"generate",{enumerable:!0,get:function(){return t.o}});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,197 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
5
|
-
//#region src/types.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Options for the Razorwind MDX documentation generator.
|
|
8
|
-
*/
|
|
9
|
-
interface Options {
|
|
10
|
-
/**
|
|
11
|
-
* Directory (relative to the execution cwd) where generated docs are written.
|
|
12
|
-
*
|
|
13
|
-
* @defaultValue `"docs/design-system"`
|
|
14
|
-
*/
|
|
15
|
-
outDir?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Title used on the generated documentation index page.
|
|
18
|
-
*
|
|
19
|
-
* @defaultValue `"Design System"`
|
|
20
|
-
*/
|
|
21
|
-
title?: string;
|
|
22
|
-
/**
|
|
23
|
-
* CSS custom-property prefix used when emitting `var(--…)` references.
|
|
24
|
-
*
|
|
25
|
-
* @defaultValue `"rw"`
|
|
26
|
-
*/
|
|
27
|
-
cssVarPrefix?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Restrict generated docs to these DTCG `$type` values.
|
|
30
|
-
* When omitted, all supported types are included.
|
|
31
|
-
*/
|
|
32
|
-
includeTypes?: TokenType[];
|
|
33
|
-
/**
|
|
34
|
-
* Skip generating component documentation pages.
|
|
35
|
-
*
|
|
36
|
-
* @defaultValue `false`
|
|
37
|
-
*/
|
|
38
|
-
skipRegistry?: boolean;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* A flattened design token ready for documentation rendering.
|
|
42
|
-
*/
|
|
43
|
-
interface FlatToken {
|
|
44
|
-
/** Dot-separated token path (e.g. `color.primary`). */
|
|
45
|
-
path: string;
|
|
46
|
-
/** DTCG `$type`, when known. */
|
|
47
|
-
type?: TokenType | string;
|
|
48
|
-
/** Raw `$value` from the token document. */
|
|
49
|
-
value: unknown;
|
|
50
|
-
/** CSS-friendly string form of {@link value}. */
|
|
51
|
-
cssValue: string;
|
|
52
|
-
/** Stable CSS custom property name for this path. */
|
|
53
|
-
cssVar: string;
|
|
54
|
-
/** Optional DTCG `$description`. */
|
|
55
|
-
description?: string;
|
|
56
|
-
/** Theme / set id when tokens are a `Record<string, Tokens>`. */
|
|
57
|
-
theme?: string;
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/flatten.d.ts
|
|
61
|
-
interface TokenSet {
|
|
62
|
-
id: string;
|
|
63
|
-
tokens: Tokens;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Split `Schema.tokens` into one or more named token sets.
|
|
67
|
-
*
|
|
68
|
-
* A record whose keys all look like themes (`light`, `dark`, …) is treated as
|
|
69
|
-
* multi-theme input; otherwise the whole document is a single set.
|
|
70
|
-
*/
|
|
71
|
-
declare function resolveTokenSets(tokens: Tokens | Record<string, Tokens>): TokenSet[];
|
|
72
|
-
/**
|
|
73
|
-
* Flatten DTCG token trees into documentation rows.
|
|
74
|
-
*/
|
|
75
|
-
declare function flattenTokens(tokens: Tokens | Record<string, Tokens>, options?: Pick<Options, "cssVarPrefix" | "includeTypes">): FlatToken[];
|
|
76
|
-
//#endregion
|
|
77
|
-
//#region src/format.d.ts
|
|
78
|
-
/**
|
|
79
|
-
* Convert an arbitrary label into a lowercase, dash-separated file slug.
|
|
80
|
-
*/
|
|
81
|
-
declare function toSlug(value: string): string;
|
|
82
|
-
/**
|
|
83
|
-
* Escape a value so it renders safely inside an MDX markdown table cell.
|
|
84
|
-
*/
|
|
85
|
-
declare function escapeTableCell(value: string): string;
|
|
86
|
-
//#endregion
|
|
87
|
-
//#region src/generate.d.ts
|
|
88
|
-
/**
|
|
89
|
-
* Group flattened tokens by their top-level path segment.
|
|
90
|
-
*/
|
|
91
|
-
declare function groupTokens(tokens: FlatToken[]): Map<string, FlatToken[]>;
|
|
92
|
-
/**
|
|
93
|
-
* Render a markdown token table for a set of flattened tokens.
|
|
94
|
-
*/
|
|
95
|
-
declare function renderTokenTable(tokens: FlatToken[]): string;
|
|
96
|
-
/**
|
|
97
|
-
* Render an MDX documentation page for a single token group.
|
|
98
|
-
*/
|
|
99
|
-
declare function renderGroupMdx(group: string, tokens: FlatToken[]): string;
|
|
100
|
-
/**
|
|
101
|
-
* Render the documentation index page linking to every generated page.
|
|
102
|
-
*/
|
|
103
|
-
declare function renderIndexMdx(input: {
|
|
104
|
-
title: string;
|
|
105
|
-
groups: Map<string, FlatToken[]>;
|
|
106
|
-
hasComponents: boolean;
|
|
107
|
-
componentPages?: {
|
|
108
|
-
slug: string;
|
|
109
|
-
title: string;
|
|
110
|
-
count: number;
|
|
111
|
-
}[];
|
|
112
|
-
}): string;
|
|
113
|
-
/** Component types that receive a dedicated documentation page. */
|
|
114
|
-
declare const COMPONENT_TYPES: {
|
|
115
|
-
readonly ui: {
|
|
116
|
-
readonly slug: "ui";
|
|
117
|
-
readonly title: "UI Primitives";
|
|
118
|
-
};
|
|
119
|
-
readonly component: {
|
|
120
|
-
readonly slug: "components";
|
|
121
|
-
readonly title: "Components";
|
|
122
|
-
};
|
|
123
|
-
readonly page: {
|
|
124
|
-
readonly slug: "pages";
|
|
125
|
-
readonly title: "Pages";
|
|
126
|
-
};
|
|
127
|
-
readonly block: {
|
|
128
|
-
readonly slug: "blocks";
|
|
129
|
-
readonly title: "Blocks";
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
/** @deprecated Use {@link COMPONENT_TYPES}. */
|
|
133
|
-
declare const REGISTRY_ITEM_TYPES: {
|
|
134
|
-
readonly "registry:ui": {
|
|
135
|
-
readonly slug: "ui";
|
|
136
|
-
readonly title: "UI Primitives";
|
|
137
|
-
};
|
|
138
|
-
readonly "registry:component": {
|
|
139
|
-
readonly slug: "components";
|
|
140
|
-
readonly title: "Components";
|
|
141
|
-
};
|
|
142
|
-
readonly "registry:page": {
|
|
143
|
-
readonly slug: "pages";
|
|
144
|
-
readonly title: "Pages";
|
|
145
|
-
};
|
|
146
|
-
readonly "registry:block": {
|
|
147
|
-
readonly slug: "blocks";
|
|
148
|
-
readonly title: "Blocks";
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
type ComponentDocType = keyof typeof COMPONENT_TYPES;
|
|
152
|
-
type RegistryItemType = keyof typeof REGISTRY_ITEM_TYPES;
|
|
153
|
-
/** A documented component type together with its matching items. */
|
|
154
|
-
interface RegistryItemPage {
|
|
155
|
-
type: ComponentDocType;
|
|
156
|
-
slug: string;
|
|
157
|
-
title: string;
|
|
158
|
-
items: Record<string, unknown>[];
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Extract documented components from `schema.components`, grouped by type.
|
|
162
|
-
*
|
|
163
|
-
* Only `ui`, `component`, `page` and `block` items are documented — one page
|
|
164
|
-
* per type.
|
|
165
|
-
*/
|
|
166
|
-
declare function extractRegistryItems(components: unknown): RegistryItemPage[];
|
|
167
|
-
/**
|
|
168
|
-
* Render an MDX documentation page for all components of a single type.
|
|
169
|
-
*/
|
|
170
|
-
declare function renderRegistryItemsMdx(page: RegistryItemPage): string;
|
|
171
|
-
/**
|
|
172
|
-
* Generate MDX documentation pages from a Razorwind schema.
|
|
173
|
-
*
|
|
174
|
-
* Produces an index page, one page per top-level token group, component
|
|
175
|
-
* pages grouped by type, and a flattened `tokens.json` manifest.
|
|
176
|
-
*/
|
|
177
|
-
declare function generateDocs(spec: Schema, options?: Options): GeneratorFunctionResult<Schema, Options>;
|
|
178
|
-
//#endregion
|
|
179
|
-
//#region src/index.d.ts
|
|
180
|
-
/**
|
|
181
|
-
* Razorwind plugin that turns the design system specification (tokens +
|
|
182
|
-
* optional components) into MDX documentation pages.
|
|
183
|
-
*
|
|
184
|
-
* @example
|
|
185
|
-
* ```ts
|
|
186
|
-
* import { defineConfig } from "@razorwind/core";
|
|
187
|
-
* import docs from "@razorwind/docs-generator";
|
|
188
|
-
*
|
|
189
|
-
* export default defineConfig({
|
|
190
|
-
* plugins: [docs]
|
|
191
|
-
* });
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
declare const _default: any;
|
|
195
|
-
//#endregion
|
|
196
|
-
export { COMPONENT_TYPES, type ComponentDocType, type FlatToken, type Options, REGISTRY_ITEM_TYPES, type RegistryItemPage, type RegistryItemType, _default as default, escapeTableCell, extractRegistryItems, flattenTokens, formatTokenValue, generateDocs, groupTokens, renderGroupMdx, renderIndexMdx, renderRegistryItemsMdx, renderTokenTable, resolveTokenSets, toCssVar, toSlug };
|
|
197
|
-
//# sourceMappingURL=index.d.cts.map
|
|
1
|
+
import { t as extract_d_exports } from "./extract.cjs";
|
|
2
|
+
import { l as generate_d_exports } from "./generate-BVV7jy8B.cjs";
|
|
3
|
+
export { extract_d_exports as extract, generate_d_exports as generate };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,197 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { GeneratorFunctionResult } from "@power-plant/core";
|
|
5
|
-
//#region src/types.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Options for the Razorwind MDX documentation generator.
|
|
8
|
-
*/
|
|
9
|
-
interface Options {
|
|
10
|
-
/**
|
|
11
|
-
* Directory (relative to the execution cwd) where generated docs are written.
|
|
12
|
-
*
|
|
13
|
-
* @defaultValue `"docs/design-system"`
|
|
14
|
-
*/
|
|
15
|
-
outDir?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Title used on the generated documentation index page.
|
|
18
|
-
*
|
|
19
|
-
* @defaultValue `"Design System"`
|
|
20
|
-
*/
|
|
21
|
-
title?: string;
|
|
22
|
-
/**
|
|
23
|
-
* CSS custom-property prefix used when emitting `var(--…)` references.
|
|
24
|
-
*
|
|
25
|
-
* @defaultValue `"rw"`
|
|
26
|
-
*/
|
|
27
|
-
cssVarPrefix?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Restrict generated docs to these DTCG `$type` values.
|
|
30
|
-
* When omitted, all supported types are included.
|
|
31
|
-
*/
|
|
32
|
-
includeTypes?: TokenType[];
|
|
33
|
-
/**
|
|
34
|
-
* Skip generating component documentation pages.
|
|
35
|
-
*
|
|
36
|
-
* @defaultValue `false`
|
|
37
|
-
*/
|
|
38
|
-
skipRegistry?: boolean;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* A flattened design token ready for documentation rendering.
|
|
42
|
-
*/
|
|
43
|
-
interface FlatToken {
|
|
44
|
-
/** Dot-separated token path (e.g. `color.primary`). */
|
|
45
|
-
path: string;
|
|
46
|
-
/** DTCG `$type`, when known. */
|
|
47
|
-
type?: TokenType | string;
|
|
48
|
-
/** Raw `$value` from the token document. */
|
|
49
|
-
value: unknown;
|
|
50
|
-
/** CSS-friendly string form of {@link value}. */
|
|
51
|
-
cssValue: string;
|
|
52
|
-
/** Stable CSS custom property name for this path. */
|
|
53
|
-
cssVar: string;
|
|
54
|
-
/** Optional DTCG `$description`. */
|
|
55
|
-
description?: string;
|
|
56
|
-
/** Theme / set id when tokens are a `Record<string, Tokens>`. */
|
|
57
|
-
theme?: string;
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/flatten.d.ts
|
|
61
|
-
interface TokenSet {
|
|
62
|
-
id: string;
|
|
63
|
-
tokens: Tokens;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Split `Schema.tokens` into one or more named token sets.
|
|
67
|
-
*
|
|
68
|
-
* A record whose keys all look like themes (`light`, `dark`, …) is treated as
|
|
69
|
-
* multi-theme input; otherwise the whole document is a single set.
|
|
70
|
-
*/
|
|
71
|
-
declare function resolveTokenSets(tokens: Tokens | Record<string, Tokens>): TokenSet[];
|
|
72
|
-
/**
|
|
73
|
-
* Flatten DTCG token trees into documentation rows.
|
|
74
|
-
*/
|
|
75
|
-
declare function flattenTokens(tokens: Tokens | Record<string, Tokens>, options?: Pick<Options, "cssVarPrefix" | "includeTypes">): FlatToken[];
|
|
76
|
-
//#endregion
|
|
77
|
-
//#region src/format.d.ts
|
|
78
|
-
/**
|
|
79
|
-
* Convert an arbitrary label into a lowercase, dash-separated file slug.
|
|
80
|
-
*/
|
|
81
|
-
declare function toSlug(value: string): string;
|
|
82
|
-
/**
|
|
83
|
-
* Escape a value so it renders safely inside an MDX markdown table cell.
|
|
84
|
-
*/
|
|
85
|
-
declare function escapeTableCell(value: string): string;
|
|
86
|
-
//#endregion
|
|
87
|
-
//#region src/generate.d.ts
|
|
88
|
-
/**
|
|
89
|
-
* Group flattened tokens by their top-level path segment.
|
|
90
|
-
*/
|
|
91
|
-
declare function groupTokens(tokens: FlatToken[]): Map<string, FlatToken[]>;
|
|
92
|
-
/**
|
|
93
|
-
* Render a markdown token table for a set of flattened tokens.
|
|
94
|
-
*/
|
|
95
|
-
declare function renderTokenTable(tokens: FlatToken[]): string;
|
|
96
|
-
/**
|
|
97
|
-
* Render an MDX documentation page for a single token group.
|
|
98
|
-
*/
|
|
99
|
-
declare function renderGroupMdx(group: string, tokens: FlatToken[]): string;
|
|
100
|
-
/**
|
|
101
|
-
* Render the documentation index page linking to every generated page.
|
|
102
|
-
*/
|
|
103
|
-
declare function renderIndexMdx(input: {
|
|
104
|
-
title: string;
|
|
105
|
-
groups: Map<string, FlatToken[]>;
|
|
106
|
-
hasComponents: boolean;
|
|
107
|
-
componentPages?: {
|
|
108
|
-
slug: string;
|
|
109
|
-
title: string;
|
|
110
|
-
count: number;
|
|
111
|
-
}[];
|
|
112
|
-
}): string;
|
|
113
|
-
/** Component types that receive a dedicated documentation page. */
|
|
114
|
-
declare const COMPONENT_TYPES: {
|
|
115
|
-
readonly ui: {
|
|
116
|
-
readonly slug: "ui";
|
|
117
|
-
readonly title: "UI Primitives";
|
|
118
|
-
};
|
|
119
|
-
readonly component: {
|
|
120
|
-
readonly slug: "components";
|
|
121
|
-
readonly title: "Components";
|
|
122
|
-
};
|
|
123
|
-
readonly page: {
|
|
124
|
-
readonly slug: "pages";
|
|
125
|
-
readonly title: "Pages";
|
|
126
|
-
};
|
|
127
|
-
readonly block: {
|
|
128
|
-
readonly slug: "blocks";
|
|
129
|
-
readonly title: "Blocks";
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
/** @deprecated Use {@link COMPONENT_TYPES}. */
|
|
133
|
-
declare const REGISTRY_ITEM_TYPES: {
|
|
134
|
-
readonly "registry:ui": {
|
|
135
|
-
readonly slug: "ui";
|
|
136
|
-
readonly title: "UI Primitives";
|
|
137
|
-
};
|
|
138
|
-
readonly "registry:component": {
|
|
139
|
-
readonly slug: "components";
|
|
140
|
-
readonly title: "Components";
|
|
141
|
-
};
|
|
142
|
-
readonly "registry:page": {
|
|
143
|
-
readonly slug: "pages";
|
|
144
|
-
readonly title: "Pages";
|
|
145
|
-
};
|
|
146
|
-
readonly "registry:block": {
|
|
147
|
-
readonly slug: "blocks";
|
|
148
|
-
readonly title: "Blocks";
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
type ComponentDocType = keyof typeof COMPONENT_TYPES;
|
|
152
|
-
type RegistryItemType = keyof typeof REGISTRY_ITEM_TYPES;
|
|
153
|
-
/** A documented component type together with its matching items. */
|
|
154
|
-
interface RegistryItemPage {
|
|
155
|
-
type: ComponentDocType;
|
|
156
|
-
slug: string;
|
|
157
|
-
title: string;
|
|
158
|
-
items: Record<string, unknown>[];
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Extract documented components from `schema.components`, grouped by type.
|
|
162
|
-
*
|
|
163
|
-
* Only `ui`, `component`, `page` and `block` items are documented — one page
|
|
164
|
-
* per type.
|
|
165
|
-
*/
|
|
166
|
-
declare function extractRegistryItems(components: unknown): RegistryItemPage[];
|
|
167
|
-
/**
|
|
168
|
-
* Render an MDX documentation page for all components of a single type.
|
|
169
|
-
*/
|
|
170
|
-
declare function renderRegistryItemsMdx(page: RegistryItemPage): string;
|
|
171
|
-
/**
|
|
172
|
-
* Generate MDX documentation pages from a Razorwind schema.
|
|
173
|
-
*
|
|
174
|
-
* Produces an index page, one page per top-level token group, component
|
|
175
|
-
* pages grouped by type, and a flattened `tokens.json` manifest.
|
|
176
|
-
*/
|
|
177
|
-
declare function generateDocs(spec: Schema, options?: Options): GeneratorFunctionResult<Schema, Options>;
|
|
178
|
-
//#endregion
|
|
179
|
-
//#region src/index.d.ts
|
|
180
|
-
/**
|
|
181
|
-
* Razorwind plugin that turns the design system specification (tokens +
|
|
182
|
-
* optional components) into MDX documentation pages.
|
|
183
|
-
*
|
|
184
|
-
* @example
|
|
185
|
-
* ```ts
|
|
186
|
-
* import { defineConfig } from "@razorwind/core";
|
|
187
|
-
* import docs from "@razorwind/docs-generator";
|
|
188
|
-
*
|
|
189
|
-
* export default defineConfig({
|
|
190
|
-
* plugins: [docs]
|
|
191
|
-
* });
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
declare const _default: any;
|
|
195
|
-
//#endregion
|
|
196
|
-
export { COMPONENT_TYPES, type ComponentDocType, type FlatToken, type Options, REGISTRY_ITEM_TYPES, type RegistryItemPage, type RegistryItemType, _default as default, escapeTableCell, extractRegistryItems, flattenTokens, formatTokenValue, generateDocs, groupTokens, renderGroupMdx, renderIndexMdx, renderRegistryItemsMdx, renderTokenTable, resolveTokenSets, toCssVar, toSlug };
|
|
197
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
import { t as extract_d_exports } from "./extract.mjs";
|
|
2
|
+
import { l as generate_d_exports } from "./generate-BVV7jy8B.mjs";
|
|
3
|
+
export { extract_d_exports as extract, generate_d_exports as generate };
|
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)}\n---`}function _(e){return e.split(/[._-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function y(e){return e.path.split(`.`)[0]||`tokens`}function b(e){let t=new Map;for(let n of e){let e=y(n),r=t.get(e)??[];r.push(n),t.set(e,r)}return t}function x(e){return`<span style={{ display: "inline-block", width: "1.25em", height: "1.25em", borderRadius: "4px", verticalAlign: "middle", border: "1px solid rgba(128, 128, 128, 0.35)", background: ${JSON.stringify(e)} }} />`}function S(e){let t=e.some(e=>e.theme),n=e.some(e=>e.description),r=e.some(e=>e.type===`color`),i=[...r?[`Preview`]:[],`Token`,`Type`,`Value`,`CSS Variable`,...t?[`Theme`]:[],...n?[`Description`]:[]],a=e.toSorted((e,t)=>(e.theme??``).localeCompare(t.theme??``)||e.path.localeCompare(t.path)).map(e=>`| ${[...r?[e.type===`color`?x(e.cssValue):``]:[],`\`${o(e.path)}\``,e.type?`\`${o(String(e.type))}\``:`—`,`\`${o(e.cssValue)}\``,`\`${o(e.cssVar)}\``,...t?[e.theme?o(e.theme):`—`]:[],...n?[e.description?o(e.description):`—`]:[]].join(` | `)} |`);return[`| ${i.join(` | `)} |`,`| ${i.map(()=>`---`).join(` | `)} |`,...a].join(`
|
|
3
|
-
`)}function C(e,t){let n=_(e),r=[...new Set(t.map(e=>e.theme).filter(Boolean))],i=[g({title:n,description:`${n} design tokens for the Razorwind design system.`}),`# ${n}`,`${t.length} token${t.length===1?``:`s`} in the \`${e}\` group.`];if(r.length>1)for(let e of r.toSorted((e,t)=>e.localeCompare(t))){let n=t.filter(t=>t.theme===e);i.push(`## ${_(e)}`,S(n))}else i.push(S(t));return`${i.join(`
|
|
4
|
-
|
|
5
|
-
`)}\n`}function w(e){let{title:t,groups:n,hasComponents:r,componentPages:i=[]}=e,o=[...n.values()].reduce((e,t)=>e+t.length,0),s=[...n.keys()].toSorted((e,t)=>e.localeCompare(t)).map(e=>{let t=n.get(e)?.length??0;return`- [${_(e)}](./tokens/${a(e)}.mdx) — ${t} token${t===1?``:`s`}`}),c=[g({title:t,description:`Generated reference documentation for the ${t} design tokens and components.`}),`# ${t}`,`This documentation is generated from the design system specification. It covers ${o} design token${o===1?``:`s`} across ${n.size} group${n.size===1?``:`s`}.`,`## Design Tokens`,s.length>0?s.join(`
|
|
6
|
-
`):`_No design tokens found._`];if(r||i.length>0){let e=i.map(e=>`- [${e.title}](./registry/${e.slug}.mdx) — ${e.count} item${e.count===1?``:`s`}`);c.push(`## Components`,e.length>0?e.join(`
|
|
7
|
-
`):`_No components found._`)}return`${c.join(`
|
|
8
|
-
|
|
9
|
-
`)}\n`}const T={ui:{slug:`ui`,title:`UI Primitives`},component:{slug:`components`,title:`Components`},page:{slug:`pages`,title:`Pages`},block:{slug:`blocks`,title:`Blocks`}},E={"registry:ui":T.ui,"registry:component":T.component,"registry:page":T.page,"registry:block":T.block};function D(e,t){let n=e[t];return typeof n==`string`?n:void 0}function O(e,t){let n=e[t];return Array.isArray(n)?n.filter(e=>typeof e==`string`):[]}function k(e,t){let n=e[t];return Array.isArray(n)?n.filter(e=>typeof e==`string`):v(n)?Object.entries(n).map(([e,t])=>typeof t==`string`&&t!==`*`?`${e}@${t}`:e):[]}function A(e){let t=O(e,`categories`);if(t.length>0)return t;let n=O(e,`tags`),r=D(e,`category`);return[...r?[r]:[],...n.filter(e=>e!==r)]}function j(e){if(!v(e))return[];let t=Object.values(e).filter(v),n=[];for(let[e,r]of Object.entries(T)){let i=t.filter(t=>t.type===e);i.length>0&&n.push({type:e,slug:r.slug,title:r.title,items:i})}return n}function M(e){let t=(Array.isArray(e.files)?e.files:[]).map(e=>{if(typeof e==`string`)return`| \`${o(e)}\` | — | — |`;if(!v(e))return;let t=D(e,`path`);if(!t)return;let n=D(e,`type`),r=D(e,`target`);return`| \`${o(t)}\` | ${n?`\`${o(n)}\``:`—`} | ${r?`\`${o(r)}\``:`—`} |`}).filter(e=>e!==void 0);return t.length===0?``:[`| Path | Type | Target |`,`| --- | --- | --- |`,...t].join(`
|
|
10
|
-
`)}function N(e){let t=D(e,`name`)??`unknown`,n=D(e,`title`)??_(t),r=D(e,`description`),i=D(e,`author`),a=A(e),s=k(e,`dependencies`),c=k(e,`registryDependencies`),l=[`## ${n}`];r&&l.push(r);let u=[`- **Name:** \`${t}\``,`- **Type:** \`${String(e.type)}\``,...i?[`- **Author:** ${o(i)}`]:[],...a.length>0?[`- **Categories:** ${a.map(e=>`\`${e}\``).join(`, `)}`]:[]];l.push(u.join(`
|
|
11
|
-
`)),s.length>0&&l.push(`### Dependencies`,s.map(e=>`- \`${e}\``).join(`
|
|
12
|
-
`)),c.length>0&&l.push(`### Registry Dependencies`,c.map(e=>`- \`${e}\``).join(`
|
|
13
|
-
`));let d=M(e);return d&&l.push(`### Files`,d),l.join(`
|
|
14
|
-
|
|
15
|
-
`)}function P(e){let t=[g({title:e.title,description:`${e.title} available in the Razorwind component registry.`}),`# ${e.title}`,`${e.items.length} \`${e.type}\` item${e.items.length===1?``:`s`} in the component registry.`],n=e.items.toSorted((e,t)=>(D(e,`name`)??``).localeCompare(D(t,`name`)??``));for(let e of n)t.push(N(e));return`${t.join(`
|
|
16
|
-
|
|
17
|
-
`)}\n`}function F(e,n,r){return t(e,n,{name:`razorwind-docs`},r)}function I(e,t={}){let n=t.outDir??`docs/design-system`,r=t.title??`Design System`,o=h(e.tokens,t),s=b(o),c=t.skipRegistry?[]:j(e.components),l=c.length>0,u={[i(n,`index.mdx`)]:F(i(n,`index.mdx`),w({title:r,groups:s,hasComponents:l,componentPages:c.map(e=>({slug:e.slug,title:e.title,count:e.items.length}))}),`mdx`)};for(let[e,t]of s){let r=i(n,`tokens`,`${a(e)}.mdx`);u[r]=F(r,C(e,t),`mdx`)}for(let e of c){let t=i(n,`registry`,`${e.slug}.mdx`);u[t]=F(t,P(e),`mdx`)}return u[i(n,`tokens.json`)]=F(i(n,`tokens.json`),`${JSON.stringify(o,null,2)}\n`,`json`),u}var L=e({name:`razorwind-docs`,extract:async e=>e,validate:async()=>void 0,generate:async(e,t)=>I(e,t)});export{T as COMPONENT_TYPES,E as REGISTRY_ITEM_TYPES,L as default,o as escapeTableCell,j as extractRegistryItems,h as flattenTokens,n as formatTokenValue,I as generateDocs,b as groupTokens,C as renderGroupMdx,w as renderIndexMdx,P as renderRegistryItemsMdx,S as renderTokenTable,m as resolveTokenSets,r as toCssVar,a as toSlug};
|
|
18
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import{t as e}from"./extract.mjs";import{o as t}from"./generate-BaetoMHt.mjs";export{e as extract,t as generate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};export{t};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razorwind/docgen",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Razorwind plugin that creates MDX documentation for the tokens/components defined in the design system.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "github",
|
|
8
8
|
"url": "https://github.com/storm-software/razorwind.git",
|
|
@@ -62,6 +62,34 @@
|
|
|
62
62
|
"default": "./dist/index.mjs"
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
+
"./extract": {
|
|
66
|
+
"require": {
|
|
67
|
+
"types": "./dist/extract.d.cts",
|
|
68
|
+
"default": "./dist/extract.cjs"
|
|
69
|
+
},
|
|
70
|
+
"import": {
|
|
71
|
+
"types": "./dist/extract.d.mts",
|
|
72
|
+
"default": "./dist/extract.mjs"
|
|
73
|
+
},
|
|
74
|
+
"default": {
|
|
75
|
+
"types": "./dist/extract.d.mts",
|
|
76
|
+
"default": "./dist/extract.mjs"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"./generate": {
|
|
80
|
+
"require": {
|
|
81
|
+
"types": "./dist/generate.d.cts",
|
|
82
|
+
"default": "./dist/generate.cjs"
|
|
83
|
+
},
|
|
84
|
+
"import": {
|
|
85
|
+
"types": "./dist/generate.d.mts",
|
|
86
|
+
"default": "./dist/generate.mjs"
|
|
87
|
+
},
|
|
88
|
+
"default": {
|
|
89
|
+
"types": "./dist/generate.d.mts",
|
|
90
|
+
"default": "./dist/generate.mjs"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
65
93
|
"./package.json": "./package.json"
|
|
66
94
|
},
|
|
67
95
|
"main": "./dist/index.cjs",
|
|
@@ -71,7 +99,7 @@
|
|
|
71
99
|
"dependencies": {
|
|
72
100
|
"@power-plant/core": "^0.0.37",
|
|
73
101
|
"@power-plant/dtcg-schema": "^0.0.1",
|
|
74
|
-
"@razorwind/core": "^0.0.
|
|
102
|
+
"@razorwind/core": "^0.0.9"
|
|
75
103
|
},
|
|
76
104
|
"devDependencies": {
|
|
77
105
|
"@powerlines/plugin-tsdown": "^0.1.560",
|
|
@@ -79,5 +107,5 @@
|
|
|
79
107
|
"typescript": "^6.0.3"
|
|
80
108
|
},
|
|
81
109
|
"publishConfig": { "access": "public" },
|
|
82
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "6ca83196e6028c6c051887e6390dbd62dd3b0582"
|
|
83
111
|
}
|
package/dist/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/flatten.ts","../src/format.ts","../src/generate.ts","../src/index.ts"],"mappings":";;;;;;;;UAuBiB;;;;;;EAMf;;;;;;EAOA;;;;;;EAOA;;;;;EAMA,eAAe;;;;;;EAOf;;;;;UAMe;;EAEf;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;;EAEA;;EAEA;;;;UCmCe;EACf;EACA,QAAQ;;;;;;;;iBASM,iBACd,QAAQ,SAAS,eAAe,UAC/B;;;;iBAsBa,cACd,QAAQ,SAAS,eAAe,SAChC,UAAS,KAAK,4CACb;;;;;;iBC9Ha,OAAO;;;;iBAYP,gBAAgB;;;;;;iBCmBhB,YAAY,QAAQ,cAAc,YAAY;;;;iBAoB9C,iBAAiB,QAAQ;;;;iBAiDzB,eAAe,eAAe,QAAQ;;;;iBA8BtC,eAAe;EAC7B;EACA,QAAQ,YAAY;EACpB;EACA;IAAmB;IAAc;IAAe;;;;cA8CrC;;;;;;;;;;;;;;;;;;;cAQA;;;;;;;;;;;;;;;;;;KAOD,gCAAgC;KAChC,gCAAgC;;UAG3B;EACf,MAAM;EACN;EACA;EACA,OAAO;;;;;;;;iBA8DO,qBAAqB,sBAAsB;;;;iBAmH3C,uBAAuB,MAAM;;;;;;;iBAwC7B,aACd,MAAM,QACN,UAAS,UACR,wBAAwB,QAAQ"}
|
package/dist/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/flatten.ts","../src/format.ts","../src/generate.ts","../src/index.ts"],"mappings":""}
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":[],"mappings":""}
|