diff --git a/docs/pages/base-ui/react-autocomplete/[docsTab]/index.js b/docs/pages/base-ui/react-autocomplete/[docsTab]/index.js index d3e8626fa47a26..621c40fa364fa4 100644 --- a/docs/pages/base-ui/react-autocomplete/[docsTab]/index.js +++ b/docs/pages/base-ui/react-autocomplete/[docsTab]/index.js @@ -23,7 +23,7 @@ export const getStaticPaths = () => { export const getStaticProps = () => { const useAutocompleteApiReq = require.context( - 'docs/translations/api-docs/use-autocomplete', + 'docs/translations/api-docs-base/use-autocomplete', false, /use-autocomplete.*.json$/, ); diff --git a/docs/pages/base-ui/react-badge/[docsTab]/index.js b/docs/pages/base-ui/react-badge/[docsTab]/index.js index df9fd7343aa9b5..b1ae2c648274bc 100644 --- a/docs/pages/base-ui/react-badge/[docsTab]/index.js +++ b/docs/pages/base-ui/react-badge/[docsTab]/index.js @@ -31,7 +31,7 @@ export const getStaticProps = () => { const BadgeApiDescriptions = mapApiPageTranslations(BadgeApiReq); const useBadgeApiReq = require.context( - 'docs/translations/api-docs/use-badge', + 'docs/translations/api-docs-base/use-badge', false, /use-badge.*.json$/, ); diff --git a/docs/pages/base-ui/react-button/[docsTab]/index.js b/docs/pages/base-ui/react-button/[docsTab]/index.js index 5cbf74aa5b341b..786bc1fcf260ad 100644 --- a/docs/pages/base-ui/react-button/[docsTab]/index.js +++ b/docs/pages/base-ui/react-button/[docsTab]/index.js @@ -31,7 +31,7 @@ export const getStaticProps = () => { const ButtonApiDescriptions = mapApiPageTranslations(ButtonApiReq); const useButtonApiReq = require.context( - 'docs/translations/api-docs/use-button', + 'docs/translations/api-docs-base/use-button', false, /use-button.*.json$/, ); diff --git a/docs/pages/base-ui/react-form-control/[docsTab]/index.js b/docs/pages/base-ui/react-form-control/[docsTab]/index.js index f48d57b151b636..8a395527f54590 100644 --- a/docs/pages/base-ui/react-form-control/[docsTab]/index.js +++ b/docs/pages/base-ui/react-form-control/[docsTab]/index.js @@ -31,7 +31,7 @@ export const getStaticProps = () => { const FormControlApiDescriptions = mapApiPageTranslations(FormControlApiReq); const useFormControlContextApiReq = require.context( - 'docs/translations/api-docs/use-form-control-context', + 'docs/translations/api-docs-base/use-form-control-context', false, /use-form-control-context.*.json$/, ); diff --git a/docs/pages/base-ui/react-input/[docsTab]/index.js b/docs/pages/base-ui/react-input/[docsTab]/index.js index 58c194b16044a6..7e4779bca4c90c 100644 --- a/docs/pages/base-ui/react-input/[docsTab]/index.js +++ b/docs/pages/base-ui/react-input/[docsTab]/index.js @@ -31,7 +31,7 @@ export const getStaticProps = () => { const InputApiDescriptions = mapApiPageTranslations(InputApiReq); const useInputApiReq = require.context( - 'docs/translations/api-docs/use-input', + 'docs/translations/api-docs-base/use-input', false, /use-input.*.json$/, ); diff --git a/docs/pages/base-ui/react-menu/[docsTab]/index.js b/docs/pages/base-ui/react-menu/[docsTab]/index.js index 8acbf119aa346d..1b1267ed2851eb 100644 --- a/docs/pages/base-ui/react-menu/[docsTab]/index.js +++ b/docs/pages/base-ui/react-menu/[docsTab]/index.js @@ -55,35 +55,35 @@ export const getStaticProps = () => { const MenuItemApiDescriptions = mapApiPageTranslations(MenuItemApiReq); const useDropdownApiReq = require.context( - 'docs/translations/api-docs/use-dropdown', + 'docs/translations/api-docs-base/use-dropdown', false, /use-dropdown.*.json$/, ); const useDropdownApiDescriptions = mapApiPageTranslations(useDropdownApiReq); const useMenuApiReq = require.context( - 'docs/translations/api-docs/use-menu', + 'docs/translations/api-docs-base/use-menu', false, /use-menu.*.json$/, ); const useMenuApiDescriptions = mapApiPageTranslations(useMenuApiReq); const useMenuButtonApiReq = require.context( - 'docs/translations/api-docs/use-menu-button', + 'docs/translations/api-docs-base/use-menu-button', false, /use-menu-button.*.json$/, ); const useMenuButtonApiDescriptions = mapApiPageTranslations(useMenuButtonApiReq); const useMenuItemApiReq = require.context( - 'docs/translations/api-docs/use-menu-item', + 'docs/translations/api-docs-base/use-menu-item', false, /use-menu-item.*.json$/, ); const useMenuItemApiDescriptions = mapApiPageTranslations(useMenuItemApiReq); const useMenuItemContextStabilizerApiReq = require.context( - 'docs/translations/api-docs/use-menu-item-context-stabilizer', + 'docs/translations/api-docs-base/use-menu-item-context-stabilizer', false, /use-menu-item-context-stabilizer.*.json$/, ); diff --git a/docs/pages/base-ui/react-modal/[docsTab]/index.js b/docs/pages/base-ui/react-modal/[docsTab]/index.js index c85815b52de2b5..ee9d853522c956 100644 --- a/docs/pages/base-ui/react-modal/[docsTab]/index.js +++ b/docs/pages/base-ui/react-modal/[docsTab]/index.js @@ -31,7 +31,7 @@ export const getStaticProps = () => { const ModalApiDescriptions = mapApiPageTranslations(ModalApiReq); const useModalApiReq = require.context( - 'docs/translations/api-docs/use-modal', + 'docs/translations/api-docs-base/use-modal', false, /use-modal.*.json$/, ); diff --git a/docs/pages/base-ui/react-number-input/[docsTab]/index.js b/docs/pages/base-ui/react-number-input/[docsTab]/index.js index 97e7a38d94d7a5..de732f7f0a90de 100644 --- a/docs/pages/base-ui/react-number-input/[docsTab]/index.js +++ b/docs/pages/base-ui/react-number-input/[docsTab]/index.js @@ -31,7 +31,7 @@ export const getStaticProps = () => { const NumberInputApiDescriptions = mapApiPageTranslations(NumberInputApiReq); const useNumberInputApiReq = require.context( - 'docs/translations/api-docs/use-number-input', + 'docs/translations/api-docs-base/use-number-input', false, /use-number-input.*.json$/, ); diff --git a/docs/pages/base-ui/react-select/[docsTab]/index.js b/docs/pages/base-ui/react-select/[docsTab]/index.js index c5ed80442efb96..2041433f2c4bc9 100644 --- a/docs/pages/base-ui/react-select/[docsTab]/index.js +++ b/docs/pages/base-ui/react-select/[docsTab]/index.js @@ -49,14 +49,14 @@ export const getStaticProps = () => { const SelectApiDescriptions = mapApiPageTranslations(SelectApiReq); const useOptionApiReq = require.context( - 'docs/translations/api-docs/use-option', + 'docs/translations/api-docs-base/use-option', false, /use-option.*.json$/, ); const useOptionApiDescriptions = mapApiPageTranslations(useOptionApiReq); const useOptionContextStabilizerApiReq = require.context( - 'docs/translations/api-docs/use-option-context-stabilizer', + 'docs/translations/api-docs-base/use-option-context-stabilizer', false, /use-option-context-stabilizer.*.json$/, ); @@ -65,7 +65,7 @@ export const getStaticProps = () => { ); const useSelectApiReq = require.context( - 'docs/translations/api-docs/use-select', + 'docs/translations/api-docs-base/use-select', false, /use-select.*.json$/, ); diff --git a/docs/pages/base-ui/react-slider/[docsTab]/index.js b/docs/pages/base-ui/react-slider/[docsTab]/index.js index dc0b6028f3dae0..f104a6905c7e80 100644 --- a/docs/pages/base-ui/react-slider/[docsTab]/index.js +++ b/docs/pages/base-ui/react-slider/[docsTab]/index.js @@ -31,7 +31,7 @@ export const getStaticProps = () => { const SliderApiDescriptions = mapApiPageTranslations(SliderApiReq); const useSliderApiReq = require.context( - 'docs/translations/api-docs/use-slider', + 'docs/translations/api-docs-base/use-slider', false, /use-slider.*.json$/, ); diff --git a/docs/pages/base-ui/react-snackbar/[docsTab]/index.js b/docs/pages/base-ui/react-snackbar/[docsTab]/index.js index 736bc1e0f05b57..e94440ae808e4b 100644 --- a/docs/pages/base-ui/react-snackbar/[docsTab]/index.js +++ b/docs/pages/base-ui/react-snackbar/[docsTab]/index.js @@ -31,7 +31,7 @@ export const getStaticProps = () => { const SnackbarApiDescriptions = mapApiPageTranslations(SnackbarApiReq); const useSnackbarApiReq = require.context( - 'docs/translations/api-docs/use-snackbar', + 'docs/translations/api-docs-base/use-snackbar', false, /use-snackbar.*.json$/, ); diff --git a/docs/pages/base-ui/react-switch/[docsTab]/index.js b/docs/pages/base-ui/react-switch/[docsTab]/index.js index d420993cb30449..7109664c25db11 100644 --- a/docs/pages/base-ui/react-switch/[docsTab]/index.js +++ b/docs/pages/base-ui/react-switch/[docsTab]/index.js @@ -31,7 +31,7 @@ export const getStaticProps = () => { const SwitchApiDescriptions = mapApiPageTranslations(SwitchApiReq); const useSwitchApiReq = require.context( - 'docs/translations/api-docs/use-switch', + 'docs/translations/api-docs-base/use-switch', false, /use-switch.*.json$/, ); diff --git a/docs/pages/base-ui/react-tabs/[docsTab]/index.js b/docs/pages/base-ui/react-tabs/[docsTab]/index.js index 6d6713e668c05b..f4649a6c65ff03 100644 --- a/docs/pages/base-ui/react-tabs/[docsTab]/index.js +++ b/docs/pages/base-ui/react-tabs/[docsTab]/index.js @@ -50,28 +50,28 @@ export const getStaticProps = () => { const TabsListApiDescriptions = mapApiPageTranslations(TabsListApiReq); const useTabApiReq = require.context( - 'docs/translations/api-docs/use-tab', + 'docs/translations/api-docs-base/use-tab', false, /use-tab.*.json$/, ); const useTabApiDescriptions = mapApiPageTranslations(useTabApiReq); const useTabPanelApiReq = require.context( - 'docs/translations/api-docs/use-tab-panel', + 'docs/translations/api-docs-base/use-tab-panel', false, /use-tab-panel.*.json$/, ); const useTabPanelApiDescriptions = mapApiPageTranslations(useTabPanelApiReq); const useTabsApiReq = require.context( - 'docs/translations/api-docs/use-tabs', + 'docs/translations/api-docs-base/use-tabs', false, /use-tabs.*.json$/, ); const useTabsApiDescriptions = mapApiPageTranslations(useTabsApiReq); const useTabsListApiReq = require.context( - 'docs/translations/api-docs/use-tabs-list', + 'docs/translations/api-docs-base/use-tabs-list', false, /use-tabs-list.*.json$/, ); diff --git a/docs/pages/base-ui/react-transitions/[docsTab]/index.js b/docs/pages/base-ui/react-transitions/[docsTab]/index.js index e3b33ceafd3ef9..96794ef433cdc1 100644 --- a/docs/pages/base-ui/react-transitions/[docsTab]/index.js +++ b/docs/pages/base-ui/react-transitions/[docsTab]/index.js @@ -40,7 +40,7 @@ export const getStaticProps = () => { const CssTransitionApiDescriptions = mapApiPageTranslations(CssTransitionApiReq); const useTransitionStateManagerApiReq = require.context( - 'docs/translations/api-docs/use-transition-state-manager', + 'docs/translations/api-docs-base/use-transition-state-manager', false, /use-transition-state-manager.*.json$/, ); @@ -49,7 +49,7 @@ export const getStaticProps = () => { ); const useTransitionTriggerApiReq = require.context( - 'docs/translations/api-docs/use-transition-trigger', + 'docs/translations/api-docs-base/use-transition-trigger', false, /use-transition-trigger.*.json$/, ); diff --git a/docs/translations/api-docs/use-autocomplete/use-autocomplete.json b/docs/translations/api-docs-base/use-autocomplete/use-autocomplete.json similarity index 100% rename from docs/translations/api-docs/use-autocomplete/use-autocomplete.json rename to docs/translations/api-docs-base/use-autocomplete/use-autocomplete.json diff --git a/docs/translations/api-docs/use-badge/use-badge.json b/docs/translations/api-docs-base/use-badge/use-badge.json similarity index 100% rename from docs/translations/api-docs/use-badge/use-badge.json rename to docs/translations/api-docs-base/use-badge/use-badge.json diff --git a/docs/translations/api-docs/use-button/use-button.json b/docs/translations/api-docs-base/use-button/use-button.json similarity index 100% rename from docs/translations/api-docs/use-button/use-button.json rename to docs/translations/api-docs-base/use-button/use-button.json diff --git a/docs/translations/api-docs/use-dropdown/use-dropdown.json b/docs/translations/api-docs-base/use-dropdown/use-dropdown.json similarity index 100% rename from docs/translations/api-docs/use-dropdown/use-dropdown.json rename to docs/translations/api-docs-base/use-dropdown/use-dropdown.json diff --git a/docs/translations/api-docs/use-form-control-context/use-form-control-context.json b/docs/translations/api-docs-base/use-form-control-context/use-form-control-context.json similarity index 100% rename from docs/translations/api-docs/use-form-control-context/use-form-control-context.json rename to docs/translations/api-docs-base/use-form-control-context/use-form-control-context.json diff --git a/docs/translations/api-docs/use-input/use-input.json b/docs/translations/api-docs-base/use-input/use-input.json similarity index 100% rename from docs/translations/api-docs/use-input/use-input.json rename to docs/translations/api-docs-base/use-input/use-input.json diff --git a/docs/translations/api-docs/use-menu-button/use-menu-button.json b/docs/translations/api-docs-base/use-menu-button/use-menu-button.json similarity index 100% rename from docs/translations/api-docs/use-menu-button/use-menu-button.json rename to docs/translations/api-docs-base/use-menu-button/use-menu-button.json diff --git a/docs/translations/api-docs/use-menu-item-context-stabilizer/use-menu-item-context-stabilizer.json b/docs/translations/api-docs-base/use-menu-item-context-stabilizer/use-menu-item-context-stabilizer.json similarity index 100% rename from docs/translations/api-docs/use-menu-item-context-stabilizer/use-menu-item-context-stabilizer.json rename to docs/translations/api-docs-base/use-menu-item-context-stabilizer/use-menu-item-context-stabilizer.json diff --git a/docs/translations/api-docs/use-menu-item/use-menu-item.json b/docs/translations/api-docs-base/use-menu-item/use-menu-item.json similarity index 100% rename from docs/translations/api-docs/use-menu-item/use-menu-item.json rename to docs/translations/api-docs-base/use-menu-item/use-menu-item.json diff --git a/docs/translations/api-docs/use-menu/use-menu.json b/docs/translations/api-docs-base/use-menu/use-menu.json similarity index 100% rename from docs/translations/api-docs/use-menu/use-menu.json rename to docs/translations/api-docs-base/use-menu/use-menu.json diff --git a/docs/translations/api-docs/use-modal/use-modal.json b/docs/translations/api-docs-base/use-modal/use-modal.json similarity index 100% rename from docs/translations/api-docs/use-modal/use-modal.json rename to docs/translations/api-docs-base/use-modal/use-modal.json diff --git a/docs/translations/api-docs/use-number-input/use-number-input.json b/docs/translations/api-docs-base/use-number-input/use-number-input.json similarity index 100% rename from docs/translations/api-docs/use-number-input/use-number-input.json rename to docs/translations/api-docs-base/use-number-input/use-number-input.json diff --git a/docs/translations/api-docs/use-option-context-stabilizer/use-option-context-stabilizer.json b/docs/translations/api-docs-base/use-option-context-stabilizer/use-option-context-stabilizer.json similarity index 100% rename from docs/translations/api-docs/use-option-context-stabilizer/use-option-context-stabilizer.json rename to docs/translations/api-docs-base/use-option-context-stabilizer/use-option-context-stabilizer.json diff --git a/docs/translations/api-docs/use-option/use-option.json b/docs/translations/api-docs-base/use-option/use-option.json similarity index 100% rename from docs/translations/api-docs/use-option/use-option.json rename to docs/translations/api-docs-base/use-option/use-option.json diff --git a/docs/translations/api-docs/use-select/use-select.json b/docs/translations/api-docs-base/use-select/use-select.json similarity index 100% rename from docs/translations/api-docs/use-select/use-select.json rename to docs/translations/api-docs-base/use-select/use-select.json diff --git a/docs/translations/api-docs/use-slider/use-slider.json b/docs/translations/api-docs-base/use-slider/use-slider.json similarity index 100% rename from docs/translations/api-docs/use-slider/use-slider.json rename to docs/translations/api-docs-base/use-slider/use-slider.json diff --git a/docs/translations/api-docs/use-snackbar/use-snackbar.json b/docs/translations/api-docs-base/use-snackbar/use-snackbar.json similarity index 100% rename from docs/translations/api-docs/use-snackbar/use-snackbar.json rename to docs/translations/api-docs-base/use-snackbar/use-snackbar.json diff --git a/docs/translations/api-docs/use-switch/use-switch.json b/docs/translations/api-docs-base/use-switch/use-switch.json similarity index 100% rename from docs/translations/api-docs/use-switch/use-switch.json rename to docs/translations/api-docs-base/use-switch/use-switch.json diff --git a/docs/translations/api-docs/use-tab-panel/use-tab-panel.json b/docs/translations/api-docs-base/use-tab-panel/use-tab-panel.json similarity index 100% rename from docs/translations/api-docs/use-tab-panel/use-tab-panel.json rename to docs/translations/api-docs-base/use-tab-panel/use-tab-panel.json diff --git a/docs/translations/api-docs/use-tab/use-tab.json b/docs/translations/api-docs-base/use-tab/use-tab.json similarity index 100% rename from docs/translations/api-docs/use-tab/use-tab.json rename to docs/translations/api-docs-base/use-tab/use-tab.json diff --git a/docs/translations/api-docs/use-tabs-list/use-tabs-list.json b/docs/translations/api-docs-base/use-tabs-list/use-tabs-list.json similarity index 100% rename from docs/translations/api-docs/use-tabs-list/use-tabs-list.json rename to docs/translations/api-docs-base/use-tabs-list/use-tabs-list.json diff --git a/docs/translations/api-docs/use-tabs/use-tabs.json b/docs/translations/api-docs-base/use-tabs/use-tabs.json similarity index 100% rename from docs/translations/api-docs/use-tabs/use-tabs.json rename to docs/translations/api-docs-base/use-tabs/use-tabs.json diff --git a/docs/translations/api-docs/use-transition-state-manager/use-transition-state-manager.json b/docs/translations/api-docs-base/use-transition-state-manager/use-transition-state-manager.json similarity index 100% rename from docs/translations/api-docs/use-transition-state-manager/use-transition-state-manager.json rename to docs/translations/api-docs-base/use-transition-state-manager/use-transition-state-manager.json diff --git a/docs/translations/api-docs/use-transition-trigger/use-transition-trigger.json b/docs/translations/api-docs-base/use-transition-trigger/use-transition-trigger.json similarity index 100% rename from docs/translations/api-docs/use-transition-trigger/use-transition-trigger.json rename to docs/translations/api-docs-base/use-transition-trigger/use-transition-trigger.json diff --git a/packages/api-docs-builder-core/baseUi/generateBaseUiApiPages.ts b/packages/api-docs-builder-core/baseUi/generateBaseUiApiPages.ts index e8933b54b1f190..4b895543163c24 100644 --- a/packages/api-docs-builder-core/baseUi/generateBaseUiApiPages.ts +++ b/packages/api-docs-builder-core/baseUi/generateBaseUiApiPages.ts @@ -86,7 +86,7 @@ Page.getLayout = (page) => { apiTabImportStatements += `import ${hook}ApiJsonPageContent from '../../api/${hookNameKebabCase}.json';`; staticProps += ` const ${hook}ApiReq = require.context( - 'docs/translations/api-docs/${hookNameKebabCase}', + 'docs/translations/api-docs-base/${hookNameKebabCase}', false, /${hookNameKebabCase}.*.json$/, ); diff --git a/packages/api-docs-builder/ApiBuilders/HookApiBuilder.ts b/packages/api-docs-builder/ApiBuilders/HookApiBuilder.ts index 25681aa91b4529..d018e396525450 100644 --- a/packages/api-docs-builder/ApiBuilders/HookApiBuilder.ts +++ b/packages/api-docs-builder/ApiBuilders/HookApiBuilder.ts @@ -510,7 +510,7 @@ export default async function generateHookApi( reactApi.description = reactApi.description.slice(0, annotatedDescriptionMatch.index).trim(); } - const { getHookImports = defaultGetHookImports } = projectSettings; + const { getHookImports = defaultGetHookImports, translationPagesDirectory } = projectSettings; reactApi.filename = filename; reactApi.name = name; reactApi.imports = getHookImports(name, filename); @@ -545,7 +545,7 @@ export default async function generateHookApi( if (!skipApiGeneration) { // Generate pages, json and translations await generateApiTranslations( - path.join(process.cwd(), 'docs/translations/api-docs'), + path.join(process.cwd(), translationPagesDirectory), reactApi, projectSettings.translationLanguages, ); diff --git a/packages/api-docs-builder/ProjectSettings.ts b/packages/api-docs-builder/ProjectSettings.ts index d6a1ec8b6f98a3..e814a25d7ee428 100644 --- a/packages/api-docs-builder/ProjectSettings.ts +++ b/packages/api-docs-builder/ProjectSettings.ts @@ -26,6 +26,11 @@ export interface ProjectSettings { * The output path of `pagesApi` generated from `input.pageDirectory` */ apiManifestPath: string; + /** + * Determine if the API manifest file is created. + * @default true + */ + writeApiManifest?: boolean; }; /** * Component directories to be used to generate API diff --git a/packages/api-docs-builder/buildApi.ts b/packages/api-docs-builder/buildApi.ts index 38fe6469cedf29..538338e7008dc1 100644 --- a/packages/api-docs-builder/buildApi.ts +++ b/packages/api-docs-builder/buildApi.ts @@ -111,7 +111,8 @@ async function buildSingleProject( const tsProjects = projectSettings.typeScriptProjects.map((project) => buildTypeScriptProject(project.name), ); - const apiPagesManifestPath = projectSettings.output.apiManifestPath; + + const { apiManifestPath: apiPagesManifestPath, writeApiManifest = true } = projectSettings.output; const manifestDir = apiPagesManifestPath.match(/(.*)\/[^/]+\./)?.[1]; if (manifestDir) { @@ -189,12 +190,14 @@ async function buildSingleProject( process.exit(1); } - let source = `module.exports = ${JSON.stringify(projectSettings.getApiPages())}`; - if (projectSettings.onWritingManifestFile) { - source = projectSettings.onWritingManifestFile(builds, source); - } + if (writeApiManifest) { + let source = `module.exports = ${JSON.stringify(projectSettings.getApiPages())}`; + if (projectSettings.onWritingManifestFile) { + source = projectSettings.onWritingManifestFile(builds, source); + } - await writePrettifiedFile(apiPagesManifestPath, source); + await writePrettifiedFile(apiPagesManifestPath, source); + } await projectSettings.onCompleted?.(); return builds; diff --git a/packages/api-docs-builder/utils/findPagesMarkdown.ts b/packages/api-docs-builder/utils/findPagesMarkdown.ts index 58510771ba765c..d305a26b9cd1b7 100644 --- a/packages/api-docs-builder/utils/findPagesMarkdown.ts +++ b/packages/api-docs-builder/utils/findPagesMarkdown.ts @@ -24,14 +24,14 @@ export default function findPagesMarkdown( } // Ignore non en-US source markdown. - if (!/\.md$/.test(item) || /-(zh|pt)\.md/.test(item)) { + if (!/\.mdx?$/.test(item) || /-(zh|pt)\.mdx?/.test(item)) { return; } let pathname = filename .replace(new RegExp(`\\${path.sep}`, 'g'), '/') .replace(/^.*\/data/, '') - .replace('.md', ''); + .replace(/\.mdx?/, ''); // Remove the last pathname segment. pathname = pathname