From 5ce0bef7a0a5aa5f6dfec5a6b61739bb17b4914a Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Thu, 21 Oct 2021 14:29:21 +0200 Subject: [PATCH] Moved the function to a better place --- .../default/partials/member.declaration.tsx | 5 ++--- .../partials/member.signature.title.tsx | 22 +++---------------- src/lib/output/themes/lib.tsx | 20 +++++++++++++++++ 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/lib/output/themes/default/partials/member.declaration.tsx b/src/lib/output/themes/default/partials/member.declaration.tsx index 5a283aada..90c22c7ec 100644 --- a/src/lib/output/themes/default/partials/member.declaration.tsx +++ b/src/lib/output/themes/default/partials/member.declaration.tsx @@ -1,14 +1,13 @@ import { DeclarationReflection, ReflectionType } from "../../../../models"; import { JSX } from "../../../../utils"; -import { wbr } from "../../lib"; +import { renderTypeParametersSignature, wbr } from "../../lib"; import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; -import { typeParameterSignatureList } from "./member.signature.title"; export const memberDeclaration = (context: DefaultThemeRenderContext, props: DeclarationReflection) => ( <>
{wbr(props.name)} - {typeParameterSignatureList(props.typeParameters)} + {renderTypeParametersSignature(props.typeParameters)} {props.type && ( <> {!!props.flags.isOptional && "?"}:{" "} diff --git a/src/lib/output/themes/default/partials/member.signature.title.tsx b/src/lib/output/themes/default/partials/member.signature.title.tsx index db4d826c8..05200e891 100644 --- a/src/lib/output/themes/default/partials/member.signature.title.tsx +++ b/src/lib/output/themes/default/partials/member.signature.title.tsx @@ -1,23 +1,7 @@ -import { join, wbr } from "../../lib"; +import { join, renderTypeParametersSignature, wbr } from "../../lib"; import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext"; import { JSX } from "../../../../utils"; -import type { SignatureReflection, TypeParameterReflection } from "../../../../models"; - -export const typeParameterSignatureList = (typeParameters: readonly TypeParameterReflection[] | undefined): JSX.Element => ( - <> - {!!typeParameters && typeParameters.length > 0 && ( - <> - {"<"} - {join({", "}, typeParameters, (item) => ( - - {item.name} - - ))} - {">"} - - )} - -); +import type { SignatureReflection } from "../../../../models"; export const memberSignatureTitle = ( context: DefaultThemeRenderContext, @@ -37,7 +21,7 @@ export const memberSignatureTitle = ( )} )} - {typeParameterSignatureList(props.typeParameters)} + {renderTypeParametersSignature(props.typeParameters)} ( {join(", ", props.parameters ?? [], (item) => ( <> diff --git a/src/lib/output/themes/lib.tsx b/src/lib/output/themes/lib.tsx index 7c31fc3d3..1321a2c26 100644 --- a/src/lib/output/themes/lib.tsx +++ b/src/lib/output/themes/lib.tsx @@ -78,3 +78,23 @@ export function hasTypeParameters( } return false; } + +export function renderTypeParametersSignature( + typeParameters: readonly TypeParameterReflection[] | undefined +): JSX.Element { + return ( + <> + {!!typeParameters && typeParameters.length > 0 && ( + <> + {"<"} + {join({", "}, typeParameters, (item) => ( + + {item.name} + + ))} + {">"} + + )} + + ); +}