import { Contracts } from "ts-extractor" ; import { MarkdownBuilder } from "@simplrjs/markdown" ; import { GeneratorHelpers } from "../generator-helpers" ; import { SupportedApiItemKindType , PluginOptions , PluginResult } from "../contracts/plugin" ; import { ContainerPlugin , ContainerMembersKindsGroup } from "../abstractions/container-plugin" ; import { ApiSourceFile } from "../api-items/definitions/api-source-file" ; export class ApiSourceFilePlugin extends ContainerPlugin < Contracts . ApiSourceFileDto > { public SupportedApiDefinitionKind ( ) { return [ GeneratorHelpers . ApiDefinitionKind . SourceFile ] ; } public static readonly MemberKindsList : ContainerMembersKindsGroup [ ] = [ { Heading : "Functions" , Kinds : [ GeneratorHelpers . ApiDefinitionKind . Function ] } , { Heading : "Interfaces" , Kinds : [ GeneratorHelpers . ApiDefinitionKind . Interface ] } , { Heading : "Types" , Kinds : [ GeneratorHelpers . ApiDefinitionKind . TypeAlias ] } , { Heading : "Enums" , Kinds : [ GeneratorHelpers . ApiDefinitionKind . Enum ] } , { Heading : "Classes" , Kinds : [ GeneratorHelpers . ApiDefinitionKind . Class ] } , { Heading : "Namespaces" , Kinds : [ GeneratorHelpers . ApiDefinitionKind . Namespace , GeneratorHelpers . ApiDefinitionKind . ImportNamespace ] } , { Heading : "Variables" , Kinds : [ GeneratorHelpers . ApiDefinitionKind . Variable ] } , { Heading : "Other" , Kinds : [ GeneratorHelpers . ApiDefinitionKind . Any ] } ] ; public Render ( options , apiItem ) { const serializedApiItem = new ApiSourceFile ( options . ExtractedData , apiItem , options . Reference ) ; const heading = serializedApiItem . ToHeadingText ( ) ; const pluginResult = { ... GeneratorHelpers . GetDefaultPluginResultData ( ) , ApiItem : apiItem , Reference : options . Reference , UsedReferences : [ options . Reference . Id ] } ; pluginResult . Result = new MarkdownBuilder ( ) . Header ( heading , 1 ) . EmptyLine ( ) . Text ( this . RenderApiItemMetadata ( apiItem ) ) . GetOutput ( ) ; const membersResult = this . RenderMemberGroups ( options , ApiSourceFilePlugin . MemberKindsList , serializedApiItem . Members ) ; const membersHeadings = membersResult . Headings ; membersResult . Headings = [ ] ; pluginResult . Headings . push ( { Heading : heading , ApiItemId : options . Reference . Id , Members : membersHeadings , } ) ; GeneratorHelpers . MergePluginResultData ( pluginResult , membersResult ) ; return pluginResult ; } }