Skip to content

Commit

Permalink
Moved the function to a better place
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Oct 21, 2021
1 parent 1ed18d4 commit 5ce0bef
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
5 changes: 2 additions & 3 deletions src/lib/output/themes/default/partials/member.declaration.tsx
Original file line number Diff line number Diff line change
@@ -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) => (
<>
<div class="tsd-signature tsd-kind-icon">
{wbr(props.name)}
{typeParameterSignatureList(props.typeParameters)}
{renderTypeParametersSignature(props.typeParameters)}
{props.type && (
<>
<span class="tsd-signature-symbol">{!!props.flags.isOptional && "?"}:</span>{" "}
Expand Down
22 changes: 3 additions & 19 deletions src/lib/output/themes/default/partials/member.signature.title.tsx
Original file line number Diff line number Diff line change
@@ -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 && (
<>
<span class="tsd-signature-symbol">{"<"}</span>
{join(<span class="tsd-signature-symbol">{", "}</span>, typeParameters, (item) => (
<span class="tsd-signature-type" data-tsd-kind={item.kindString}>
{item.name}
</span>
))}
<span class="tsd-signature-symbol">{">"}</span>
</>
)}
</>
);
import type { SignatureReflection } from "../../../../models";

export const memberSignatureTitle = (
context: DefaultThemeRenderContext,
Expand All @@ -37,7 +21,7 @@ export const memberSignatureTitle = (
)}
</>
)}
{typeParameterSignatureList(props.typeParameters)}
{renderTypeParametersSignature(props.typeParameters)}
<span class="tsd-signature-symbol">(</span>
{join(", ", props.parameters ?? [], (item) => (
<>
Expand Down
20 changes: 20 additions & 0 deletions src/lib/output/themes/lib.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,23 @@ export function hasTypeParameters(
}
return false;
}

export function renderTypeParametersSignature(
typeParameters: readonly TypeParameterReflection[] | undefined
): JSX.Element {
return (
<>
{!!typeParameters && typeParameters.length > 0 && (
<>
<span class="tsd-signature-symbol">{"<"}</span>
{join(<span class="tsd-signature-symbol">{", "}</span>, typeParameters, (item) => (
<span class="tsd-signature-type" data-tsd-kind={item.kindString}>
{item.name}
</span>
))}
<span class="tsd-signature-symbol">{">"}</span>
</>
)}
</>
);
}

0 comments on commit 5ce0bef

Please sign in to comment.