From dfc4ffd8527439d6de5fe8356d0916f283597db4 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Fri, 14 Jul 2023 20:18:08 +0200 Subject: [PATCH] [docs-infra] Fix API generation for Base UI (#37941) --- .../all-components/all-components.md | 0 docs/pages/base-ui/all-components/index.js | 4 ++-- packages/api-docs-builder/buildApiUtils.ts | 14 +++----------- 3 files changed, 5 insertions(+), 13 deletions(-) rename docs/data/base/{components => }/all-components/all-components.md (100%) diff --git a/docs/data/base/components/all-components/all-components.md b/docs/data/base/all-components/all-components.md similarity index 100% rename from docs/data/base/components/all-components/all-components.md rename to docs/data/base/all-components/all-components.md diff --git a/docs/pages/base-ui/all-components/index.js b/docs/pages/base-ui/all-components/index.js index 2bb2c253929f6b..84838d634f620b 100644 --- a/docs/pages/base-ui/all-components/index.js +++ b/docs/pages/base-ui/all-components/index.js @@ -1,11 +1,11 @@ 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'; +import * as pageProps from 'docs/data/base/all-components/all-components.md?@mui/markdown'; export default function Page(props) { const { userLanguage, ...other } = props; - return ; + return ; } Page.getLayout = (page) => { diff --git a/packages/api-docs-builder/buildApiUtils.ts b/packages/api-docs-builder/buildApiUtils.ts index 0cd9813ed63e7a..a82924f2f4a927 100644 --- a/packages/api-docs-builder/buildApiUtils.ts +++ b/packages/api-docs-builder/buildApiUtils.ts @@ -580,6 +580,8 @@ export function generateBaseUIApiPages() { const productName = pathnameTokens[1]; const componentName = pathnameTokens[3]; + // TODO: fix `productName` should be called `productId` and include the full name, + // e.g. base-ui below. if ( productName === 'base' && (markdown.filename.indexOf('\\components\\') >= 0 || @@ -689,23 +691,13 @@ export const getStaticPaths = () => { ${staticProps} `; - const componentPageDirectory = `docs/pages/${productName}-ui/${ - componentName !== 'all-components' ? 'react-' : '' - }${componentName}/`; + const componentPageDirectory = `docs/pages/${productName}-ui/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 });