File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,6 @@ let functionsByTypeByCategory: FunctionsByTypeByCategory = {
165165
166166for ( let func of functionsCollection ) {
167167 let folder = path . basename ( path . dirname ( func . filePath || '' ) ) ;
168- folder = folder . replace ( / _ / g, ' ' ) ;
169168
170169 if ( ! functionsByCategory [ folder ] ) {
171170 functionsByCategory [ folder ] = [ ] ;
Original file line number Diff line number Diff line change @@ -47,14 +47,22 @@ const titleCase = (str: string) =>
4747 str . charAt ( 0 ) . toUpperCase ( ) + str . slice ( 1 ) . toLowerCase ( ) ;
4848
4949const makeTitle = ( subType : string , category : string , type : string ) : string => {
50- const isUpperCase = category === category . toUpperCase ( ) ;
51- const categoryPart = isUpperCase ? category : titleCase ( category ) ;
52- const typePart = titleCase ( type ) ;
50+ const displayName = ( name : string ) => name . replace ( / _ / g, ' ' ) ;
51+
52+ const smartTitleCase = ( str : string ) => {
53+ return str
54+ . split ( ' ' )
55+ . map ( word => ( / ^ [ A - Z 0 - 9 ] + $ / . test ( word ) ? word : word . charAt ( 0 ) . toUpperCase ( ) + word . slice ( 1 ) . toLowerCase ( ) ) )
56+ . join ( ' ' ) ;
57+ } ;
58+
59+ const categoryPart = smartTitleCase ( displayName ( category ) ) ;
60+ const typePart = smartTitleCase ( type ) ;
61+
5362 if ( subType === 'any' ) {
5463 return `${ categoryPart } ${ typePart } ` ;
5564 } else {
56- const isUpperCase2 = subType === subType . toUpperCase ( ) ;
57- const subTypePart = isUpperCase2 ? subType : titleCase ( subType ) ;
65+ const subTypePart = smartTitleCase ( displayName ( subType ) ) ;
5866 return `${ subTypePart } ${ categoryPart } ${ typePart } ` ;
5967 }
6068} ;
You can’t perform that action at this time.
0 commit comments