diff --git a/.eslintrc.js b/.eslintrc.js index 4d495ddb45..5c8e17a215 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -439,5 +439,12 @@ module.exports = { 'import/prefer-default-export': 'off', }, }, + { + files: ['scripts/buildApiDocs/**/*'], + rules: { + 'import/no-default-export': 'error', + 'import/prefer-default-export': 'off', + }, + }, ], }; diff --git a/docs/pages/base-ui/api/form-control.json b/docs/pages/base-ui/api/form-control.json index 5c6df584fe..4403030246 100644 --- a/docs/pages/base-ui/api/form-control.json +++ b/docs/pages/base-ui/api/form-control.json @@ -65,6 +65,6 @@ "forwardsRefTo": "HTMLDivElement", "filename": "/packages/mui-base/src/FormControl/FormControl.tsx", "inheritance": null, - "demos": "", + "demos": "", "cssComponent": false } diff --git a/docs/pages/base-ui/api/snackbar.json b/docs/pages/base-ui/api/snackbar.json index 02142ed055..fad38bd3ae 100644 --- a/docs/pages/base-ui/api/snackbar.json +++ b/docs/pages/base-ui/api/snackbar.json @@ -44,6 +44,6 @@ "forwardsRefTo": "HTMLDivElement", "filename": "/packages/mui-base/src/Snackbar/Snackbar.tsx", "inheritance": null, - "demos": "", + "demos": "", "cssComponent": false } diff --git a/docs/pages/base-ui/api/textarea-autosize.json b/docs/pages/base-ui/api/textarea-autosize.json index aa3e40128e..3e7b0d9eaf 100644 --- a/docs/pages/base-ui/api/textarea-autosize.json +++ b/docs/pages/base-ui/api/textarea-autosize.json @@ -17,6 +17,6 @@ "forwardsRefTo": "HTMLTextAreaElement", "filename": "/packages/mui-base/src/TextareaAutosize/TextareaAutosize.tsx", "inheritance": null, - "demos": "", + "demos": "", "cssComponent": false } diff --git a/package.json b/package.json index 74d3e3006a..0eb34f0437 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "release:publish:dry-run": "pnpm publish --recursive --tag latest --registry=\"http://localhost:4873/\"", "release:tag": "node scripts/releaseTag.mjs", "docs:api": "rimraf --glob ./docs/pages/**/api-docs ./docs/pages/**/api && pnpm docs:api:build", - "docs:api:build": "tsx --tsconfig ./scripts/buidApiDocs/tsconfig.json ./scripts/buidApiDocs/index.ts", + "docs:api:build": "tsx --tsconfig ./scripts/buildApiDocs/tsconfig.json ./scripts/buildApiDocs/index.ts", "docs:build": "pnpm --filter docs build", "docs:build-sw": "pnpm --filter docs build-sw", "docs:deploy": "pnpm --filter docs run deploy", @@ -83,7 +83,6 @@ "@babel/preset-typescript": "^7.23.3", "@babel/register": "^7.23.7", "@mnajdova/enzyme-adapter-react-18": "^0.2.0", - "@mui-internal/api-docs-builder-core": "workspace:^", "@mui-internal/docs-utils": "^1.0.2", "@mui/internal-markdown": "^1.0.0", "@mui/internal-scripts": "^1.0.1", @@ -117,6 +116,7 @@ "cpy-cli": "^5.0.0", "cross-env": "^7.0.3", "danger": "^11.3.1", + "docs": "workspace:^", "enzyme": "^3.11.0", "eslint": "^8.57.0", "eslint-config-airbnb": "^19.0.4", diff --git a/packages/api-docs-builder-core/.eslintrc.js b/packages/api-docs-builder-core/.eslintrc.js deleted file mode 100644 index c6c75c36b7..0000000000 --- a/packages/api-docs-builder-core/.eslintrc.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - rules: { - 'import/no-default-export': 'error', - 'import/prefer-default-export': 'off', - }, -}; diff --git a/packages/api-docs-builder-core/baseUi/getBaseUiComponentInfo.skipped-test.ts b/packages/api-docs-builder-core/baseUi/getBaseUiComponentInfo.skipped-test.ts deleted file mode 100644 index 0b03c9d4dc..0000000000 --- a/packages/api-docs-builder-core/baseUi/getBaseUiComponentInfo.skipped-test.ts +++ /dev/null @@ -1,42 +0,0 @@ -// TODO: restore when api-docs-builder is imported from a package - -import path from 'path'; -import fs from 'fs'; -import { expect } from 'chai'; -import sinon from 'sinon'; -import { getBaseUiComponentInfo } from './getBaseUiComponentInfo'; - -describe('getBaseUiComponentInfo', () => { - it('return correct info for base component file', () => { - const componentInfo = getBaseUiComponentInfo( - path.join(process.cwd(), `/packages/mui-base/src/Button/Button.tsx`), - ); - sinon.assert.match(componentInfo, { - name: 'Button', - apiPathname: '/base-ui/react-button/components-api/#button', - muiName: 'Button', - apiPagesDirectory: sinon.match((value) => - value.endsWith(path.join('docs', 'pages', 'base-ui', 'api')), - ), - }); - - componentInfo.readFile(); - - expect(componentInfo.getInheritance()).to.deep.equal(null); - - let existed = false; - try { - fs.readdirSync(path.join(process.cwd(), 'docs/data')); - existed = true; - // eslint-disable-next-line no-empty - } catch (error) {} - if (existed) { - expect(componentInfo.getDemos()).to.deep.equal([ - { - demoPageTitle: 'Button', - demoPathname: '/base-ui/react-button/', - }, - ]); - } - }); -}); diff --git a/packages/api-docs-builder-core/baseUi/getBaseUiHookInfo.skipped-test.ts b/packages/api-docs-builder-core/baseUi/getBaseUiHookInfo.skipped-test.ts deleted file mode 100644 index e3ede3d635..0000000000 --- a/packages/api-docs-builder-core/baseUi/getBaseUiHookInfo.skipped-test.ts +++ /dev/null @@ -1,36 +0,0 @@ -// TODO: restore when api-docs-builder is imported from a package - -import path from 'path'; -import fs from 'fs'; -import { expect } from 'chai'; -import sinon from 'sinon'; -import { getBaseUiHookInfo } from './getBaseUiHookInfo'; - -describe('getBaseUiHookInfo', () => { - it('return correct info for base hook file', () => { - const info = getBaseUiHookInfo( - path.join(process.cwd(), `/packages/mui-base/src/useButton/useButton.ts`), - ); - sinon.assert.match(info, { - name: 'useButton', - apiPathname: '/base-ui/react-button/hooks-api/#use-button', - }); - - info.readFile(); - - let existed = false; - try { - fs.readdirSync(path.join(process.cwd(), 'docs/data')); - existed = true; - // eslint-disable-next-line no-empty - } catch (error) {} - if (existed) { - expect(info.getDemos()).to.deep.equal([ - { - demoPageTitle: 'Button', - demoPathname: '/base-ui/react-button/#hook', - }, - ]); - } - }); -}); diff --git a/packages/api-docs-builder-core/baseUi/migratedBaseComponents.ts b/packages/api-docs-builder-core/baseUi/migratedBaseComponents.ts deleted file mode 100644 index 07d0f3b5b6..0000000000 --- a/packages/api-docs-builder-core/baseUi/migratedBaseComponents.ts +++ /dev/null @@ -1,23 +0,0 @@ -export const migratedBaseComponents = [ - 'Badge', - 'Button', - 'ClickAwayListener', - 'FocusTrap', - 'Input', - 'MenuItem', - 'Menu', - 'Modal', - 'NoSsr', - 'OptionGroup', - 'Option', - 'Popper', - 'Portal', - 'Select', - 'Slider', - 'Switch', - 'TablePagination', - 'TabPanel', - 'TabsList', - 'Tabs', - 'Tab', -]; diff --git a/packages/api-docs-builder-core/package.json b/packages/api-docs-builder-core/package.json deleted file mode 100644 index 8ad00b1758..0000000000 --- a/packages/api-docs-builder-core/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "@mui-internal/api-docs-builder-core", - "version": "1.0.0", - "description": "MUI Core-specific settings for API docs generator", - "private": "true", - "main": "./index.ts", - "scripts": { - "test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/api-docs-builder-core/**/*.test.{js,ts,tsx}'", - "typescript": "tsc -p tsconfig.json" - }, - "dependencies": { - "@mui/internal-markdown": "^1.0.0", - "@mui/monorepo": "github:mui/material-ui#5e4e18a10085b7e65955ca11ba6c93c838003e0c", - "docs": "workspace:^", - "lodash": "^4.17.21" - }, - "devDependencies": { - "@types/babel__core": "^7.20.5", - "@types/babel__traverse": "^7.20.5", - "@types/chai": "^4.3.12", - "@types/doctrine": "^0.0.9", - "@types/mdast": "4.0.3", - "@types/mocha": "^10.0.6", - "@types/node": "^18.19.18", - "@types/sinon": "^17.0.3", - "ast-types": "^0.14.2", - "chai": "^4.4.1", - "sinon": "^17.0.1", - "typescript": "^5.3.3" - } -} diff --git a/packages/api-docs-builder-core/tsconfig.json b/packages/api-docs-builder-core/tsconfig.json deleted file mode 100644 index 59dcd36c43..0000000000 --- a/packages/api-docs-builder-core/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["./**/*.ts"], - "exclude": ["./node_modules"] -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 619238906b..2575bfede0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -96,9 +96,6 @@ importers: '@mnajdova/enzyme-adapter-react-18': specifier: ^0.2.0 version: 0.2.0(enzyme@3.11.0)(react-dom@18.2.0)(react@18.2.0) - '@mui-internal/api-docs-builder-core': - specifier: workspace:^ - version: link:packages/api-docs-builder-core '@mui-internal/docs-utils': specifier: ^1.0.2 version: 1.0.2 @@ -198,6 +195,9 @@ importers: danger: specifier: ^11.3.1 version: 11.3.1 + docs: + specifier: workspace:^ + version: link:docs enzyme: specifier: ^3.11.0 version: 3.11.0 @@ -602,58 +602,6 @@ importers: specifier: ^17.7.2 version: 17.7.2 - packages/api-docs-builder-core: - dependencies: - '@mui/internal-markdown': - specifier: ^1.0.0 - version: 1.0.0 - '@mui/monorepo': - specifier: github:mui/material-ui#5e4e18a10085b7e65955ca11ba6c93c838003e0c - version: github.com/mui/material-ui/5e4e18a10085b7e65955ca11ba6c93c838003e0c - docs: - specifier: workspace:^ - version: link:../../docs - lodash: - specifier: ^4.17.21 - version: 4.17.21 - devDependencies: - '@types/babel__core': - specifier: ^7.20.5 - version: 7.20.5 - '@types/babel__traverse': - specifier: ^7.20.5 - version: 7.20.5 - '@types/chai': - specifier: ^4.3.12 - version: 4.3.12 - '@types/doctrine': - specifier: ^0.0.9 - version: 0.0.9 - '@types/mdast': - specifier: 4.0.3 - version: 4.0.3 - '@types/mocha': - specifier: ^10.0.6 - version: 10.0.6 - '@types/node': - specifier: ^18.19.18 - version: 18.19.18 - '@types/sinon': - specifier: ^17.0.3 - version: 17.0.3 - ast-types: - specifier: ^0.14.2 - version: 0.14.2 - chai: - specifier: ^4.4.1 - version: 4.4.1 - sinon: - specifier: ^17.0.1 - version: 17.0.1 - typescript: - specifier: ^5.3.3 - version: 5.3.3 - packages/eslint-plugin-material-ui: devDependencies: '@types/eslint': @@ -5148,35 +5096,6 @@ packages: resolution: {integrity: sha512-8Mb21KWtpn6PvRQXjsKhrXIcxbSloGqNH50RntwGeJsGPW4xvNhfml+3kKulaKpO/7pgZfOmzsJz7VbepArlGQ==} dev: true - /@types/babel__core@7.20.5: - resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==} - dependencies: - '@babel/parser': 7.23.9 - '@babel/types': 7.23.9 - '@types/babel__generator': 7.6.8 - '@types/babel__template': 7.4.4 - '@types/babel__traverse': 7.20.5 - dev: true - - /@types/babel__generator@7.6.8: - resolution: {integrity: sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==} - dependencies: - '@babel/types': 7.23.9 - dev: true - - /@types/babel__template@7.4.4: - resolution: {integrity: sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==} - dependencies: - '@babel/parser': 7.23.9 - '@babel/types': 7.23.9 - dev: true - - /@types/babel__traverse@7.20.5: - resolution: {integrity: sha512-WXCyOcRtH37HAUkpXhUduaxdm82b4GSlyTqajXviN4EfiuPgNYR109xMCKvpl6zPIpua0DGlMEDCq+g8EdoheQ==} - dependencies: - '@babel/types': 7.23.9 - dev: true - /@types/body-parser@1.19.2: resolution: {integrity: sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==} dependencies: @@ -5221,10 +5140,6 @@ packages: resolution: {integrity: sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==} dev: true - /@types/doctrine@0.0.9: - resolution: {integrity: sha512-eOIHzCUSH7SMfonMG1LsC2f8vxBFtho6NGBznK41R84YzPuvSBzrhEps33IsQiOW9+VL6NQ9DbjQJznk/S4uRA==} - dev: true - /@types/enzyme@3.10.18: resolution: {integrity: sha512-RaO/TyyHZvXkpzinbMTZmd/S5biU4zxkvDsn22ujC29t9FMSzq8tnn8f2MxQ2P8GVhFRG5jTAL05DXKyTtpEQQ==} dependencies: @@ -5339,12 +5254,6 @@ packages: '@types/unist': 2.0.10 dev: true - /@types/mdast@4.0.3: - resolution: {integrity: sha512-LsjtqsyF+d2/yFOYaN22dHZI1Cpwkrj+g06G8+qtUKlhovPW89YhqSnfKtMbkgmEtYpH2gydRNULd6y8mciAFg==} - dependencies: - '@types/unist': 3.0.2 - dev: true - /@types/mime@1.3.2: resolution: {integrity: sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==} @@ -5487,10 +5396,6 @@ packages: resolution: {integrity: sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA==} dev: true - /@types/unist@3.0.2: - resolution: {integrity: sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==} - dev: true - /@types/webxr@0.5.14: resolution: {integrity: sha512-UEMMm/Xn3DtEa+gpzUrOcDj+SJS1tk5YodjwOxcqStNhCfPcwgyC5Srg2ToVKyg2Fhq16Ffpb0UWUQHqoT9AMA==} dev: false diff --git a/packages/api-docs-builder-core/baseUi/generateApiLinks.ts b/scripts/buildApiDocs/config/baseUi/generateApiLinks.ts similarity index 100% rename from packages/api-docs-builder-core/baseUi/generateApiLinks.ts rename to scripts/buildApiDocs/config/baseUi/generateApiLinks.ts diff --git a/packages/api-docs-builder-core/baseUi/generateBaseUiApiPages.ts b/scripts/buildApiDocs/config/baseUi/generateBaseUiApiPages.ts similarity index 100% rename from packages/api-docs-builder-core/baseUi/generateBaseUiApiPages.ts rename to scripts/buildApiDocs/config/baseUi/generateBaseUiApiPages.ts diff --git a/packages/api-docs-builder-core/baseUi/getBaseUiComponentInfo.ts b/scripts/buildApiDocs/config/baseUi/getBaseUiComponentInfo.ts similarity index 66% rename from packages/api-docs-builder-core/baseUi/getBaseUiComponentInfo.ts rename to scripts/buildApiDocs/config/baseUi/getBaseUiComponentInfo.ts index 611bd9a48b..beaed3cb91 100644 --- a/packages/api-docs-builder-core/baseUi/getBaseUiComponentInfo.ts +++ b/scripts/buildApiDocs/config/baseUi/getBaseUiComponentInfo.ts @@ -1,6 +1,5 @@ import fs from 'fs'; import path from 'path'; -import kebabCase from 'lodash/kebabCase'; import { getHeaders, getTitle } from '@mui/internal-markdown'; import { ComponentInfo, @@ -10,16 +9,12 @@ import { parseFile, } from '@mui-internal/api-docs-builder/buildApiUtils'; import findPagesMarkdown from '@mui-internal/api-docs-builder/utils/findPagesMarkdown'; -import { migratedBaseComponents } from './migratedBaseComponents'; -export function getBaseUiDemos(name: string, filename?: string) { +export function getBaseUiDemos(name: string) { // resolve demos, so that we can getch the API url const allMarkdowns = findPagesMarkdown() .filter((markdown) => { - if (migratedBaseComponents.some((component) => (filename ?? name).includes(component))) { - return markdown.filename.match(/[\\/]data[\\/]base[\\/]/); - } - return true; + return markdown.filename.match(/[\\/]data[\\/]base[\\/]/); }) .map((markdown) => { const markdownContent = fs.readFileSync(markdown.filename, 'utf8'); @@ -47,7 +42,7 @@ export function getBaseUiComponentInfo(filename: string): ComponentInfo { throw new Error(`Could not find the component name from: ${filename}`); } - const demos = getBaseUiDemos(name, filename); + const demos = getBaseUiDemos(name); const apiPath = getApiPath(demos, name) || ''; return { @@ -61,17 +56,8 @@ export function getBaseUiComponentInfo(filename: string): ComponentInfo { srcInfo = parseFile(filename); return srcInfo; }, - getInheritance: (inheritedComponent = srcInfo?.inheritedComponent) => { - if (!inheritedComponent) { - return null; - } - return { - name: inheritedComponent, - apiPathname: - inheritedComponent === 'Transition' - ? 'https://reactcommunity.org/react-transition-group/transition/#Transition-props' - : `/base-ui/api/${kebabCase(inheritedComponent)}/`, - }; + getInheritance: () => { + return null; }, getDemos: () => demos, }; diff --git a/packages/api-docs-builder-core/baseUi/getBaseUiHookInfo.ts b/scripts/buildApiDocs/config/baseUi/getBaseUiHookInfo.ts similarity index 88% rename from packages/api-docs-builder-core/baseUi/getBaseUiHookInfo.ts rename to scripts/buildApiDocs/config/baseUi/getBaseUiHookInfo.ts index 6859623e09..ee659c238e 100644 --- a/packages/api-docs-builder-core/baseUi/getBaseUiHookInfo.ts +++ b/scripts/buildApiDocs/config/baseUi/getBaseUiHookInfo.ts @@ -11,7 +11,6 @@ import { parseFile, } from '@mui-internal/api-docs-builder/buildApiUtils'; import findPagesMarkdown from '@mui-internal/api-docs-builder/utils/findPagesMarkdown'; -import { migratedBaseComponents } from './migratedBaseComponents'; export function getBaseUiHookInfo(filename: string): HookInfo { const { name } = extractPackageFile(filename); @@ -22,10 +21,7 @@ export function getBaseUiHookInfo(filename: string): HookInfo { const allMarkdowns = findPagesMarkdown() .filter((markdown) => { - if (migratedBaseComponents.some((component) => filename.includes(component))) { - return markdown.filename.match(/[\\/]data[\\/]base[\\/]/); - } - return true; + return markdown.filename.match(/[\\/]data[\\/]base[\\/]/); }) .map((markdown) => { const markdownContent = fs.readFileSync(markdown.filename, 'utf8'); diff --git a/packages/api-docs-builder-core/baseUi/projectSettings.ts b/scripts/buildApiDocs/config/baseUi/projectSettings.ts similarity index 100% rename from packages/api-docs-builder-core/baseUi/projectSettings.ts rename to scripts/buildApiDocs/config/baseUi/projectSettings.ts diff --git a/packages/api-docs-builder-core/index.ts b/scripts/buildApiDocs/config/index.ts similarity index 100% rename from packages/api-docs-builder-core/index.ts rename to scripts/buildApiDocs/config/index.ts diff --git a/packages/api-docs-builder-core/react-docgen.d.ts b/scripts/buildApiDocs/config/react-docgen.d.ts similarity index 100% rename from packages/api-docs-builder-core/react-docgen.d.ts rename to scripts/buildApiDocs/config/react-docgen.d.ts diff --git a/scripts/buildApiDocs/config/tsconfig.json b/scripts/buildApiDocs/config/tsconfig.json new file mode 100644 index 0000000000..eca7f236c3 --- /dev/null +++ b/scripts/buildApiDocs/config/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./**/*.ts"] +} diff --git a/scripts/buidApiDocs/index.ts b/scripts/buildApiDocs/index.ts similarity index 91% rename from scripts/buidApiDocs/index.ts rename to scripts/buildApiDocs/index.ts index d4a42c19f1..2697a149ab 100644 --- a/scripts/buidApiDocs/index.ts +++ b/scripts/buildApiDocs/index.ts @@ -1,6 +1,6 @@ import yargs, { ArgumentsCamelCase } from 'yargs'; import { ProjectSettings, buildApi } from '@mui-internal/api-docs-builder'; -import { baseUiProjectSettings } from '@mui-internal/api-docs-builder-core'; +import { baseUiProjectSettings } from './config'; const projectSettings: ProjectSettings[] = [baseUiProjectSettings]; diff --git a/scripts/buidApiDocs/tsconfig.json b/scripts/buildApiDocs/tsconfig.json similarity index 100% rename from scripts/buidApiDocs/tsconfig.json rename to scripts/buildApiDocs/tsconfig.json