-
-
Notifications
You must be signed in to change notification settings - Fork 723
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge
@returns
and return type blocks in output
Resolves #2180
- Loading branch information
Showing
4 changed files
with
66 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 50 additions & 45 deletions
95
src/lib/output/themes/default/partials/member.signature.body.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,59 @@ | ||
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; | ||
import { JSX } from "../../../../utils"; | ||
import { JSX, Raw } from "../../../../utils"; | ||
import { ReflectionType, SignatureReflection } from "../../../../models"; | ||
import { hasTypeParameters, renderFlags } from "../../lib"; | ||
|
||
export const memberSignatureBody = ( | ||
export function memberSignatureBody( | ||
context: DefaultThemeRenderContext, | ||
props: SignatureReflection, | ||
{ hideSources = false }: { hideSources?: boolean } = {} | ||
) => ( | ||
<> | ||
{renderFlags(props.flags, props.comment)} | ||
{context.comment(props)} | ||
) { | ||
const returnsTag = props.comment?.getTag("@returns"); | ||
|
||
{hasTypeParameters(props) && context.typeParameters(props.typeParameters)} | ||
return ( | ||
<> | ||
{renderFlags(props.flags, props.comment)} | ||
{context.comment(props)} | ||
|
||
{props.parameters && props.parameters.length > 0 && ( | ||
<div class="tsd-parameters"> | ||
<h4 class="tsd-parameters-title">Parameters</h4> | ||
<ul class="tsd-parameter-list"> | ||
{props.parameters.map((item) => ( | ||
<li> | ||
<h5> | ||
{renderFlags(item.flags, item.comment)} | ||
{!!item.flags.isRest && <span class="tsd-signature-symbol">...</span>} | ||
<span class="tsd-kind-parameter">{item.name}</span> | ||
{": "} | ||
{context.type(item.type)} | ||
{item.defaultValue != null && ( | ||
<span class="tsd-signature-symbol"> | ||
{" = "} | ||
{item.defaultValue} | ||
</span> | ||
)} | ||
</h5> | ||
{context.comment(item)} | ||
{item.type instanceof ReflectionType && context.parameter(item.type.declaration)} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
)} | ||
{props.type && ( | ||
<> | ||
<h4 class="tsd-returns-title"> | ||
{"Returns "} | ||
{context.type(props.type)} | ||
</h4> | ||
{props.type instanceof ReflectionType && context.parameter(props.type.declaration)} | ||
</> | ||
)} | ||
{!hideSources && context.memberSources(props)} | ||
</> | ||
); | ||
{hasTypeParameters(props) && context.typeParameters(props.typeParameters)} | ||
|
||
{props.parameters && props.parameters.length > 0 && ( | ||
<div class="tsd-parameters"> | ||
<h4 class="tsd-parameters-title">Parameters</h4> | ||
<ul class="tsd-parameter-list"> | ||
{props.parameters.map((item) => ( | ||
<li> | ||
<h5> | ||
{renderFlags(item.flags, item.comment)} | ||
{!!item.flags.isRest && <span class="tsd-signature-symbol">...</span>} | ||
<span class="tsd-kind-parameter">{item.name}</span> | ||
{": "} | ||
{context.type(item.type)} | ||
{item.defaultValue != null && ( | ||
<span class="tsd-signature-symbol"> | ||
{" = "} | ||
{item.defaultValue} | ||
</span> | ||
)} | ||
</h5> | ||
{context.comment(item)} | ||
{item.type instanceof ReflectionType && context.parameter(item.type.declaration)} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
)} | ||
{props.type && ( | ||
<> | ||
<h4 class="tsd-returns-title"> | ||
{"Returns "} | ||
{context.type(props.type)} | ||
</h4> | ||
{returnsTag && <Raw html={context.markdown(returnsTag.content)} />} | ||
{props.type instanceof ReflectionType && context.parameter(props.type.declaration)} | ||
</> | ||
)} | ||
{!hideSources && context.memberSources(props)} | ||
</> | ||
); | ||
} |