Skip to content

Commit 767874a

Browse files
committed
Render constructors in their own "Constructors" section, rather than in the "Methods" section
1 parent 33a4bac commit 767874a

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

apps/api-documenter/src/documenters/MarkdownDocumenter.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class MarkdownDocumenter {
100100
break;
101101
case ApiItemKind.Constructor:
102102
case ApiItemKind.ConstructSignature:
103-
output.appendNode(new DocHeading({ configuration, title: `${scopedName} constructor` }));
103+
output.appendNode(new DocHeading({ configuration, title: scopedName }));
104104
break;
105105
case ApiItemKind.Method:
106106
case ApiItemKind.MethodSignature:
@@ -382,6 +382,10 @@ export class MarkdownDocumenter {
382382
headerTitles: [ 'Property', 'Modifiers', 'Type', 'Description' ]
383383
});
384384

385+
const constructorsTable: DocTable = new DocTable({ configuration,
386+
headerTitles: [ 'Constructor', 'Modifiers', 'Description' ]
387+
});
388+
385389
const propertiesTable: DocTable = new DocTable({ configuration,
386390
headerTitles: [ 'Property', 'Modifiers', 'Type', 'Description' ]
387391
});
@@ -393,7 +397,18 @@ export class MarkdownDocumenter {
393397
for (const apiMember of apiClass.members) {
394398

395399
switch (apiMember.kind) {
396-
case ApiItemKind.Constructor:
400+
case ApiItemKind.Constructor: {
401+
constructorsTable.addRow(
402+
new DocTableRow({ configuration }, [
403+
this._createTitleCell(apiMember),
404+
this._createModifiersCell(apiMember),
405+
this._createDescriptionCell(apiMember)
406+
])
407+
);
408+
409+
this._writeApiItemPage(apiMember);
410+
break;
411+
}
397412
case ApiItemKind.Method: {
398413
methodsTable.addRow(
399414
new DocTableRow({ configuration }, [
@@ -440,6 +455,11 @@ export class MarkdownDocumenter {
440455
output.appendNode(eventsTable);
441456
}
442457

458+
if (constructorsTable.rows.length > 0) {
459+
output.appendNode(new DocHeading({ configuration: this._tsdocConfiguration, title: 'Constructors' }));
460+
output.appendNode(constructorsTable);
461+
}
462+
443463
if (propertiesTable.rows.length > 0) {
444464
output.appendNode(new DocHeading({ configuration: this._tsdocConfiguration, title: 'Properties' }));
445465
output.appendNode(propertiesTable);
@@ -509,6 +529,7 @@ export class MarkdownDocumenter {
509529
for (const apiMember of apiClass.members) {
510530

511531
switch (apiMember.kind) {
532+
case ApiItemKind.ConstructSignature:
512533
case ApiItemKind.MethodSignature: {
513534
methodsTable.addRow(
514535
new DocTableRow({ configuration }, [

0 commit comments

Comments
 (0)