File tree Expand file tree Collapse file tree 5 files changed +26
-16
lines changed Expand file tree Collapse file tree 5 files changed +26
-16
lines changed Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
2
3
3
import { PagePropsType } from "../../types/page.types" ;
4
- import { getCommentText } from "pages/handlers/comment" ;
4
+ import { getCommentNode } from "pages/handlers/comment" ;
5
5
6
6
export type DescriptionProps = {
7
7
className ?: string ;
@@ -10,11 +10,5 @@ export type DescriptionProps = {
10
10
export const Description : React . FC < PagePropsType & DescriptionProps > = ( props ) => {
11
11
const { reflection, className = "" } = props ;
12
12
13
- return (
14
- < div className = { `api-docs__description ${ className } ` } >
15
- { `
16
- ${ getCommentText ( reflection ) }
17
- ` }
18
- </ div >
19
- ) ;
13
+ return < div className = { `api-docs__description ${ className } ` } > { getCommentNode ( reflection ) } </ div > ;
20
14
} ;
Original file line number Diff line number Diff line change @@ -20,10 +20,26 @@ export const getCommentText = (reflection: JSONOutput.SomeReflection): string =>
20
20
if ( ! comment ) {
21
21
return "" ;
22
22
}
23
+ return comment ?. summary
24
+ . map ( ( { text } ) => text )
25
+ . join ( "\n" )
26
+ . trim ( ) ;
27
+ } ;
28
+
29
+ export const getCommentNode = ( reflection : JSONOutput . SomeReflection ) : React . ReactNode => {
30
+ const comment = getCommentText ( reflection ) . trim ( ) ;
31
+
32
+ if ( ! comment ) {
33
+ return null ;
34
+ }
23
35
// New line is necessary for MDX to parse it correctly - otherwise we would get errors
24
- return `\n
36
+ return (
37
+ < >
38
+ { `
25
39
26
- ${ comment ?. summary . map ( ( { text } ) => text ) . join ( "\n" ) }
40
+ ${ comment }
27
41
28
- \n` ;
42
+ ` }
43
+ </ >
44
+ ) ;
29
45
} ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { Code } from "pages/components/code";
4
4
import { Type } from "pages/components/type" ;
5
5
import { PagePropsType } from "types/page.types" ;
6
6
import { getCallPreview } from "pages/utils/parsing.utils" ;
7
- import { getCommentText } from "pages/handlers/comment" ;
7
+ import { getCommentNode } from "pages/handlers/comment" ;
8
8
9
9
export const Grid = ( {
10
10
reflections,
@@ -37,7 +37,7 @@ export const Grid = ({
37
37
< Type { ...pageProps } reflection = { type } />
38
38
</ Code >
39
39
</ div >
40
- < div className = "api-docs__grid-description" > { getCommentText ( reflection ) } </ div >
40
+ < div className = "api-docs__grid-description" > { getCommentNode ( reflection ) } </ div >
41
41
</ div >
42
42
) ;
43
43
} ) }
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { Code } from "pages/components/code";
4
4
import { Type } from "pages/components/type" ;
5
5
import { PagePropsType } from "types/page.types" ;
6
6
import { getCallPreview } from "pages/utils/parsing.utils" ;
7
- import { getCommentText } from "pages/handlers/comment" ;
7
+ import { getCommentNode } from "pages/handlers/comment" ;
8
8
9
9
export const Table = ( {
10
10
reflections,
@@ -46,7 +46,7 @@ export const Table = ({
46
46
< Type { ...pageProps } reflection = { type } />
47
47
</ Code >
48
48
</ td >
49
- < td className = "api-docs__table-description" > { getCommentText ( reflection ) . trim ( ) } </ td >
49
+ < td className = "api-docs__table-description" > { getCommentNode ( reflection ) } </ td >
50
50
</ tr >
51
51
) ;
52
52
} ) }
Original file line number Diff line number Diff line change 27
27
"peerDependencies" : {
28
28
"@docusaurus/plugin-content-docs" : " >= 2.0.0" ,
29
29
"@docusaurus/types" : " >= 2.0.0" ,
30
+ "@docsgen/core" : " *" ,
30
31
"react" : " >= 16.8.0" ,
31
32
"react-dom" : " >= 16.8.0"
32
33
},
33
34
"dependencies" : {
34
- "@docsgen/core" : " *" ,
35
35
"@reins/query-params" : " ^0.1.1" ,
36
36
"fs-extra" : " ^11.2.0" ,
37
37
"mdast-util-from-markdown" : " ^2.0.0" ,
You can’t perform that action at this time.
0 commit comments