11import { Context , Converter } from 'typedoc/dist/lib/converter' ;
2- import { DeclarationOption , ParameterType } from 'typedoc/dist/lib/utils/options/declaration' ;
3- import { BindOption } from 'typedoc/dist/lib/utils' ;
42import { ConverterComponent } from 'typedoc/dist/lib/converter/components' ;
53import KeyOfCommentResolver from './convert/keyof-comment-resolver' ;
64
7- export enum AddKeysTagOption {
8- off = 0 ,
9- add = 1 ,
10- update = 2 ,
11- }
12-
13- export const addKeysOptionMapping : { [ key : string ] : AddKeysTagOption } = {
14- off : AddKeysTagOption . off ,
15- add : AddKeysTagOption . add ,
16- update : AddKeysTagOption . update ,
17- } ;
18-
19- const keyofCommentsOption = {
20- name : 'keyofComments' ,
21- type : ParameterType . Map ,
22- help : 'Expands the values of the keyof operator and adds a tag, default is set to off' ,
23- defaultValue : AddKeysTagOption . off ,
24- map : addKeysOptionMapping ,
25- } as DeclarationOption ;
26-
275export class KeyOfPlugin extends ConverterComponent {
286 static options = [
29- keyofCommentsOption ,
307 ] ;
318
32- @BindOption ( keyofCommentsOption . name )
33- _mode ! : AddKeysTagOption ;
34-
359 protected initialize ( ) {
3610 this . listenTo ( this . owner , {
3711 [ Converter . EVENT_RESOLVE_BEGIN ] : this . onBeginResolve ,
@@ -40,14 +14,6 @@ export class KeyOfPlugin extends ConverterComponent {
4014
4115 private onBeginResolve ( context : Context ) {
4216 const resolver = KeyOfCommentResolver . instance ( ) ;
43- if ( this . _mode !== AddKeysTagOption . off ) {
44- const override = this . _mode === AddKeysTagOption . update ;
45-
46- Object . values ( context . project . reflections )
47- . filter ( item => resolver . shouldResolveKeys ( context . project , item ) )
48- . forEach ( item => resolver . resolveKeys ( context . project , item , override ) ) ;
49- }
50-
5117 Object . values ( context . project . reflections )
5218 . filter ( item => resolver . shouldInlineKeys ( context . project , item ) )
5319 . forEach ( item => resolver . inlineKeys ( context . project , item ) ) ;
0 commit comments