Skip to content

Build docs of services category in a separate folder #3453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions scripts/docs/buildDocsCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const childProcess = require('child_process');
const fs = require('fs');

const COMPONENTS_DOCS_DIR = './docs/components';
const VALID_CATEGORIES = [
const SERVICES_DOCS_DIR = './docs/services';

const VALID_COMPONENTS_CATEGORIES = [
'foundation',
'basic',
'assets',
Expand All @@ -21,7 +23,9 @@ const VALID_CATEGORIES = [
'overlays',
'charts',
'incubator',
'infra'
'infra',
// non components categories
'services'
];

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

if (!VALID_CATEGORIES.includes(component.category)) {
if (!VALID_COMPONENTS_CATEGORIES.includes(component.category)) {
console.error(`${componentName} has invalid category "${component.category}"`);
}

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

const componentParentDir =
componentParentName || isParentComponent ? `/${componentParentName || componentName}` : '';
const dirPath = `${COMPONENTS_DOCS_DIR}/${component.category}${componentParentDir}`;

let dirPath;
if (component.category === 'services') {
dirPath = `${SERVICES_DOCS_DIR}`;
} else {
const componentParentDir =
componentParentName || isParentComponent ? `/${componentParentName || componentName}` : '';
dirPath = `${COMPONENTS_DOCS_DIR}/${component.category}${componentParentDir}`;
}

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

fs.writeFileSync(`${dirPath}/${component.name}.md`, content, {encoding: 'utf8'});
fs.writeFileSync(`${dirPath}/${component.name.replaceAll(' ', '_')}.md`, content, {encoding: 'utf8'});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the replaceAll here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When Docusaurus read the md files, they can't have spaces in them
Usually the components names (in api.json) are one word
Now that I want to support building other types of md files, the name doesn't represent just components name.
for example in the private PR I have a file with a name of RNN TopBar

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Thanks

});
}

Expand Down