Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove default template headers of Hierarchy and Type Parameters from DefaultThemeRenderContext when overridden. #2038

Merged
merged 3 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/lib/output/themes/default/partials/hierarchy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import { JSX } from "../../../../utils";
import type { DeclarationHierarchy } from "../../../../models";

export const hierarchy = (context: DefaultThemeRenderContext, props: DeclarationHierarchy) => (
<ul class="tsd-hierarchy">
{props.types.map((item, i, l) => (
<li>
{props.isTarget ? <span class="target">{item.toString()}</span> : context.type(item)}
{i === l.length - 1 && !!props.next && context.hierarchy(props.next)}
</li>
))}
</ul>
<>
<h4>Hierarchy</h4>
<ul class="tsd-hierarchy">
{props.types.map((item, i, l) => (
<li>
{props.isTarget ? <span class="target">{item.toString()}</span> : context.type(item)}
{i === l.length - 1 && !!props.next && context.hierarchy(props.next)}
</li>
))}
</ul>
</>
);
49 changes: 26 additions & 23 deletions src/lib/output/themes/default/partials/typeParameters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,31 @@ import { JSX } from "../../../../utils";

export function typeParameters(context: DefaultThemeRenderContext, typeParameters: TypeParameterReflection[]) {
return (
<ul class="tsd-type-parameters">
{typeParameters?.map((item) => (
<li>
<h4>
{item.varianceModifier ? `${item.varianceModifier} ` : ""}
{item.name}
{!!item.type && (
<>
<span class="tsd-signature-symbol"> extends </span>
{context.type(item.type)}
</>
)}
{!!item.default && (
<>
{" = "}
{context.type(item.default)}
</>
)}
</h4>
{context.comment(item)}
</li>
))}
</ul>
<>
<h4>Type Parameters</h4>
<ul class="tsd-type-parameters">
{typeParameters?.map((item) => (
<li>
<h4>
{item.varianceModifier ? `${item.varianceModifier} ` : ""}
{item.name}
{!!item.type && (
<>
<span class="tsd-signature-symbol"> extends </span>
{context.type(item.type)}
</>
)}
{!!item.default && (
<>
{" = "}
{context.type(item.default)}
</>
)}
</h4>
{context.comment(item)}
</li>
))}
</ul>
</>
);
}
2 changes: 0 additions & 2 deletions src/lib/output/themes/default/templates/reflection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ export function reflectionTemplate(context: DefaultThemeRenderContext, props: Pa

{hasTypeParameters(props.model) && (
<section class="tsd-panel tsd-type-parameters">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason the <section> (and maybe even the condition) didn't move into the helpers? Seems like you'd still have elements you don't want if modifying these helpers.

<h4>Type Parameters</h4>
{context.typeParameters(props.model.typeParameters)}
</section>
)}
{props.model instanceof DeclarationReflection && (
<>
{!!props.model.typeHierarchy && (
<section class="tsd-panel tsd-hierarchy">
<h4>Hierarchy</h4>
{context.hierarchy(props.model.typeHierarchy)}
</section>
)}
Expand Down