Skip to content

Commit

Permalink
[docs-infra] Fix API generation for Base UI
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jul 12, 2023
1 parent 73dd1e1 commit 56d1d01
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 56d1d01

Please sign in to comment.