Skip to content

Commit

Permalink
Remove default template headers of Hierarchy and Type Parameters from…
Browse files Browse the repository at this point in the history
… DefaultThemeRenderContext when overridden. (#2038)

* Remove default reflection headers of Hierarchy and Type Parameters from DefaultThemeRenderContext when overridden.
* Refactor Hierarchy and TypeParameters sections.
  • Loading branch information
kaphula committed Aug 26, 2022
1 parent 08759bf commit e9c3181
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 44 deletions.
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

0 comments on commit e9c3181

Please sign in to comment.