|
2 | 2 | // See LICENSE in the project root for license information. |
3 | 3 |
|
4 | 4 | import * as ts from 'typescript'; |
5 | | -import { AstItemKind, IAstItemOptions } from './AstItem'; |
| 5 | +import { AstItem, AstItemKind, IAstItemOptions } from './AstItem'; |
6 | 6 | import { AstMember } from './AstMember'; |
7 | 7 | import { AstParameter } from './AstParameter'; |
8 | 8 | import { TypeScriptHelpers } from '../utils/TypeScriptHelpers'; |
@@ -36,7 +36,7 @@ export class AstMethod extends AstMember { |
36 | 36 | if (methodDeclaration.parameters) { |
37 | 37 | this.params = []; |
38 | 38 | for (const param of methodDeclaration.parameters) { |
39 | | - const declarationSymbol: ts.Symbol = TypeScriptHelpers.tryGetSymbolForDeclaration(param); |
| 39 | + const declarationSymbol: ts.Symbol = TypeScriptHelpers.getSymbolForDeclaration(param); |
40 | 40 | const astParameter: AstParameter = new AstParameter({ |
41 | 41 | context: this.context, |
42 | 42 | declaration: param, |
@@ -65,23 +65,38 @@ export class AstMethod extends AstMember { |
65 | 65 | // If this is a class constructor, and if the documentation summary was omitted, then |
66 | 66 | // we fill in a default summary versus flagging it as "undocumented". |
67 | 67 | // Generally class constructors have uninteresting documentation. |
68 | | - if (this.kind === AstItemKind.Constructor) { |
| 68 | + if (this.kind === AstItemKind.Constructor && this.parentContainer) { |
69 | 69 | if (this.documentation.summary.length === 0) { |
70 | 70 | this.documentation.summary.push( |
71 | 71 | ...Markup.createTextElements('Constructs a new instance of the ')); |
72 | 72 |
|
73 | 73 | const scopedPackageName: IScopedPackageName = ApiDefinitionReference |
74 | 74 | .parseScopedPackageName(this.context.package.name); |
75 | 75 |
|
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 | + } |
85 | 100 |
|
86 | 101 | this.documentation.summary.push(...Markup.createTextElements(' class')); |
87 | 102 | } |
|
0 commit comments