Skip to content

Commit 7c51a33

Browse files
committed
Workaround for incorrect IMarkupApiLink references being emitted for namespaced items
1 parent e5a7ac5 commit 7c51a33

1 file changed

Lines changed: 26 additions & 11 deletions

File tree

‎apps/api-extractor/src/ast/AstMethod.ts‎

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// See LICENSE in the project root for license information.
33

44
import * as ts from 'typescript';
5-
import { AstItemKind, IAstItemOptions } from './AstItem';
5+
import { AstItem, AstItemKind, IAstItemOptions } from './AstItem';
66
import { AstMember } from './AstMember';
77
import { AstParameter } from './AstParameter';
88
import { TypeScriptHelpers } from '../utils/TypeScriptHelpers';
@@ -65,23 +65,38 @@ export class AstMethod extends AstMember {
6565
// If this is a class constructor, and if the documentation summary was omitted, then
6666
// we fill in a default summary versus flagging it as "undocumented".
6767
// Generally class constructors have uninteresting documentation.
68-
if (this.kind === AstItemKind.Constructor) {
68+
if (this.kind === AstItemKind.Constructor && this.parentContainer) {
6969
if (this.documentation.summary.length === 0) {
7070
this.documentation.summary.push(
7171
...Markup.createTextElements('Constructs a new instance of the '));
7272

7373
const scopedPackageName: IScopedPackageName = ApiDefinitionReference
7474
.parseScopedPackageName(this.context.package.name);
7575

76-
this.documentation.summary.push(
77-
Markup.createApiLinkFromText(this.parentContainer!.name, {
78-
scopeName: scopedPackageName.scope,
79-
packageName: scopedPackageName.package,
80-
exportName: this.parentContainer!.name,
81-
memberName: ''
82-
}
83-
)
84-
);
76+
const parentParentContainer: AstItem | undefined = this.parentContainer.parentContainer;
77+
if (parentParentContainer && parentParentContainer.kind === AstItemKind.Namespace) {
78+
// This is a temporary workaround to support policies.namespaceSupport === permissive
79+
// until the new AstSymbolTable engine is wired up
80+
this.documentation.summary.push(
81+
Markup.createApiLinkFromText(this.parentContainer.name, {
82+
scopeName: scopedPackageName.scope,
83+
packageName: scopedPackageName.package,
84+
exportName: parentParentContainer.name,
85+
memberName: this.parentContainer.name
86+
}
87+
)
88+
);
89+
} else {
90+
this.documentation.summary.push(
91+
Markup.createApiLinkFromText(this.parentContainer.name, {
92+
scopeName: scopedPackageName.scope,
93+
packageName: scopedPackageName.package,
94+
exportName: this.parentContainer.name,
95+
memberName: ''
96+
}
97+
)
98+
);
99+
}
85100

86101
this.documentation.summary.push(...Markup.createTextElements(' class'));
87102
}

0 commit comments

Comments
 (0)