Skip to content

Commit

Permalink
[docs-infra] Fix API generation for Base UI (#37941)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored Jul 14, 2023
1 parent 87c9a6d commit dfc4ffd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
4 changes: 2 additions & 2 deletions docs/pages/base-ui/all-components/index.js
Original file line number Diff line number Diff line change
@@ -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 <MarkdownDocs {...pageProps} {...other} />;
return <MarkdownDocs {...pageProps} {...other} disableToc />;
}

Page.getLayout = (page) => {
Expand Down
14 changes: 3 additions & 11 deletions packages/api-docs-builder/buildApiUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down Expand Up @@ -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 });
Expand Down

0 comments on commit dfc4ffd

Please sign in to comment.