@@ -3,20 +3,48 @@ import useFrontMatter from "./useFrontMatter";
3
3
4
4
const CBParameters = ( ) => {
5
5
const frontMatter = useFrontMatter ( ) ;
6
+ const formatReturnType = ( returns ) => {
7
+ if ( ! returns || ! returns . signatureTypeName ) return "" ;
8
+
9
+ if ( returns . typeArgs && returns . typeArgs . length > 0 ) {
10
+ const typeArg = returns . typeArgs [ 0 ] ;
11
+ switch ( typeArg . type ) {
12
+ case "array" :
13
+ return "[ ]" ;
14
+ case "void" :
15
+ return "void" ;
16
+ case "intrinsic" :
17
+ return "" ;
18
+ case "reference" :
19
+ return "" ;
20
+ default :
21
+ return `${ returns . signatureTypeName } <${ typeArg . name } >` ;
22
+ }
23
+ } else {
24
+ // Handle no typeArgs or unsupported types
25
+ return returns . signatureTypeName ;
26
+ }
27
+ } ;
6
28
7
29
return (
8
30
< div >
9
31
{ Object . entries ( frontMatter ) . map ( ( [ key , value ] ) => {
10
32
if ( key === "cbparameters" ) {
11
33
const hasParameters = value . parameters && value . parameters . length > 0 ;
12
- const hasReturns = value . returns && value . returns . signatureTypeName && value . returns . description ;
34
+ const hasReturns =
35
+ value . returns &&
36
+ value . returns . signatureTypeName &&
37
+ value . returns . description &&
38
+ value . returns . typeArgs &&
39
+ value . returns . typeArgs . length > 0 &&
40
+ value . returns . typeArgs [ 0 ] . name ;
13
41
14
42
return (
15
43
< div >
16
44
{ hasParameters && (
17
45
< div >
18
46
< h3 > Parameters</ h3 >
19
- < table className = "table" >
47
+ < table className = "table" >
20
48
< thead >
21
49
< tr >
22
50
< th > Name</ th >
@@ -39,21 +67,15 @@ const CBParameters = () => {
39
67
40
68
{ hasReturns && (
41
69
< div >
42
- < h3 > Returns</ h3 >
43
- < table className = "table" >
44
- < thead >
45
- < tr >
46
- < th > Type</ th >
47
- < th > Description</ th >
48
- </ tr >
49
- </ thead >
50
- < tbody >
51
- < tr >
52
- < td > { value . returns . signatureTypeName } </ td >
53
- < td > { value . returns . description } </ td >
54
- </ tr >
55
- </ tbody >
56
- </ table >
70
+ < h3 > Returns:</ h3 >
71
+ < div className = "description" >
72
+ { " " }
73
+ { `${ value . returns . signatureTypeName } <${
74
+ value . returns . typeArgs [ 0 ] . name || ""
75
+ } ${ formatReturnType ( value . returns ) } >`}
76
+ </ div >
77
+
78
+ { value . returns . description }
57
79
</ div >
58
80
) }
59
81
</ div >
0 commit comments