Skip to content

Commit b1ceef4

Browse files
authored
Build docs of services category in a separate folder (#3453)
* Build docs of services category in a separate folder * Remove spaces for autogenerated md filenames
1 parent ee8a437 commit b1ceef4

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

scripts/docs/buildDocsCommon.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ const childProcess = require('child_process');
66
const fs = require('fs');
77

88
const COMPONENTS_DOCS_DIR = './docs/components';
9-
const VALID_CATEGORIES = [
9+
const SERVICES_DOCS_DIR = './docs/services';
10+
11+
const VALID_COMPONENTS_CATEGORIES = [
1012
'foundation',
1113
'basic',
1214
'assets',
@@ -21,7 +23,9 @@ const VALID_CATEGORIES = [
2123
'overlays',
2224
'charts',
2325
'incubator',
24-
'infra'
26+
'infra',
27+
// non components categories
28+
'services'
2529
];
2630

2731
function buildDocs(apiFolders, componentsPreProcess) {
@@ -64,7 +68,7 @@ function processComponents(components) {
6468
const isParentComponent = parentComponents.includes(componentName);
6569
const isIncubatorComponent = component.category === 'incubator';
6670

67-
if (!VALID_CATEGORIES.includes(component.category)) {
71+
if (!VALID_COMPONENTS_CATEGORIES.includes(component.category)) {
6872
console.error(`${componentName} has invalid category "${component.category}"`);
6973
}
7074

@@ -88,15 +92,21 @@ function processComponents(components) {
8892
content += `${buildOldDocs(component)}\n`;
8993
}
9094

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+
}
94104

95105
if (!fs.existsSync(dirPath)) {
96106
fs.mkdirSync(dirPath, {recursive: true});
97107
}
98108

99-
fs.writeFileSync(`${dirPath}/${component.name}.md`, content, {encoding: 'utf8'});
109+
fs.writeFileSync(`${dirPath}/${component.name.replaceAll(' ', '_')}.md`, content, {encoding: 'utf8'});
100110
});
101111
}
102112

0 commit comments

Comments
 (0)