Skip to content

Commit 9e911a2

Browse files
committed
style: format
1 parent f74dafa commit 9e911a2

File tree

8 files changed

+121
-107
lines changed

8 files changed

+121
-107
lines changed

docs/app.config.ts

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
11
import { withSolidBase } from "@kobalte/solidbase/config";
22
import { defineConfig } from "@solidjs/start/config";
33

4-
export default defineConfig(withSolidBase(
5-
{},
6-
{
7-
title: "Solid-Docgen",
8-
description: "Documentation for Solid-Docgen",
9-
themeConfig: {
10-
nav: [
11-
{
12-
text: "Docs",
13-
link: "/guide",
14-
},
15-
{
16-
text: "Playground",
17-
link: "/playground",
18-
},
19-
],
20-
sidebar: {
21-
"/guide": {
22-
items: [
23-
{
24-
title: "Overview",
25-
collapsed: false,
26-
items: [
27-
{
28-
title: "About",
29-
link: "/",
30-
},
31-
{
32-
title: "Getting Started",
33-
link: "/getting-started",
34-
},
35-
],
36-
},
37-
],
38-
},
39-
},
40-
},
41-
}
42-
));
4+
export default defineConfig(
5+
withSolidBase(
6+
{},
7+
{
8+
title: "Solid-Docgen",
9+
description: "Documentation for Solid-Docgen",
10+
themeConfig: {
11+
nav: [
12+
{
13+
text: "Docs",
14+
link: "/guide",
15+
},
16+
{
17+
text: "Playground",
18+
link: "/playground",
19+
},
20+
],
21+
sidebar: {
22+
"/guide": {
23+
items: [
24+
{
25+
title: "Overview",
26+
collapsed: false,
27+
items: [
28+
{
29+
title: "About",
30+
link: "/",
31+
},
32+
{
33+
title: "Getting Started",
34+
link: "/getting-started",
35+
},
36+
],
37+
},
38+
],
39+
},
40+
},
41+
},
42+
},
43+
),
44+
);

docs/src/app.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { Router } from "@solidjs/router";
33
import { FileRoutes } from "@solidjs/start/router";
44

55
export default function App() {
6-
return (
7-
<Router root={SolidBaseRoot}>
8-
<FileRoutes />
9-
</Router>
10-
);
11-
}
6+
return (
7+
<Router root={SolidBaseRoot}>
8+
<FileRoutes />
9+
</Router>
10+
);
11+
}

docs/src/entry-client.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// @refresh reload
2-
import { mount, StartClient } from "@solidjs/start/client";
2+
import { StartClient, mount } from "@solidjs/start/client";
33

44
mount(() => <StartClient />, document.getElementById("app")!);

docs/src/entry-server.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
// @refresh reload
22
import { getHtmlProps } from "@kobalte/solidbase/server";
3-
import { createHandler, StartServer } from "@solidjs/start/server";
3+
import { StartServer, createHandler } from "@solidjs/start/server";
44

55
export default createHandler(() => (
6-
<StartServer
7-
document={({ assets, children, scripts }) => (
8-
<html {...getHtmlProps()}>
9-
<head>
10-
<meta charset="utf-8" />
11-
<meta name="viewport" content="width=device-width, initial-scale=1" />
12-
<link rel="icon" href="/favicon.ico" />
13-
{assets}
14-
</head>
15-
<body>
16-
<div id="app">{children}</div>
17-
{scripts}
18-
</body>
19-
</html>
20-
)}
21-
/>
6+
<StartServer
7+
document={({ assets, children, scripts }) => (
8+
<html {...getHtmlProps()}>
9+
<head>
10+
<meta charset="utf-8" />
11+
<meta name="viewport" content="width=device-width, initial-scale=1" />
12+
<link rel="icon" href="/favicon.ico" />
13+
{assets}
14+
</head>
15+
<body>
16+
<div id="app">{children}</div>
17+
{scripts}
18+
</body>
19+
</html>
20+
)}
21+
/>
2222
));

docs/src/routes/playground.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default function Playground() {
2-
return <div>Playground</div>;
3-
}
2+
return <div>Playground</div>;
3+
}

scripts/release.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { execSync } from "node:child_process";
22
import { Octokit } from "@octokit/core";
33

44
// @ts-ignore
5-
process.exit(1); // Not ready for release
5+
process.exit(0); // Not ready for release
66

