|
1 | 1 | import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; |
2 | | -import { JSX } from "../../../../utils"; |
| 2 | +import { JSX, Raw } from "../../../../utils"; |
3 | 3 | import { ReflectionType, SignatureReflection } from "../../../../models"; |
4 | 4 | import { hasTypeParameters, renderFlags } from "../../lib"; |
5 | 5 |
|
6 | | -export const memberSignatureBody = ( |
| 6 | +export function memberSignatureBody( |
7 | 7 | context: DefaultThemeRenderContext, |
8 | 8 | props: SignatureReflection, |
9 | 9 | { hideSources = false }: { hideSources?: boolean } = {} |
10 | | -) => ( |
11 | | - <> |
12 | | - {renderFlags(props.flags, props.comment)} |
13 | | - {context.comment(props)} |
| 10 | +) { |
| 11 | + const returnsTag = props.comment?.getTag("@returns"); |
14 | 12 |
|
15 | | - {hasTypeParameters(props) && context.typeParameters(props.typeParameters)} |
| 13 | + return ( |
| 14 | + <> |
| 15 | + {renderFlags(props.flags, props.comment)} |
| 16 | + {context.comment(props)} |
16 | 17 |
|
17 | | - {props.parameters && props.parameters.length > 0 && ( |
18 | | - <div class="tsd-parameters"> |
19 | | - <h4 class="tsd-parameters-title">Parameters</h4> |
20 | | - <ul class="tsd-parameter-list"> |
21 | | - {props.parameters.map((item) => ( |
22 | | - <li> |
23 | | - <h5> |
24 | | - {renderFlags(item.flags, item.comment)} |
25 | | - {!!item.flags.isRest && <span class="tsd-signature-symbol">...</span>} |
26 | | - <span class="tsd-kind-parameter">{item.name}</span> |
27 | | - {": "} |
28 | | - {context.type(item.type)} |
29 | | - {item.defaultValue != null && ( |
30 | | - <span class="tsd-signature-symbol"> |
31 | | - {" = "} |
32 | | - {item.defaultValue} |
33 | | - </span> |
34 | | - )} |
35 | | - </h5> |
36 | | - {context.comment(item)} |
37 | | - {item.type instanceof ReflectionType && context.parameter(item.type.declaration)} |
38 | | - </li> |
39 | | - ))} |
40 | | - </ul> |
41 | | - </div> |
42 | | - )} |
43 | | - {props.type && ( |
44 | | - <> |
45 | | - <h4 class="tsd-returns-title"> |
46 | | - {"Returns "} |
47 | | - {context.type(props.type)} |
48 | | - </h4> |
49 | | - {props.type instanceof ReflectionType && context.parameter(props.type.declaration)} |
50 | | - </> |
51 | | - )} |
52 | | - {!hideSources && context.memberSources(props)} |
53 | | - </> |
54 | | -); |
| 18 | + {hasTypeParameters(props) && context.typeParameters(props.typeParameters)} |
| 19 | + |
| 20 | + {props.parameters && props.parameters.length > 0 && ( |
| 21 | + <div class="tsd-parameters"> |
| 22 | + <h4 class="tsd-parameters-title">Parameters</h4> |
| 23 | + <ul class="tsd-parameter-list"> |
| 24 | + {props.parameters.map((item) => ( |
| 25 | + <li> |
| 26 | + <h5> |
| 27 | + {renderFlags(item.flags, item.comment)} |
| 28 | + {!!item.flags.isRest && <span class="tsd-signature-symbol">...</span>} |
| 29 | + <span class="tsd-kind-parameter">{item.name}</span> |
| 30 | + {": "} |
| 31 | + {context.type(item.type)} |
| 32 | + {item.defaultValue != null && ( |
| 33 | + <span class="tsd-signature-symbol"> |
| 34 | + {" = "} |
| 35 | + {item.defaultValue} |
| 36 | + </span> |
| 37 | + )} |
| 38 | + </h5> |
| 39 | + {context.comment(item)} |
| 40 | + {item.type instanceof ReflectionType && context.parameter(item.type.declaration)} |
| 41 | + </li> |
| 42 | + ))} |
| 43 | + </ul> |
| 44 | + </div> |
| 45 | + )} |
| 46 | + {props.type && ( |
| 47 | + <> |
| 48 | + <h4 class="tsd-returns-title"> |
| 49 | + {"Returns "} |
| 50 | + {context.type(props.type)} |
| 51 | + </h4> |
| 52 | + {returnsTag && <Raw html={context.markdown(returnsTag.content)} />} |
| 53 | + {props.type instanceof ReflectionType && context.parameter(props.type.declaration)} |
| 54 | + </> |
| 55 | + )} |
| 56 | + {!hideSources && context.memberSources(props)} |
| 57 | + </> |
| 58 | + ); |
| 59 | +} |
0 commit comments