@@ -2,22 +2,7 @@ import { buildHierarchy } from './buildHierarchy.mjs';
22import { getRemarkRehype } from '../../../utils/remark.mjs' ;
33import { transformNodesToString } from '../../../utils/unist.mjs' ;
44import { parseList } from './parseList.mjs' ;
5-
6- const sectionTypePlurals = {
7- module : 'modules' ,
8- misc : 'miscs' ,
9- class : 'classes' ,
10- method : 'methods' ,
11- property : 'properties' ,
12- global : 'globals' ,
13- example : 'examples' ,
14- ctor : 'signatures' ,
15- classMethod : 'classMethods' ,
16- event : 'events' ,
17- var : 'vars' ,
18- } ;
19-
20- const unpromotedKeys = [ 'textRaw' , 'name' , 'type' , 'desc' , 'miscs' ] ;
5+ import { SECTION_TYPE_PLURALS , UNPROMOTED_KEYS } from '../constants.mjs' ;
216
227/**
238 * Converts a value to an array.
@@ -27,6 +12,9 @@ const unpromotedKeys = ['textRaw', 'name', 'type', 'desc', 'miscs'];
2712 */
2813const enforceArray = val => ( Array . isArray ( val ) ? val : [ val ] ) ;
2914
15+ /**
16+ *
17+ */
3018export const createSectionBuilder = ( ) => {
3119 const html = getRemarkRehype ( ) ;
3220
@@ -117,7 +105,7 @@ export const createSectionBuilder = () => {
117105 * @param {import('../types.d.ts').Section } parent - The parent section.
118106 */
119107 const addToParent = ( section , parent ) => {
120- const key = sectionTypePlurals [ section . type ] || 'miscs' ;
108+ const key = SECTION_TYPE_PLURALS [ section . type ] || 'miscs' ;
121109
122110 parent [ key ] ??= [ ] ;
123111 parent [ key ] . push ( section ) ;
@@ -133,7 +121,7 @@ export const createSectionBuilder = () => {
133121 if ( section . type === 'misc' && parent . type !== 'misc' ) {
134122 Object . entries ( section ) . forEach ( ( [ key , value ] ) => {
135123 // Only promote certain keys
136- if ( ! unpromotedKeys . includes ( key ) ) {
124+ if ( ! UNPROMOTED_KEYS . includes ( key ) ) {
137125 // Merge the section's properties into the parent section
138126 parent [ key ] = parent [ key ]
139127 ? // If the parent already has this key, concatenate the values
0 commit comments