Skip to content

Commit 734a3c0

Browse files
committed
Use parentContainer to include the class name in the default constructor summary
1 parent d06c5d4 commit 734a3c0

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

‎libraries/api-extractor/src/definitions/ApiMethod.ts‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { ApiItemKind, IApiItemOptions } from './ApiItem';
33
import ApiMember from './ApiMember';
44
import ApiParameter from './ApiParameter';
55
import TypeScriptHelpers from '../TypeScriptHelpers';
6-
import { ITextElement } from '../IDocElement';
6+
import { ITextElement, ICodeLinkElement } from '../IDocElement';
7+
import ApiDefinitionReference, { IScopedPackageName } from '../ApiDefinitionReference';
78

89
/**
910
* This class is part of the ApiItem abstract syntax tree. It represents functions that are members of
@@ -71,7 +72,24 @@ export default class ApiMethod extends ApiMember {
7172
if (this.documentation.summary.length === 0) {
7273
this.documentation.summary.push({
7374
kind: 'textDocElement',
74-
value: 'Constructs a new instance of the class'
75+
value: 'Constructs a new instance of the '
76+
} as ITextElement);
77+
78+
const scopedPackageName: IScopedPackageName = ApiDefinitionReference
79+
.parseScopedPackageName(this.extractor.package.name);
80+
81+
this.documentation.summary.push({
82+
kind: 'linkDocElement',
83+
referenceType: 'code',
84+
scopeName: scopedPackageName.scope,
85+
packageName: scopedPackageName.package,
86+
exportName: this.parentContainer.name,
87+
value: this.parentContainer.name
88+
} as ICodeLinkElement);
89+
90+
this.documentation.summary.push({
91+
kind: 'textDocElement',
92+
value: ' class'
7593
} as ITextElement);
7694
}
7795
this.needsDocumentation = false;

‎libraries/api-extractor/testInputs/example2/example2-output.json‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,19 @@
158158
"summary": [
159159
{
160160
"kind": "textDocElement",
161-
"value": "Constructs a new instance of the class"
161+
"value": "Constructs a new instance of the "
162+
},
163+
{
164+
"kind": "linkDocElement",
165+
"referenceType": "code",
166+
"scopeName": "",
167+
"packageName": "example2",
168+
"exportName": "MyDocumentedClass",
169+
"value": "MyDocumentedClass"
170+
},
171+
{
172+
"kind": "textDocElement",
173+
"value": " class"
162174
}
163175
],
164176
"remarks": []

0 commit comments

Comments
 (0)