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 { ApiClass } from "../api-items/definitions/api-class" ; export class ApiClassPlugin extends ContainerPlugin < Contracts . ApiClassDto > { public SupportedApiDefinitionKind ( ) { return [ GeneratorHelpers . ApiDefinitionKind . Class ] ; } public static readonly MemberKindsList : ContainerMembersKindsGroup [ ] = [ { Heading : "Index" , Kinds : [ GeneratorHelpers . ApiDefinitionKind . Index ] } , { Heading : "Constructor" , Kinds : [ GeneratorHelpers . ApiDefinitionKind . ClassConstructor ] } , { Heading : "Methods" , Kinds : [ GeneratorHelpers . ApiDefinitionKind . ClassMethod ] } , { Heading : "Properties" , Kinds : [ GeneratorHelpers . ApiDefinitionKind . ClassProperty , GeneratorHelpers . ApiDefinitionKind . GetAccessor , GeneratorHelpers . ApiDefinitionKind . SetAccessor , ] } , { Heading : "Other" , Kinds : [ GeneratorHelpers . ApiDefinitionKind . Any ] } ] ; public Render ( options , apiItem ) { const serializedApiItem = new ApiClass ( 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 ) ) . Code ( serializedApiItem . ToText ( ) , GeneratorHelpers . DEFAULT_CODE_OPTIONS ) . GetOutput ( ) ; const typeParametersResult = this . RenderTypeParameters ( options . ExtractedData , serializedApiItem . TypeParameters ) ; GeneratorHelpers . MergePluginResultData ( pluginResult , typeParametersResult ) ; const membersResult = this . RenderMemberGroups ( options , ApiClassPlugin . 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 ; } }