import { ReflectionKind , DeclarationReflection , } from "typedoc/dist/lib/models/reflections/index" ; import { Component , ConverterComponent , } from "typedoc/dist/lib/converter/components" ; import { Converter } from "typedoc/dist/lib/converter/converter" ; import { Context } from "typedoc/dist/lib/converter/context" ; import { ALLOW_INHERIT_OPTIONS } from "./constants" ; @ Component ( { name : "filter-inherit" } ) export class FilterInheritPlugin extends ConverterComponent { private allowInheritedList : string [ ] ; private inheritedReflections : DeclarationReflection [ ] ; /**
     * Create a new FilterInheritPlugin instance.
     */ initialize ( ) { this . listenTo ( this . owner , Converter . EVENT_BEGIN , this . onBegin ) ; this . listenTo ( this . owner , Converter . EVENT_CREATE_DECLARATION , this . onDeclaration , - 100 ) ; this . listenTo ( this . owner , Converter . EVENT_RESOLVE_BEGIN , this . onBeginResolve ) ; } onBegin ( ) { const options = this . application . options . getRawValues ( ) ; this . allowInheritedList = options [ ALLOW_INHERIT_OPTIONS ] || [ ] ; this . inheritedReflections = [ ] ; } param context param reflection param node private onDeclaration ( context , reflection , node ? ) { if ( reflection . inheritedFrom && reflection . parent && reflection . parent . kindOf ( ReflectionKind . ClassOrInterface ) && ( ! reflection . overwrites || ( reflection . overwrites && reflection . overwrites !== reflection . inheritedFrom ) ) ) { this . inheritedReflections . push ( reflection ) ; } } param context private onBeginResolve ( context ) { this . inheritedReflections . forEach ( ( refletion ) => { const project = context . project ; const result = refletion . inheritedFrom ?. name . match ( /(\w+)\.(\w+)/ ) ; if ( ! result || ( result && ! this . allowInheritedList . includes ( result [ 1 ] ) ) ) { project . removeReflection ( refletion ) ; } } ) ; } }