Skip to content

Commit a71aa07

Browse files
committed
feat: stringify
1 parent 07482e6 commit a71aa07

File tree

38 files changed

+659
-541
lines changed

38 files changed

+659
-541
lines changed

docs/app.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export default defineConfig(
3838
title: "Getting Started",
3939
link: "/getting-started",
4040
},
41+
{
42+
title: "Examples",
43+
link: "/examples",
44+
},
4145
],
4246
},
4347
],

docs/package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,19 @@
1010
"@bigmistqke/repl": "^0.2.3",
1111
"@bigmistqke/vite-plugin-worker-proxy": "^0.0.12",
1212
"@bigmistqke/worker-proxy": "^0.0.12",
13-
"@kobalte/solidbase": "^0.2.6",
13+
"@iconify-json/ri": "^1.2.5",
14+
"@kobalte/solidbase": "^0.2.11",
1415
"@monaco-editor/loader": "^1.5.0",
1516
"@solidjs/router": "^0.15.3",
1617
"@solidjs/start": "^1.1.0",
1718
"monaco-editor": "^0.52.2",
19+
"solid-docgen": "workspace:*",
1820
"solid-js": "^1.9.5",
1921
"typescript": "^5.8.3",
20-
"vinxi": "^0.5.3",
22+
"vinxi": "^0.5.6",
2123
"vite": "6.3.0"
2224
},
2325
"engines": {
2426
"node": ">=22"
25-
},
26-
"devDependencies": {
27-
"@iconify-json/ri": "^1.2.5"
2827
}
2928
}

docs/src/component/PropsTable.tsx

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { mdxComponents } from "@kobalte/solidbase/client";
2+
import type { Documentation } from "solid-docgen";
3+
import { stringifyType } from "solid-docgen/stringify";
4+
import { Dynamic, For, Show } from "solid-js/web";
5+
6+
interface PropsTableProps {
7+
docgen: Documentation;
8+
}
9+
10+
export function PropsTable(props: PropsTableProps) {
11+
return (
12+
<>
13+
<Dynamic component={mdxComponents.h2}>{props.docgen.displayName}</Dynamic>
14+
15+
<Dynamic component={mdxComponents.table}>
16+
<thead>
17+
<tr>
18+
<th>Prop</th>
19+
<th>Type</th>
20+
<th>Default</th>
21+
<th>Description</th>
22+
</tr>
23+
</thead>
24+
<tbody>
25+
<For each={Object.entries(props.docgen.props ?? {})}>
26+
{([propName, propValue]) => (
27+
<tr>
28+
<td>
29+
<Dynamic component={mdxComponents.code}>
30+
{propName}
31+
{propValue.required ? "" : "?"}
32+
</Dynamic>
33+
</td>
34+
<td>
35+
<Dynamic component={mdxComponents.code}>
36+
{stringifyType(propValue.type)}
37+
</Dynamic>
38+
</td>
39+
<td>
40+
<Show when={propValue.defaultValue}>
41+
<Dynamic component={mdxComponents.code}>
42+
{stringifyType(propValue.defaultValue!, " ", ",")}
43+
</Dynamic>
44+
</Show>
45+
</td>
46+
<td>{propValue.description}</td>
47+
</tr>
48+
)}
49+
</For>
50+
</tbody>
51+
</Dynamic>
52+
</>
53+
);
54+
}

docs/src/routes/guide/examples.mdx

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
title: Examples
3+
---
4+
5+
import {PropsTable} from "~/component/PropsTable";
6+
7+
# Examples
8+
9+
10+
```tsx
11+
interface Props {
12+
/**
13+
* This is myProp.
14+
*/
15+
myProp?: "A";
16+
secondProp: "B";
17+
/**
18+
* Description of another.
19+
*
20+
* @default "C"
21+
*/
22+
another: "C" | "D" | undefined;
23+
/**
24+
* @default 4
25+
*/
26+
lastone?: 4 | 5;
27+
}
28+
29+
export function MyComp(props: Props) {
30+
return <></>;
31+
}
32+
```
33+
34+
<PropsTable docgen={{
35+
"displayName": "MyComp",
36+
"props": {
37+
"myProp": {
38+
"type": {
39+
"name": "literal",
40+
"value": "A",
41+
"raw": "\"A\""
42+
},
43+
"required": false,
44+
"description": "This is myProp."
45+
},
46+
"secondProp": {
47+
"type": {
48+
"name": "literal",
49+
"value": "B",
50+
"raw": "\"B\""
51+
},
52+
"required": true
53+
},
54+
"another": {
55+
"type": {
56+
"name": "union",
57+
"values": [
58+
{
59+
"name": "literal",
60+
"value": "C",
61+
"raw": "\"C\""
62+
},
63+
{
64+
"name": "literal",
65+
"value": "D",
66+
"raw": "\"D\""
67+
},
68+
{
69+
"name": "undefined",
70+
"raw": "undefined"
71+
}
72+
],
73+
"raw": "\"C\" | \"D\" | undefined"
74+
},
75+
"required": true,
76+
"description": "Description of another.",
77+
"defaultValue": {
78+
"name": "literal",
79+
"value": "C",
80+
"raw": "\"C\""
81+
}
82+
},
83+
"lastone": {
84+
"type": {
85+
"name": "union",
86+
"values": [
87+
{
88+
"name": "literal",
89+
"value": 4,
90+
"raw": "4"
91+
},
92+
{
93+
"name": "literal",
94+
"value": 5,
95+
"raw": "5"
96+
}
97+
],
98+
"raw": "4 | 5 | undefined"
99+
},
100+
"required": false,
101+
"defaultValue": {
102+
"name": "literal",
103+
"value": 4,
104+
"raw": "4"
105+
}
106+
}
107+
}
108+
}}/>

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.0.0-dev",
44
"description": "A library to extract information from Solid components for documentation generation.",
55
"type": "module",
6+
"sideEffects": false,
67
"scripts": {
78
"build": "tsc",
89
"check": "biome check",
@@ -25,8 +26,14 @@
2526
"/dist"
2627
],
2728
"exports": {
28-
"import": "./src/solid-mdx.ts",
29-
"types": "./src/solid-mdx.ts"
29+
".": {
30+
"import": "./src/index.ts",
31+
"types": "./src/index.ts"
32+
},
33+
"./stringify": {
34+
"import": "./src/stringify.ts",
35+
"types": "./src/stringify.ts"
36+
}
3037
},
3138
"devDependencies": {
3239
"@biomejs/biome": "^1.9.4",
@@ -41,5 +48,5 @@
4148
"dependencies": {
4249
"ts-morph": "^25.0.1"
4350
},
44-
"packageManager": "pnpm@9.15.4"
51+
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
4552
}

0 commit comments

Comments
 (0)