@@ -6,7 +6,9 @@ const childProcess = require('child_process');
6
6
const fs = require ( 'fs' ) ;
7
7
8
8
const COMPONENTS_DOCS_DIR = './docs/components' ;
9
- const VALID_CATEGORIES = [
9
+ const SERVICES_DOCS_DIR = './docs/services' ;
10
+
11
+ const VALID_COMPONENTS_CATEGORIES = [
10
12
'foundation' ,
11
13
'basic' ,
12
14
'assets' ,
@@ -21,7 +23,9 @@ const VALID_CATEGORIES = [
21
23
'overlays' ,
22
24
'charts' ,
23
25
'incubator' ,
24
- 'infra'
26
+ 'infra' ,
27
+ // non components categories
28
+ 'services'
25
29
] ;
26
30
27
31
function buildDocs ( apiFolders , componentsPreProcess ) {
@@ -64,7 +68,7 @@ function processComponents(components) {
64
68
const isParentComponent = parentComponents . includes ( componentName ) ;
65
69
const isIncubatorComponent = component . category === 'incubator' ;
66
70
67
- if ( ! VALID_CATEGORIES . includes ( component . category ) ) {
71
+ if ( ! VALID_COMPONENTS_CATEGORIES . includes ( component . category ) ) {
68
72
console . error ( `${ componentName } has invalid category "${ component . category } "` ) ;
69
73
}
70
74
@@ -88,15 +92,21 @@ function processComponents(components) {
88
92
content += `${ buildOldDocs ( component ) } \n` ;
89
93
}
90
94
91
- const componentParentDir =
92
- componentParentName || isParentComponent ? `/${ componentParentName || componentName } ` : '' ;
93
- const dirPath = `${ COMPONENTS_DOCS_DIR } /${ component . category } ${ componentParentDir } ` ;
95
+
96
+ let dirPath ;
97
+ if ( component . category === 'services' ) {
98
+ dirPath = `${ SERVICES_DOCS_DIR } ` ;
99
+ } else {
100
+ const componentParentDir =
101
+ componentParentName || isParentComponent ? `/${ componentParentName || componentName } ` : '' ;
102
+ dirPath = `${ COMPONENTS_DOCS_DIR } /${ component . category } ${ componentParentDir } ` ;
103
+ }
94
104
95
105
if ( ! fs . existsSync ( dirPath ) ) {
96
106
fs . mkdirSync ( dirPath , { recursive : true } ) ;
97
107
}
98
108
99
- fs . writeFileSync ( `${ dirPath } /${ component . name } .md` , content , { encoding : 'utf8' } ) ;
109
+ fs . writeFileSync ( `${ dirPath } /${ component . name . replaceAll ( ' ' , '_' ) } .md` , content , { encoding : 'utf8' } ) ;
100
110
} ) ;
101
111
}
102
112
0 commit comments