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] New way of providing API layout config #41106

Merged
merged 4 commits into from
Feb 19, 2024
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
11 changes: 9 additions & 2 deletions packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ const generateApiPage = async (
reactApi: ReactApi,
sortingStrategies?: SortingStrategiesType,
onlyJsonFile: boolean = false,
layoutConfigPath: string = '',
) => {
const normalizedApiPathname = reactApi.apiPathname.replace(/\\/g, '/');
/**
Expand Down Expand Up @@ -422,12 +423,17 @@ const generateApiPage = async (
path.resolve(apiPagesDirectory, `${kebabCase(reactApi.name)}.js`),
`import * as React from 'react';
import ApiPage from 'docs/src/modules/components/ApiPage';
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations';
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations';${
layoutConfigPath === ''
? ''
: `
import layoutConfig from '${layoutConfigPath}';`
}
import jsonPageContent from './${kebabCase(reactApi.name)}.json';

export default function Page(props) {
const { descriptions, pageContent } = props;
return <ApiPage descriptions={descriptions} pageContent={pageContent} />;
return <ApiPage ${layoutConfigPath === '' ? '' : '{...layoutConfig} '}descriptions={descriptions} pageContent={pageContent} />;
}

Page.getInitialProps = () => {
Expand Down Expand Up @@ -802,6 +808,7 @@ export default async function generateComponentApi(
reactApi,
projectSettings.sortingStrategies,
generateJsonFileOnly,
componentInfo.layoutConfigPath,
);

if (
Expand Down
4 changes: 4 additions & 0 deletions packages/api-docs-builder/buildApiUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ export type ComponentInfo = {
};
getDemos: () => Array<{ demoPageTitle: string; demoPathname: string }>;
apiPagesDirectory: string;
/**
* The path to import specific layout config of the page if needed.
*/
layoutConfigPath?: string;
skipApiGeneration?: boolean;
/**
* If `true`, the component's name match one of the MUI System components.
Expand Down
Loading