Skip to content

Commit ce5b5da

Browse files
committed
chore: docs
1 parent 55a8d2f commit ce5b5da

File tree

4 files changed

+45
-204
lines changed

4 files changed

+45
-204
lines changed

packages/docs/sandboxes/react/dockview/demo-dockview/src/app.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const components = {
2828
position: 'relative',
2929
}}
3030
>
31-
<Table data={metadata} />
31+
{/* <Table data={metadata} /> */}
3232
<span
3333
style={{
3434
position: 'absolute',

packages/docs/src/components/ui/reference/docRef.tsx

+23-17
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,31 @@ type DocsJson = {
4343

4444
const newJson = docsJson_ as ExportedTypeFile;
4545

46-
console.log(newJson);
47-
4846
export const DocumentRef = (props: { value: TypeSystem.Type }) => {
49-
if (!props.value) {
47+
const code = React.useMemo(() => {
48+
if (!props.value) {
49+
return null;
50+
}
51+
52+
switch (props.value.kind) {
53+
case 'typeAlias':
54+
return codify(props.value);
55+
case 'interface':
56+
return codify(props.value);
57+
case 'class':
58+
return codify(props.value);
59+
case 'function':
60+
return codify(props.value);
61+
default:
62+
return null;
63+
}
64+
}, [props.value]);
65+
66+
if (!code) {
5067
return null;
5168
}
5269

53-
switch (props.value.kind) {
54-
case 'typealias':
55-
return codify(props.value);
56-
case 'interface':
57-
return codify(props.value);
58-
case 'class':
59-
return codify(props.value);
60-
case 'function':
61-
return codify(props.value);
62-
default:
63-
return <div>{'error'}</div>;
64-
}
70+
return <CodeBlock language="tsx">{code}</CodeBlock>;
6571
};
6672

6773
export const Text = (props: { content: DocsContent[] }) => {
@@ -211,13 +217,13 @@ export const DocRef = (props: DocRefProps) => {
211217
return (
212218
<>
213219
<Row key={i} doc={doc} />
214-
<div>
220+
{/* <div>
215221
{firstLevel(doc).map((x) => (
216222
<span style={{ padding: '0px 2px' }}>
217223
<DocumentRef value={newJson[x]} />
218224
</span>
219225
))}
220-
</div>
226+
</div> */}
221227
{/* {doc.pieces?.map((piece) => (
222228
<tr>
223229
<th colSpan={2}>

packages/docs/src/components/ui/reference/types.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export function codify(value: TypeSystem.Type | null) {
216216

217217
if (value.kind === 'typeLiteral') {
218218
if (value.properties) {
219-
return `{ ${value.properties.map(codify).join(', ')} }`;
219+
return `{\n${value.properties.map(codify).join(',\n')}\n}`;
220220
}
221221
if (value.signatures) {
222222
return value.signatures.map(codify).join('\n');
@@ -228,15 +228,19 @@ export function codify(value: TypeSystem.Type | null) {
228228
}
229229

230230
if (value.kind === 'interface') {
231-
return `interface ${value.name} { ${value.children
231+
return `interface ${value.name} {\n${value.children
232232
.map(codify)
233-
.join(',')} }`;
233+
.join(',\n')}\n}`;
234234
}
235235

236236
if (value.kind === 'class') {
237-
return `interface ${value.name} { ${value.children
237+
return `interface ${value.name} {\n${value.children
238238
.map(codify)
239-
.join(',')} }`;
239+
.join(',\n')}\n}`;
240+
}
241+
242+
if (value.kind === 'typeAlias') {
243+
return `type ${value.name} = ${codifyType(value.type)}`;
240244
}
241245

242246
console.log('unreachable', value);
@@ -300,7 +304,7 @@ export namespace TypeSystem {
300304

301305
export type TypeAlias = {
302306
name: string;
303-
kind: 'typealias';
307+
kind: 'typeAlias';
304308
typeParameters: TypeSystem.TypeParameter[];
305309
type: TypeDescriptor.Type;
306310
comment?: Comment;

0 commit comments

Comments
 (0)