Skip to content

Commit b9998a3

Browse files
committed
fix: 🐛 indentation
1 parent 45b4dbb commit b9998a3

File tree

5 files changed

+26
-16
lines changed

5 files changed

+26
-16
lines changed
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react";
22

33
import { PagePropsType } from "../../types/page.types";
4-
import { getCommentText } from "pages/handlers/comment";
4+
import { getCommentNode } from "pages/handlers/comment";
55

66
export type DescriptionProps = {
77
className?: string;
@@ -10,11 +10,5 @@ export type DescriptionProps = {
1010
export const Description: React.FC<PagePropsType & DescriptionProps> = (props) => {
1111
const { reflection, className = "" } = props;
1212

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>;
2014
};

packages/core/src/pages/handlers/comment.ts renamed to packages/core/src/pages/handlers/comment.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,26 @@ export const getCommentText = (reflection: JSONOutput.SomeReflection): string =>
2020
if (!comment) {
2121
return "";
2222
}
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+
}
2335
// New line is necessary for MDX to parse it correctly - otherwise we would get errors
24-
return `\n
36+
return (
37+
<>
38+
{`
2539
26-
${comment?.summary.map(({ text }) => text).join("\n")}
40+
${comment}
2741
28-
\n`;
42+
`}
43+
</>
44+
);
2945
};

packages/core/src/pages/modules/grid/grid.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Code } from "pages/components/code";
44
import { Type } from "pages/components/type";
55
import { PagePropsType } from "types/page.types";
66
import { getCallPreview } from "pages/utils/parsing.utils";
7-
import { getCommentText } from "pages/handlers/comment";
7+
import { getCommentNode } from "pages/handlers/comment";
88

99
export const Grid = ({
1010
reflections,
@@ -37,7 +37,7 @@ export const Grid = ({
3737
<Type {...pageProps} reflection={type} />
3838
</Code>
3939
</div>
40-
<div className="api-docs__grid-description">{getCommentText(reflection)}</div>
40+
<div className="api-docs__grid-description">{getCommentNode(reflection)}</div>
4141
</div>
4242
);
4343
})}

packages/core/src/pages/modules/table/table.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Code } from "pages/components/code";
44
import { Type } from "pages/components/type";
55
import { PagePropsType } from "types/page.types";
66
import { getCallPreview } from "pages/utils/parsing.utils";
7-
import { getCommentText } from "pages/handlers/comment";
7+
import { getCommentNode } from "pages/handlers/comment";
88

99
export const Table = ({
1010
reflections,
@@ -46,7 +46,7 @@ export const Table = ({
4646
<Type {...pageProps} reflection={type} />
4747
</Code>
4848
</td>
49-
<td className="api-docs__table-description">{getCommentText(reflection).trim()}</td>
49+
<td className="api-docs__table-description">{getCommentNode(reflection)}</td>
5050
</tr>
5151
);
5252
})}

packages/docusaurus/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
"peerDependencies": {
2828
"@docusaurus/plugin-content-docs": ">= 2.0.0",
2929
"@docusaurus/types": ">= 2.0.0",
30+
"@docsgen/core": "*",
3031
"react": ">= 16.8.0",
3132
"react-dom": ">= 16.8.0"
3233
},
3334
"dependencies": {
34-
"@docsgen/core": "*",
3535
"@reins/query-params": "^0.1.1",
3636
"fs-extra": "^11.2.0",
3737
"mdast-util-from-markdown": "^2.0.0",

0 commit comments

Comments
 (0)