Skip to content

Commit 6d92e84

Browse files
committed
Render objects one level deep
Resolves #2276
1 parent c9dee38 commit 6d92e84

File tree

2 files changed

+49
-33
lines changed

2 files changed

+49
-33
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- TypeDoc's `--pretty` option now also controls whether generated HTML contains line breaks, #2287.
66
- Optimized icon caching to reduce file size in generated HTML documentation, #2287.
7+
- Render property description of "roughly top level" object types, #2276.
78
- Added `MarkdownEvent.INCLUDE` for plugins, #2284.
89

910
### Bug Fixes
Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,57 @@
1-
import { DeclarationReflection, ReflectionType } from "../../../../models";
1+
import type { DeclarationReflection, ReflectionType } from "../../../../models";
22
import { JSX } from "../../../../utils";
33
import { getKindClass, hasTypeParameters, renderTypeParametersSignature, wbr } from "../../lib";
44
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
55

6-
export const memberDeclaration = (context: DefaultThemeRenderContext, props: DeclarationReflection) => (
7-
<>
8-
<div class="tsd-signature">
9-
<span class={getKindClass(props)}>{wbr(props.name)}</span>
10-
{renderTypeParametersSignature(context, props.typeParameters)}
11-
{props.type && (
12-
<>
13-
<span class="tsd-signature-symbol">{!!props.flags.isOptional && "?"}:</span>{" "}
14-
{context.type(props.type)}
15-
</>
16-
)}
17-
{!!props.defaultValue && (
18-
<>
19-
<span class="tsd-signature-symbol">
20-
{" = "}
21-
{props.defaultValue}
22-
</span>
23-
</>
24-
)}
25-
</div>
26-
27-
{context.commentSummary(props)}
28-
29-
{hasTypeParameters(props) && context.typeParameters(props.typeParameters)}
30-
31-
{props.type instanceof ReflectionType && (
6+
export function memberDeclaration(context: DefaultThemeRenderContext, props: DeclarationReflection) {
7+
function renderTypeDeclaration(type: ReflectionType) {
8+
return (
329
<div class="tsd-type-declaration">
3310
<h4>Type declaration</h4>
34-
{context.parameter(props.type.declaration)}
11+
{context.parameter(type.declaration)}
3512
</div>
36-
)}
13+
);
14+
}
3715

38-
{context.commentTags(props)}
16+
const visitor = { reflection: renderTypeDeclaration };
3917

40-
{context.memberSources(props)}
41-
</>
42-
);
18+
return (
19+
<>
20+
<div class="tsd-signature">
21+
<span class={getKindClass(props)}>{wbr(props.name)}</span>
22+
{renderTypeParametersSignature(context, props.typeParameters)}
23+
{props.type && (
24+
<>
25+
<span class="tsd-signature-symbol">{!!props.flags.isOptional && "?"}:</span>{" "}
26+
{context.type(props.type)}
27+
</>
28+
)}
29+
{!!props.defaultValue && (
30+
<>
31+
<span class="tsd-signature-symbol">
32+
{" = "}
33+
{props.defaultValue}
34+
</span>
35+
</>
36+
)}
37+
</div>
38+
39+
{context.commentSummary(props)}
40+
41+
{hasTypeParameters(props) && context.typeParameters(props.typeParameters)}
42+
43+
{props.type?.visit<JSX.Children>({
44+
reflection: renderTypeDeclaration,
45+
array: (arr) => arr.elementType.visit(visitor),
46+
intersection: (int) => int.types.map((t) => t.visit(visitor)),
47+
union: (union) => union.types.map((t) => t.visit(visitor)),
48+
reference: (ref) => ref.typeArguments?.map((t) => t.visit(visitor)),
49+
tuple: (ref) => ref.elements.map((t) => t.visit(visitor)),
50+
})}
51+
52+
{context.commentTags(props)}
53+
54+
{context.memberSources(props)}
55+
</>
56+
);
57+
}

0 commit comments

Comments
 (0)