|
1 | 1 | import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
|
2 | 2 | import {
|
| 3 | + DeclarationReflection, |
3 | 4 | LiteralType,
|
4 | 5 | ProjectReflection,
|
5 | 6 | ReferenceType,
|
@@ -66,6 +67,13 @@ function renderUniquePath(context: DefaultThemeRenderContext, reflection: Reflec
|
66 | 67 | </a>
|
67 | 68 | ));
|
68 | 69 | }
|
| 70 | +function includeIndentation(context: DefaultThemeRenderContext): JSX.Element { |
| 71 | + return context.getCurrentDepth() > 0 ? ( |
| 72 | + <span>{new Array(context.getCurrentDepth() * 4).fill("\u00A0").join("")}</span> |
| 73 | + ) : ( |
| 74 | + <></> |
| 75 | + ); |
| 76 | +} |
69 | 77 |
|
70 | 78 | // The type helper accepts an optional needsParens parameter that is checked
|
71 | 79 | // if an inner type may result in invalid output without them. For example:
|
@@ -277,8 +285,11 @@ const typeRenderers: {
|
277 | 285 | },
|
278 | 286 | reflection(context, type) {
|
279 | 287 | const members: JSX.Element[] = [];
|
| 288 | + const children: DeclarationReflection[] = type.declaration.children || []; |
| 289 | + |
| 290 | + if (children.length) context.incrementCurrentDepth(); |
280 | 291 |
|
281 |
| - for (const item of type.declaration.children || []) { |
| 292 | + for (const item of children) { |
282 | 293 | if (item.getSignature && item.setSignature) {
|
283 | 294 | members.push(
|
284 | 295 | <>
|
@@ -359,14 +370,24 @@ const typeRenderers: {
|
359 | 370 | }
|
360 | 371 |
|
361 | 372 | if (members.length) {
|
362 |
| - const membersWithSeparators = members.flatMap((m) => [m, <span class="tsd-signature-symbol">; </span>]); |
| 373 | + const membersWithSeparators = members.flatMap((m) => [ |
| 374 | + includeIndentation(context), |
| 375 | + m, |
| 376 | + <span class="tsd-signature-symbol">; </span>, |
| 377 | + <br></br>, |
| 378 | + ]); |
363 | 379 | membersWithSeparators.pop();
|
364 | 380 |
|
| 381 | + context.decrementCurrentDepth(); |
| 382 | + |
365 | 383 | return (
|
366 | 384 | <>
|
367 | 385 | <span class="tsd-signature-symbol">{"{"} </span>
|
| 386 | + <br></br> |
368 | 387 | {membersWithSeparators}
|
369 |
| - <span class="tsd-signature-symbol"> {"}"}</span> |
| 388 | + <br></br> |
| 389 | + {includeIndentation(context)} |
| 390 | + <span class="tsd-signature-symbol">{"}"}</span> |
370 | 391 | </>
|
371 | 392 | );
|
372 | 393 | }
|
|
0 commit comments