Skip to content

Commit

Permalink
Merge pull request #1754 from RunDevelopment/issue1746
Browse files Browse the repository at this point in the history
Highlight type parameters consistently
  • Loading branch information
Gerrit0 authored Oct 22, 2021
2 parents ef0904c + 5ce0bef commit 89537bc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
10 changes: 2 additions & 8 deletions src/lib/output/themes/default/partials/member.declaration.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { DeclarationReflection, ReflectionType } from "../../../../models";
import { JSX } from "../../../../utils";
import { join, wbr } from "../../lib";
import { renderTypeParametersSignature, wbr } from "../../lib";
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";

export const memberDeclaration = (context: DefaultThemeRenderContext, props: DeclarationReflection) => (
<>
<div class="tsd-signature tsd-kind-icon">
{wbr(props.name)}
{!!props.typeParameters && (
<>
{"<"}
{join(", ", props.typeParameters, (item) => item.name)}
{">"}
</>
)}
{renderTypeParametersSignature(props.typeParameters)}
{props.type && (
<>
<span class="tsd-signature-symbol">{!!props.flags.isOptional && "?"}:</span>{" "}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join, wbr } from "../../lib";
import { join, renderTypeParametersSignature, wbr } from "../../lib";
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
import { JSX } from "../../../../utils";
import type { SignatureReflection } from "../../../../models";
Expand All @@ -21,13 +21,7 @@ export const memberSignatureTitle = (
)}
</>
)}
{!!props.typeParameters && (
<>
{"<"}
{join(", ", props.typeParameters, (item) => item.name)}
{">"}
</>
)}
{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 89537bc

Please sign in to comment.