@@ -3,6 +3,7 @@ import { ApiItemKind, IApiItemOptions } from './ApiItem';
33import ApiMember from './ApiMember' ;
44import ApiParameter from './ApiParameter' ;
55import TypeScriptHelpers from '../TypeScriptHelpers' ;
6+ import { ITextElement } from '../IDocElement' ;
67
78/**
89 * This class is part of the ApiItem abstract syntax tree. It represents functions that are members of
@@ -12,8 +13,9 @@ import TypeScriptHelpers from '../TypeScriptHelpers';
1213 * @see ApiFunction for functions that are defined inside of a package
1314 */
1415export default class ApiMethod extends ApiMember {
15- public returnType : string ;
16- public params : ApiParameter [ ] ;
16+ public readonly returnType : string ;
17+ public readonly params : ApiParameter [ ] ;
18+ private readonly _isConstructor : boolean ;
1719
1820 constructor ( options : IApiItemOptions ) {
1921 super ( options ) ;
@@ -38,8 +40,11 @@ export default class ApiMethod extends ApiMember {
3840 }
3941 }
4042
43+ // tslint:disable-next-line:no-bitwise
44+ this . _isConstructor = ( options . declarationSymbol . flags & ts . SymbolFlags . Constructor ) !== 0 ;
45+
4146 // Return type
42- if ( ! ( this . name === '__constructor' ) ) {
47+ if ( ! this . isConstructor ) {
4348 if ( methodDeclaration . type ) {
4449 this . returnType = methodDeclaration . type . getText ( ) ;
4550 } else {
@@ -48,4 +53,28 @@ export default class ApiMethod extends ApiMember {
4853 }
4954 }
5055 }
56+
57+ /**
58+ * Returns true if this member represents a class constructor.
59+ */
60+ public get isConstructor ( ) : boolean {
61+ return this . _isConstructor ;
62+ }
63+
64+ protected onCompleteInitialization ( ) : void {
65+ super . onCompleteInitialization ( ) ;
66+
67+ // If this is a class constructor, and if the documentation summary was omitted, then
68+ // we fill in a default summary versus flagging it as "undocumented".
69+ // Generally class constructors have uninteresting documentation.
70+ if ( this . isConstructor ) {
71+ if ( this . documentation . summary . length === 0 ) {
72+ this . documentation . summary . push ( {
73+ kind : 'textDocElement' ,
74+ value : 'Constructs a new instance of the class'
75+ } as ITextElement ) ;
76+ }
77+ this . needsDocumentation = false ;
78+ }
79+ }
5180}
0 commit comments