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 all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/lib/output/themes/default/partials/hierarchy.tsx
Expand Up @@ -2,13 +2,20 @@ import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
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>
export const hierarchy = (context: DefaultThemeRenderContext, props: DeclarationHierarchy | undefined) => (
<>
{!!props && (
<section class="tsd-panel tsd-hierarchy">
<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>
</section>
)}
</>
);
51 changes: 28 additions & 23 deletions src/lib/output/themes/default/partials/typeParameters.tsx
Expand Up @@ -4,28 +4,33 @@ 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>
<>
<section class="tsd-panel tsd-type-parameters">
<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>
</section>
</>
);
}
15 changes: 3 additions & 12 deletions src/lib/output/themes/default/templates/reflection.tsx
Expand Up @@ -16,20 +16,11 @@ export function reflectionTemplate(context: DefaultThemeRenderContext, props: Pa
<section class="tsd-panel tsd-comment">{context.comment(props.model)}</section>
)}

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

{!!props.model.implementedTypes && (
<section class="tsd-panel">
<h4>Implements</h4>
Expand Down