Skip to content
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

[docs-infra] Fixes in API pages generation #37813

Merged
merged 5 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
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
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}
`;

Copy link
Member

Choose a reason for hiding this comment

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

I'm reverting the changes to this file in #37941. It doesn't work per the last commit of #37931. I think that the markdown should match exactly the URL (/base-ui/all-components/) to make reasoning with the path easier. In our case, moving the markdown to match is enough to fix the issue on its own.

Copy link
Member Author

Choose a reason for hiding this comment

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

This fixed another issue with generating docs api pages for the coming soon pages locally. For e.g. running yarn docs:api locally generates API pages for the checkbox, radio, according etc. It's still makes sense to not generate API pages if there are no components & hooks in the header.

Copy link
Member

@oliviertassinari oliviertassinari Jul 19, 2023

Choose a reason for hiding this comment

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

Oh, I see, yarn docs:api now generates files but the CI doesn't check that no new files aren't committed, hence the CI didn't catch the regression I introduced in #37941. So part of my revert was correct, the other part was wrong. Oops

Copy link
Member

Choose a reason for hiding this comment

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

I'm cleaning my mess: #38039.

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