77
if (!execSync("git --version").includes("git version")) {
88
console.error("Git not installed");

src/props.ts

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from "ts-morph";
99
import type {
1010
BooleanType,
11-
LiteralType,
11+
LiteralType,
1212
NullType,
1313
ObjectType,
1414
PropDescriptor,
@@ -55,7 +55,6 @@ export function parseProps(
5555
}
5656

5757
function parseType(type: Type<ts.Type>): TypeDescriptor {
58-
5958
if (type.isUnion()) {
6059
if (type.getText() === "boolean") {
6160
return {
@@ -73,56 +72,64 @@ function parseType(type: Type<ts.Type>): TypeDescriptor {
7372
if (type.isBooleanLiteral()) {
7473
return {
7574
name: "literal",
76-
value: type.getText() === "true",
75+
value: type.getText() === "true",
7776
} as LiteralType;
7877
}
7978

8079
if (type.isLiteral()) {
8180
return {
8281
name: "literal",
83-
value: type.getLiteralValue(),
82+
value: type.getLiteralValue(),
8483
} as LiteralType;
8584
}
8685

87-
if (type.isUndefined()) {
88-
return {
89-
name: "undefined",
90-
} as UndefinedType;
91-
}
86+
if (type.isUndefined()) {
87+
return {
88+
name: "undefined",
89+
} as UndefinedType;
90+
}
9291

93-
if (type.isNull()) {
94-
return {
95-
name: "null",
96-
} as NullType;
97-
}
92+
if (type.isNull()) {
93+
return {
94+
name: "null",
95+
} as NullType;
96+
}
9897

9998
if (type.isObject() || type.isInterface() || type.isAnonymous()) {
10099
return {
101100
name: "object",
102-
properties: Object.fromEntries(type.getProperties().map((prop) => {
103-
let parsed = parseType(prop.getValueDeclarationOrThrow().getType());
104-
105-
if (parsed.name === "union" && prop.isOptional()) {
106-
if (parsed.values.filter((v) => v.name !== "undefined").length === 1) {
107-
parsed = parsed.values.filter((v) => v.name !== "undefined")[0];
108-
} else if (parsed.values.filter((v) => v.name !== "undefined").length > 1) {
109-
parsed.values = parsed.values.filter((v) => v.name !== "undefined");
101+
properties: Object.fromEntries(
102+
type.getProperties().map((prop) => {
103+
let parsed = parseType(prop.getValueDeclarationOrThrow().getType());
104+
105+
if (parsed.name === "union" && prop.isOptional()) {
106+
if (
107+
parsed.values.filter((v) => v.name !== "undefined").length === 1
108+
) {
109+
parsed = parsed.values.filter((v) => v.name !== "undefined")[0];
110+
} else if (
111+
parsed.values.filter((v) => v.name !== "undefined").length > 1
112+
) {
113+
parsed.values = parsed.values.filter(
114+
(v) => v.name !== "undefined",
115+
);
116+
}
110117
}
111-
}
112-
113-
return [
114-
prop.getName(),
115-
{
116-
...parsed,
117-
required: !prop.isOptional(),
118-
},
119-
]
120-
})),
118+
119+
return [
120+
prop.getName(),
121+
{
122+
...parsed,
123+
required: !prop.isOptional(),
124+
},
125+
];
126+
}),
127+
),
121128
} as ObjectType;
122129
}
123-
130+
124131
return {
125132
name: "unknown",
126-
raw: type.getText(),
133+
raw: type.getText(),
127134
};
128135
}

src/types.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ export interface MethodDescriptor {
3131
returns: MethodReturn | null;
3232
}
3333

34-
export interface BaseType {
35-
}
34+
export interface BaseType {}
3635

3736
export interface UnionType extends BaseType {
3837
name: "union";
@@ -69,16 +68,22 @@ export interface ObjectType extends BaseType {
6968

7069
export type TypeDescriptor =
7170
| LiteralType
72-
| UnionType
71+
| UnionType
7372
| UnknownType
74-
| NullType
75-
| UndefinedType
76-
| BooleanType
73+
| NullType
74+
| UndefinedType
75+
| BooleanType
7776
| ObjectType;
7877

7978
export interface PropDescriptor {
8079
type: TypeDescriptor;
8180
required?: boolean;
82-
defaultValue?: this["type"] extends LiteralType ? this["type"]["value"] : this["type"] extends BooleanType ? boolean : this["type"] extends UnionType ? this["type"]["values"][] : unknown;
81+
defaultValue?: this["type"] extends LiteralType
82+
? this["type"]["value"]
83+
: this["type"] extends BooleanType
84+
? boolean
85+
: this["type"] extends UnionType
86+
? this["type"]["values"][]
87+
: unknown;
8388
description?: string;
8489
}

0 commit comments

Comments
 (0)