Skip to content

Commit

Permalink
[docs-infra] Fixes in API pages generation (#37813)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnajdova authored Jul 10, 2023
1 parent 610eff5 commit 8b85ae6
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/data/base/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const pages = [
title: 'Components',
icon: standardNavIcons.ToggleOnIcon,
children: [
{ pathname: '/base-ui/react-components', title: 'All components' },
{ pathname: '/base-ui/all-components', title: 'All components' },
{
pathname: '/base-ui/components/inputs',
subheader: 'inputs',
Expand Down
13 changes: 13 additions & 0 deletions docs/pages/base-ui/all-components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as React from 'react';
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocsV2';
import AppFrame from 'docs/src/modules/components/AppFrame';
import * as pageProps from 'docs/data/base/components/all-components/all-components.md?@mui/markdown';

export default function Page(props) {
const { userLanguage, ...other } = props;
return <MarkdownDocs {...pageProps} {...other} />;
}

Page.getLayout = (page) => {
return <AppFrame>{page}</AppFrame>;
};
7 changes: 0 additions & 7 deletions docs/pages/base-ui/react-components/index.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/public/_redirects
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ https://v4.material-ui.com/* https://v4.mui.com/:splat 301!
/material-ui/getting-started/overview/ /material-ui/getting-started/ 301
/joy-ui/getting-started/overview/ /joy-ui/getting-started/ 301
/base-ui/getting-started/overview/ /base-ui/getting-started/ 301
/base-ui/react-components/ /base-ui/all-components/ 301
/system/getting-started/overview/ /system/getting-started/ 301

# Proxies
Expand Down
2 changes: 1 addition & 1 deletion docs/translations/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
"/base-ui/getting-started/usage": "Usage",
"/base-ui/getting-started/customization": "Customization",
"/base-ui/react-": "Components",
"/base-ui/react-components": "All components",
"/base-ui/all-components": "All components",
"inputs": "Inputs",
"/base-ui/react-autocomplete": "Autocomplete",
"/base-ui/react-button": "Button",
Expand Down
12 changes: 11 additions & 1 deletion packages/api-docs-builder/buildApiUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,13 +689,23 @@ export const getStaticPaths = () => {
${staticProps}
`;

const componentPageDirectory = `docs/pages/${productName}-ui/react-${componentName}/`;
const componentPageDirectory = `docs/pages/${productName}-ui/${
componentName !== 'all-components' ? 'react-' : ''
}${componentName}/`;
if (!fs.existsSync(componentPageDirectory)) {
fs.mkdirSync(componentPageDirectory, { recursive: true });
}
const demosSourcePath = path.join(process.cwd(), `${componentPageDirectory}/index.js`);
writePrettifiedFile(demosSourcePath, demosSource);

if (
((components ?? []).length === 0 && (hooks ?? []).length === 0) ||
markdown.filename.endsWith('all-components.md')
) {
// Early return if it's a markdown file without components/hooks.
return;
}

const docsTabsPagesDirectory = `${componentPageDirectory}/[docsTab]`;
if (!fs.existsSync(docsTabsPagesDirectory)) {
fs.mkdirSync(docsTabsPagesDirectory, { recursive: true });
Expand Down

0 comments on commit 8b85ae6

Please sign in to comment.