@@ -43,8 +43,26 @@ type DocsJson = {
43
43
44
44
const newJson = docsJson_ as ExportedTypeFile ;
45
45
46
- // console.log('test', (newJson['DockviewApi'] as any).children);
47
- console . log ( 'test' , firstLevel ( ( newJson [ 'DockviewApi' ] as any ) . children [ 29 ] ) ) ;
46
+ console . log ( newJson ) ;
47
+
48
+ export const DocumentRef = ( props : { value : TypeSystem . Type } ) => {
49
+ if ( ! props . value ) {
50
+ return null ;
51
+ }
52
+
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
+ }
65
+ } ;
48
66
49
67
export const Text = ( props : { content : DocsContent [ ] } ) => {
50
68
return (
@@ -96,69 +114,6 @@ export const Markdown = (props: { children: string }) => {
96
114
return < span > { props . children } </ span > ;
97
115
} ;
98
116
99
- const ClassPiece = ( props : { value : DocJson ; name : string } ) => {
100
- let code = `interface ${ props . name } {\n` ;
101
-
102
- code += props . value . children
103
- . map ( ( child ) => {
104
- switch ( child . kind ) {
105
- case 'accessor' :
106
- return `\t${ child . name } : ${ child . code } ;` ;
107
- case 'method' :
108
- return `\t${ child . name } ${ child . code } ;` ;
109
- default :
110
- return null ;
111
- }
112
- } )
113
- . filter ( Boolean )
114
- . join ( '\n' ) ;
115
-
116
- code += `\n}` ;
117
-
118
- return < CodeBlock language = "tsx" > { code } </ CodeBlock > ;
119
- } ;
120
-
121
- const InterfacePiece = ( props : { value : DocJson ; name : string } ) => {
122
- let code = `interface ${ props . name } {\n` ;
123
-
124
- code += props . value . children
125
- . map ( ( child ) => {
126
- switch ( child . kind ) {
127
- case 'property' :
128
- return `\t${ child . name } : ${ child . code } ;` ;
129
- default :
130
- return null ;
131
- }
132
- } )
133
- . join ( '\n' ) ;
134
-
135
- code += `\n}` ;
136
-
137
- return < CodeBlock language = "tsx" > { code } </ CodeBlock > ;
138
- } ;
139
-
140
- const Piece = ( props : { piece : string } ) => {
141
- const item = docsJson [ props . piece ] ;
142
-
143
- if ( ! item ) {
144
- return null ;
145
- }
146
-
147
- if ( item . kind === 'class' ) {
148
- return < ClassPiece name = { props . piece } value = { item } /> ;
149
- }
150
-
151
- if ( item . kind === 'interface' ) {
152
- return < InterfacePiece name = { props . piece } value = { item } /> ;
153
- }
154
-
155
- if ( ! item . metadata ?. code ) {
156
- return null ;
157
- }
158
-
159
- return < CodeBlock language = "tsx" > { item . metadata . code } </ CodeBlock > ;
160
- } ;
161
-
162
117
const Row = ( props : { doc : TypeSystem . Type } ) => {
163
118
const comment =
164
119
props . doc . kind === 'accessor'
@@ -259,7 +214,7 @@ export const DocRef = (props: DocRefProps) => {
259
214
< div >
260
215
{ firstLevel ( doc ) . map ( ( x ) => (
261
216
< span style = { { padding : '0px 2px' } } >
262
- { x }
217
+ < DocumentRef value = { newJson [ x ] } />
263
218
</ span >
264
219
) ) }
265
220
</ div >
0 commit comments