11// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22// See LICENSE in the project root for license information.
33
4- import * as colors from 'colors' ;
54import * as path from 'path' ;
65
76import {
@@ -13,7 +12,6 @@ import {
1312 DocSection ,
1413 DocPlainText ,
1514 DocLinkTag ,
16- DocNode ,
1715 TSDocConfiguration ,
1816 StringBuilder ,
1917 DocNodeKind ,
@@ -34,7 +32,8 @@ import {
3432 ApiDeclarationMixin ,
3533 ApiStaticMixin ,
3634 ApiResultTypeMixin ,
37- ApiPropertyItem
35+ ApiPropertyItem ,
36+ ApiFunctionLikeMixin
3837} from '@microsoft/api-extractor' ;
3938
4039import { MarkdownRenderer } from '../utils/MarkdownRenderer' ;
@@ -141,6 +140,7 @@ export class MarkdownDocumenter {
141140 break ;
142141 case ApiItemKind . Method :
143142 case ApiItemKind . MethodSignature :
143+ this . _writeFunctionLikeTables ( output , apiItem as ApiFunctionLikeMixin ) ;
144144 break ;
145145 case ApiItemKind . Namespace :
146146 break ;
@@ -411,6 +411,71 @@ export class MarkdownDocumenter {
411411 }
412412 }
413413
414+ /**
415+ * GENERATE PAGE: FUNCTION-LIKE
416+ */
417+ private _writeFunctionLikeTables ( output : DocSection , apiFunctionLike : ApiFunctionLikeMixin ) : void {
418+ const configuration : TSDocConfiguration = this . _tsdocConfiguration ;
419+
420+ if ( apiFunctionLike . name === 'example' ) {
421+ debugger ;
422+ }
423+
424+ const parametersTable : DocTable = new DocTable ( { configuration,
425+ headerTitles : [ 'Parameter' , 'Type' , 'Description' ]
426+ } ) ;
427+
428+ for ( const apiParameter of apiFunctionLike . parameters ) {
429+ const parameterDescription : DocSection = new DocSection ( { configuration } ) ;
430+ if ( apiParameter . tsdocParamBlock ) {
431+ this . _appendSection ( parameterDescription , apiParameter . tsdocParamBlock . content ) ;
432+ }
433+
434+ parametersTable . addRow (
435+ new DocTableRow ( { configuration } , [
436+ this . _createTitleCell ( apiParameter ) ,
437+ new DocTableCell ( { configuration} , [
438+ new DocParagraph ( { configuration } , [
439+ new DocCodeSpan ( { configuration, code : apiParameter . resultTypeSignature } )
440+ ] )
441+ ] ) ,
442+ new DocTableCell ( { configuration} , parameterDescription . nodes )
443+ ] )
444+ ) ;
445+ }
446+
447+ if ( parametersTable . rows . length > 0 ) {
448+ output . appendNode ( new DocHeading ( { configuration : this . _tsdocConfiguration , title : 'Parameters' } ) ) ;
449+ output . appendNode ( parametersTable ) ;
450+ }
451+
452+ if ( ApiResultTypeMixin . isBaseClassOf ( apiFunctionLike ) ) {
453+
454+ output . appendNode (
455+ new DocParagraph ( { configuration } , [
456+ new DocEmphasisSpan ( { configuration, bold : true } , [
457+ new DocPlainText ( { configuration, text : 'Returns:' } )
458+ ] )
459+ ] )
460+ ) ;
461+
462+ output . appendNode (
463+ new DocParagraph ( { configuration } , [
464+ new DocCodeSpan ( { configuration, code : apiFunctionLike . resultTypeSignature } )
465+ ] )
466+ ) ;
467+
468+ if ( apiFunctionLike instanceof ApiDocumentedItem ) {
469+ if ( apiFunctionLike . tsdocComment ) {
470+ if ( apiFunctionLike . tsdocComment . returnsBlock ) {
471+ this . _appendSection ( output , apiFunctionLike . tsdocComment . returnsBlock . content ) ;
472+ }
473+ }
474+ }
475+
476+ }
477+ }
478+
414479 private _createTitleCell ( apiItem : ApiItem ) : DocTableCell {
415480 const configuration : TSDocConfiguration = this . _tsdocConfiguration ;
416481
0 commit comments