@@ -3,21 +3,23 @@ import { JSONOutput } from "typedoc";
3
3
import { Code } from "pages/components/code" ;
4
4
import { Type } from "pages/components/type" ;
5
5
import { PagePropsType } from "types/page.types" ;
6
- import { getCallPreview } from "pages/utils/parsing.utils" ;
7
6
import { getCommentNode } from "pages/handlers/comment" ;
7
+ import { getSignaturePreview } from "pages/utils" ;
8
8
9
9
export const Table = ( {
10
10
reflections,
11
11
reflectionsTree,
12
12
pageProps,
13
13
title,
14
14
className = "" ,
15
+ hideType = false ,
15
16
} : {
16
17
reflections : JSONOutput . SomeReflection [ ] ;
17
18
reflectionsTree : JSONOutput . ProjectReflection [ ] ;
18
19
pageProps : PagePropsType ;
19
20
title ?: string ;
20
21
className ?: string ;
22
+ hideType ?: boolean ;
21
23
} ) => {
22
24
return (
23
25
< div className = { `api-docs__table-wrapper ${ className } ` } >
@@ -26,31 +28,42 @@ export const Table = ({
26
28
< thead >
27
29
< tr >
28
30
< th > Name</ th >
29
- < th > Type</ th >
31
+ { ! hideType && < th > Type</ th > }
30
32
< th > Description</ th >
31
33
</ tr >
32
34
</ thead >
33
35
< tbody >
34
36
{ reflections . map ( ( reflection , index ) => {
35
37
const isMethod = "signatures" in reflection ;
36
- const callSignature =
37
- ( "signatures" in reflection &&
38
- reflection ?. signatures &&
39
- getCallPreview ( { signature : reflection . signatures [ 0 ] , reflectionsTree } ) ) ||
40
- "" ;
38
+ const name =
39
+ "signatures" in reflection && reflection ?. signatures
40
+ ? getSignaturePreview ( {
41
+ reflection : reflection . signatures [ 0 ] ,
42
+ reflectionsTree,
43
+ useArrow : true ,
44
+ hideGenerics : true ,
45
+ hideParamTypes : true ,
46
+ hideReturns : true ,
47
+ } )
48
+ : reflection . name ;
41
49
const type = "type" in reflection && typeof reflection . type !== "string" ? reflection . type : reflection ;
42
50
43
51
return (
44
52
< tr className = "api-docs__table-row" key = { index } >
45
- < td className = "api-docs__table-name" >
46
- { reflection . name }
47
- { isMethod ? callSignature : "" }
48
- </ td >
49
- < td className = "api-docs__table-type" >
50
- < Code >
51
- < Type { ...pageProps } reflection = { type } />
52
- </ Code >
53
- </ td >
53
+ { isMethod ? (
54
+ < td className = "api-docs__table-type" >
55
+ < Code > { name } </ Code >
56
+ </ td >
57
+ ) : (
58
+ < td className = "api-docs__table-name" > { name } </ td >
59
+ ) }
60
+ { ! hideType && (
61
+ < td className = "api-docs__table-type" >
62
+ < Code >
63
+ < Type { ...pageProps } reflection = { type } />
64
+ </ Code >
65
+ </ td >
66
+ ) }
54
67
< td className = "api-docs__table-description" > { getCommentNode ( reflection ) } </ td >
55
68
</ tr >
56
69
) ;
0 commit comments