import { Contracts } from "ts-extractor" ; import { MarkdownBuilder } from "@simplrjs/markdown" ; import { GeneratorHelpers } from "../generator-helpers" ; import { SupportedApiItemKindType , PluginResult , PluginOptions } from "../contracts/plugin" ; import { FunctionLikePlugin } from "../abstractions/function-like-plugin" ; import { ApiFunction } from "../api-items/definitions/api-function" ; export class ApiFunctionPlugin extends FunctionLikePlugin < Contracts . ApiFunctionDto > { public SupportedApiDefinitionKind ( ) { return [ GeneratorHelpers . ApiDefinitionKind . Function ] ; } public Render ( options , apiItem ) { const serializedApiItem = new ApiFunction ( options . ExtractedData , apiItem , options . Reference ) ; const heading = serializedApiItem . ToHeadingText ( ) ; const pluginResult = { ... GeneratorHelpers . GetDefaultPluginResultData ( ) , ApiItem : apiItem , Reference : options . Reference , Headings : [ { Heading : heading , ApiItemId : options . Reference . Id } ] , UsedReferences : [ options . Reference . Id ] } ; pluginResult . Result = new MarkdownBuilder ( ) . Header ( heading , 3 ) . EmptyLine ( ) . Text ( this . RenderApiItemMetadata ( apiItem ) ) . Code ( serializedApiItem . ToText ( ) , GeneratorHelpers . DEFAULT_CODE_OPTIONS ) . GetOutput ( ) ; const typeParametersResult = this . RenderTypeParameters ( options . ExtractedData , serializedApiItem . TypeParameters ) ; GeneratorHelpers . MergePluginResultData ( pluginResult , typeParametersResult ) ; const parametersResult = this . RenderParameters ( options . ExtractedData , serializedApiItem . Parameters ) ; GeneratorHelpers . MergePluginResultData ( pluginResult , parametersResult ) ; const returnTypeResult = this . RenderReturnType ( options . ExtractedData , serializedApiItem . ReturnType ) ; GeneratorHelpers . MergePluginResultData ( pluginResult , returnTypeResult ) ; return pluginResult ; } }