@@ -21,7 +21,8 @@ import AstNamespace from '../ast/AstNamespace';
2121import AstModuleVariable from '../ast/AstModuleVariable' ;
2222import AstMethod from '../ast/AstMethod' ;
2323import { ReleaseTag } from '../aedoc/ReleaseTag' ;
24- import { IApiReturnValue , IApiParameter } from '../api/ApiItem' ;
24+ import { IAedocParameter } from '../aedoc/ApiDocumentation' ;
25+ import { IApiReturnValue , IApiParameter , IApiNameMap } from '../api/ApiItem' ;
2526import ApiJsonFile from '../api/ApiJsonFile' ;
2627
2728/**
@@ -168,9 +169,6 @@ export default class ApiJsonGenerator extends AstItemVisitor {
168169 return ;
169170 }
170171
171- for ( const param of astFunction . params ) {
172- this . visitApiParam ( param , astFunction . documentation . parameters [ param . name ] ) ;
173- }
174172 const returnValueNode : IApiReturnValue = {
175173 type : astFunction . returnType ,
176174 description : astFunction . documentation . returnsMessage
@@ -179,7 +177,7 @@ export default class ApiJsonGenerator extends AstItemVisitor {
179177 const newNode : Object = {
180178 kind : ApiJsonFile . convertKindToJson ( astFunction . kind ) ,
181179 returnValue : returnValueNode ,
182- parameters : astFunction . documentation . parameters ,
180+ parameters : this . _createParameters ( astFunction ) ,
183181 deprecatedMessage : astFunction . inheritedDeprecatedMessage || [ ] ,
184182 summary : astFunction . documentation . summary || [ ] ,
185183 remarks : astFunction . documentation . remarks || [ ] ,
@@ -278,16 +276,12 @@ export default class ApiJsonGenerator extends AstItemVisitor {
278276 return ;
279277 }
280278
281- for ( const param of astMethod . params ) {
282- this . visitApiParam ( param , astMethod . documentation . parameters [ param . name ] ) ;
283- }
284-
285279 let newNode : Object ;
286280 if ( astMethod . name === '__constructor' ) {
287281 newNode = {
288282 kind : ApiJsonFile . convertKindToJson ( AstItemKind . Constructor ) ,
289283 signature : astMethod . getDeclarationLine ( ) ,
290- parameters : astMethod . documentation . parameters ,
284+ parameters : this . _createParameters ( astMethod ) ,
291285 deprecatedMessage : astMethod . inheritedDeprecatedMessage || [ ] ,
292286 summary : astMethod . documentation . summary || [ ] ,
293287 remarks : astMethod . documentation . remarks || [ ]
@@ -305,7 +299,7 @@ export default class ApiJsonGenerator extends AstItemVisitor {
305299 isOptional : ! ! astMethod . isOptional ,
306300 isStatic : ! ! astMethod . isStatic ,
307301 returnValue : returnValueNode ,
308- parameters : astMethod . documentation . parameters ,
302+ parameters : this . _createParameters ( astMethod ) ,
309303 deprecatedMessage : astMethod . inheritedDeprecatedMessage || [ ] ,
310304 summary : astMethod . documentation . summary || [ ] ,
311305 remarks : astMethod . documentation . remarks || [ ] ,
@@ -316,15 +310,31 @@ export default class ApiJsonGenerator extends AstItemVisitor {
316310 refObject [ astMethod . name ] = newNode ;
317311 }
318312
319- protected visitApiParam ( astParam : AstParameter , refObject ?: Object ) : void {
320- if ( ! astParam . supportedName ) {
321- return ;
322- }
313+ private _createParameters ( astFunction : AstMethod | AstFunction ) : IApiNameMap < IApiParameter > {
314+ const result : IApiNameMap < IApiParameter > = { } ;
315+
316+ for ( const astParameter of astFunction . params ) {
317+ if ( ! astParameter . supportedName ) {
318+ continue ; // skip parameter names with unusual characters
319+ }
323320
324- if ( refObject ) {
325- ( refObject as IApiParameter ) . isOptional = astParam . isOptional ;
326- ( refObject as IApiParameter ) . isSpread = astParam . isSpread ;
327- ( refObject as IApiParameter ) . type = astParam . type ;
321+ const apiParameter : IApiParameter = {
322+ name : astParameter . name ,
323+ description : [ ] ,
324+ isOptional : astParameter . isOptional ,
325+ isSpread : astParameter . isSpread ,
326+ type : astParameter . type || ''
327+ } ;
328+
329+ const aedocParameter : IAedocParameter = astFunction . documentation . parameters [ astParameter . name ] ;
330+ if ( aedocParameter ) {
331+ apiParameter . description = aedocParameter . description ;
332+ }
333+
334+ result [ astParameter . name ] = apiParameter ;
328335 }
336+
337+ return result ;
329338 }
339+
330340}
0 commit comments