Skip to content

Commit

Permalink
Render objects one level deep
Browse files Browse the repository at this point in the history
Resolves #2276
  • Loading branch information
Gerrit0 committed May 29, 2023
1 parent c9dee38 commit 6d92e84
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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

### Bug Fixes
Expand Down
81 changes: 48 additions & 33 deletions src/lib/output/themes/default/partials/member.declaration.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,57 @@
import { DeclarationReflection, ReflectionType } from "../../../../models";
import type { DeclarationReflection, ReflectionType } from "../../../../models";
import { JSX } from "../../../../utils";
import { getKindClass, hasTypeParameters, renderTypeParametersSignature, wbr } from "../../lib";
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";

export const memberDeclaration = (context: DefaultThemeRenderContext, props: DeclarationReflection) => (
<>
<div class="tsd-signature">
<span class={getKindClass(props)}>{wbr(props.name)}</span>
{renderTypeParametersSignature(context, props.typeParameters)}
{props.type && (
<>
<span class="tsd-signature-symbol">{!!props.flags.isOptional && "?"}:</span>{" "}
{context.type(props.type)}
</>
)}
{!!props.defaultValue && (
<>
<span class="tsd-signature-symbol">
{" = "}
{props.defaultValue}
</span>
</>
)}
</div>

{context.commentSummary(props)}

{hasTypeParameters(props) && context.typeParameters(props.typeParameters)}

{props.type instanceof ReflectionType && (
export function memberDeclaration(context: DefaultThemeRenderContext, props: DeclarationReflection) {
function renderTypeDeclaration(type: ReflectionType) {
return (
<div class="tsd-type-declaration">
<h4>Type declaration</h4>
{context.parameter(props.type.declaration)}
{context.parameter(type.declaration)}
</div>
)}
);
}

{context.commentTags(props)}
const visitor = { reflection: renderTypeDeclaration };

{context.memberSources(props)}
</>
);
return (
<>
<div class="tsd-signature">
<span class={getKindClass(props)}>{wbr(props.name)}</span>
{renderTypeParametersSignature(context, props.typeParameters)}
{props.type && (
<>
<span class="tsd-signature-symbol">{!!props.flags.isOptional && "?"}:</span>{" "}
{context.type(props.type)}
</>
)}
{!!props.defaultValue && (
<>
<span class="tsd-signature-symbol">
{" = "}
{props.defaultValue}
</span>
</>
)}
</div>

{context.commentSummary(props)}

{hasTypeParameters(props) && context.typeParameters(props.typeParameters)}

{props.type?.visit<JSX.Children>({
reflection: renderTypeDeclaration,
array: (arr) => arr.elementType.visit(visitor),
intersection: (int) => int.types.map((t) => t.visit(visitor)),
union: (union) => union.types.map((t) => t.visit(visitor)),
reference: (ref) => ref.typeArguments?.map((t) => t.visit(visitor)),
tuple: (ref) => ref.elements.map((t) => t.visit(visitor)),
})}

{context.commentTags(props)}

{context.memberSources(props)}
</>
);
}

0 comments on commit 6d92e84

Please sign in to comment.