Skip to content

Commit e9c3181

Browse files
authored
Remove default template headers of Hierarchy and Type Parameters from DefaultThemeRenderContext when overridden. (#2038)
* Remove default reflection headers of Hierarchy and Type Parameters from DefaultThemeRenderContext when overridden. * Refactor Hierarchy and TypeParameters sections.
1 parent 08759bf commit e9c3181

File tree

3 files changed

+47
-44
lines changed

3 files changed

+47
-44
lines changed

src/lib/output/themes/default/partials/hierarchy.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
22
import { JSX } from "../../../../utils";
33
import type { DeclarationHierarchy } from "../../../../models";
44

5-
export const hierarchy = (context: DefaultThemeRenderContext, props: DeclarationHierarchy) => (
6-
<ul class="tsd-hierarchy">
7-
{props.types.map((item, i, l) => (
8-
<li>
9-
{props.isTarget ? <span class="target">{item.toString()}</span> : context.type(item)}
10-
{i === l.length - 1 && !!props.next && context.hierarchy(props.next)}
11-
</li>
12-
))}
13-
</ul>
5+
export const hierarchy = (context: DefaultThemeRenderContext, props: DeclarationHierarchy | undefined) => (
6+
<>
7+
{!!props && (
8+
<section class="tsd-panel tsd-hierarchy">
9+
<h4>Hierarchy</h4>
10+
<ul class="tsd-hierarchy">
11+
{props.types.map((item, i, l) => (
12+
<li>
13+
{props.isTarget ? <span class="target">{item.toString()}</span> : context.type(item)}
14+
{i === l.length - 1 && !!props.next && context.hierarchy(props.next)}
15+
</li>
16+
))}
17+
</ul>
18+
</section>
19+
)}
20+
</>
1421
);

src/lib/output/themes/default/partials/typeParameters.tsx

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,33 @@ import { JSX } from "../../../../utils";
44

55
export function typeParameters(context: DefaultThemeRenderContext, typeParameters: TypeParameterReflection[]) {
66
return (
7-
<ul class="tsd-type-parameters">
8-
{typeParameters?.map((item) => (
9-
<li>
10-
<h4>
11-
{item.varianceModifier ? `${item.varianceModifier} ` : ""}
12-
{item.name}
13-
{!!item.type && (
14-
<>
15-
<span class="tsd-signature-symbol"> extends </span>
16-
{context.type(item.type)}
17-
</>
18-
)}
19-
{!!item.default && (
20-
<>
21-
{" = "}
22-
{context.type(item.default)}
23-
</>
24-
)}
25-
</h4>
26-
{context.comment(item)}
27-
</li>
28-
))}
29-
</ul>
7+
<>
8+
<section class="tsd-panel tsd-type-parameters">
9+
<h4>Type Parameters</h4>
10+
<ul class="tsd-type-parameters">
11+
{typeParameters?.map((item) => (
12+
<li>
13+
<h4>
14+
{item.varianceModifier ? `${item.varianceModifier} ` : ""}
15+
{item.name}
16+
{!!item.type && (
17+
<>
18+
<span class="tsd-signature-symbol"> extends </span>
19+
{context.type(item.type)}
20+
</>
21+
)}
22+
{!!item.default && (
23+
<>
24+
{" = "}
25+
{context.type(item.default)}
26+
</>
27+
)}
28+
</h4>
29+
{context.comment(item)}
30+
</li>
31+
))}
32+
</ul>
33+
</section>
34+
</>
3035
);
3136
}

src/lib/output/themes/default/templates/reflection.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,11 @@ export function reflectionTemplate(context: DefaultThemeRenderContext, props: Pa
1616
<section class="tsd-panel tsd-comment">{context.comment(props.model)}</section>
1717
)}
1818

19-
{hasTypeParameters(props.model) && (
20-
<section class="tsd-panel tsd-type-parameters">
21-
<h4>Type Parameters</h4>
22-
{context.typeParameters(props.model.typeParameters)}
23-
</section>
24-
)}
19+
{hasTypeParameters(props.model) && <> {context.typeParameters(props.model.typeParameters)} </>}
2520
{props.model instanceof DeclarationReflection && (
2621
<>
27-
{!!props.model.typeHierarchy && (
28-
<section class="tsd-panel tsd-hierarchy">
29-
<h4>Hierarchy</h4>
30-
{context.hierarchy(props.model.typeHierarchy)}
31-
</section>
32-
)}
22+
{context.hierarchy(props.model.typeHierarchy)}
23+
3324
{!!props.model.implementedTypes && (
3425
<section class="tsd-panel">
3526
<h4>Implements</h4>

0 commit comments

Comments
 (0)