Skip to content

[docs-infra] Support subpath-only components in API docs - #49968

Open
LukasTy wants to merge 2 commits into
mui:masterfrom
LukasTy:claude/api-docs-subpath-components
Open

LukasTy wants to merge 2 commits into
mui:masterfrom
LukasTy:claude/api-docs-subpath-components

Conversation

@LukasTy

@LukasTy LukasTy commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

#48823 (Menu2) needs this API docs tooling. This PR moves the generic part out of that PR for a separate review. The Menu2 PR stays open, and gets a merge of master after this PR merges.

Changes

  • api-docs-builder resolves a component that has only a subpath export from its own file. Before, the Pigment components had to be extra entry points of the material project.
  • The API page lists a package-root import only when the package root exports the component. This removes the incorrect @mui/material imports from the PigmentContainer, PigmentGrid, and PigmentStack API pages.
  • The undocumented-prop check uses the same lookup to skip React DOM props.
  • PigmentContainer lists its MuiContainer classes.
  • findComponents accepts digits in all parts of a component file name, not only a trailing 2. The file name must end in .js or .tsx.
  • parseSlotsAndClasses reads the instantiated type of the classes prop, so a generic classes prop works.
  • ComponentInfo gets an optional importName, the local name in import examples. The Menu2 PR sets it.
  • typescript-to-proptypes preserves null in React element-type unions, for slots that accept null. It takes null and undefined from the resolved prop type. A prop that an intersection or a mapped type narrows stays required.

Impact

  • pnpm docs:api: only the 3 Pigment API pages and the PigmentContainer translations change.
  • pnpm proptypes: no changes.

Generated with Claude Code

Move the generic API docs tooling out of mui#48823.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LukasTy LukasTy added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305). needs cherry-pick The PR should be cherry-picked to master after merge. v9.x labels Dec 3, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-49968--material-ui.netlify.app/
QR code for https://deploy-preview-49968--material-ui.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Performance

No regressions in 32 benchmarks · precise to ±8.7% (±12.9% at worst) · ran 3m 50s · details


Check out the code infra dashboard for more information about this PR.

Intersections and mapped types can remove `null` or `undefined` from a prop declaration. Read them from the resolved prop type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LukasTy
LukasTy marked this pull request as ready for review December 3, 2026 15:42
@LukasTy
LukasTy requested review from Janpot, brijeshb42 and siriwatknp and a balanced review from Copilot December 3, 2026 15:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the API documentation tooling changes.

No open issues 🎉

What changed in this PR

Prepares Material UI’s API documentation tooling for subpath-only components, supporting Menu v2 in #48823 and correcting existing Pigment documentation.

Changes:

  • Resolves subpath-only components and generates imports based on package exports.
  • Supports digit-containing component names, import aliases, and generic class props.
  • Preserves React union types and nullability in generated PropTypes, with regression fixtures.
File Description
packages-internal/​scripts/​typescript-to-proptypes/​test/​nullable-react-types/​output.js Expected nullable React validators.
packages-internal/​scripts/​typescript-to-proptypes/​test/​nullable-react-types/​input.d.ts Nullable React type fixtures.
packages-internal/​scripts/​typescript-to-proptypes/​test/​narrowed-react-types/​output.js Expected required validators after narrowing.
packages-internal/​scripts/​typescript-to-proptypes/​test/​narrowed-react-types/​input.d.ts Intersection and mapped-type fixtures.
packages-internal/​scripts/​typescript-to-proptypes/​test/​mixed-react-types/​output.js Expected mixed-union validators.
packages-internal/​scripts/​typescript-to-proptypes/​test/​mixed-react-types/​input.d.ts Mixed React union fixtures.
packages-internal/​scripts/​typescript-to-proptypes/​src/​getTypeHash.ts Distinguishes element validator kinds.
packages-internal/​scripts/​typescript-to-proptypes/​src/​getPropTypesFromFile.ts Preserves React unions and resolved nullability.
packages-internal/​api-docs-builder/​src/​utils/​parseSlotsAndClasses.ts Reads instantiated class prop types.
packages-internal/​api-docs-builder/​src/​utils/​parseSlotsAndClasses.test.ts Tests generic and local class extraction.
packages-internal/​api-docs-builder/​src/​utils/​getComponentTypeScriptProject.ts Resolves component-local exports.
packages-internal/​api-docs-builder/​src/​utils/​getComponentTypeScriptProject.test.ts Tests resolution and shared-project isolation.
packages-internal/​api-docs-builder/​src/​utils/​getComponentImports.ts Generates export-aware import examples.
packages-internal/​api-docs-builder/​src/​utils/​getComponentImports.test.ts Tests import paths and aliases.
packages-internal/​api-docs-builder/​src/​utils/​findComponents.ts Accepts digits and anchors file extensions.
packages-internal/​api-docs-builder/​src/​utils/​findComponents.test.ts Tests filename filtering and nested discovery.
packages-internal/​api-docs-builder/​src/​utils/​createTypeScriptProject.ts Removes an obsolete Pigment entry-point example.
packages-internal/​api-docs-builder/​src/​types/​utils.types.ts Adds optional local import names.
packages-internal/​api-docs-builder/​src/​ApiBuilders/​ComponentApiBuilder.ts Integrates import and component-resolution helpers.
packages-internal/​api-docs-builder-core/​materialUi/​projectSettings.ts Simplifies entry points and maps PigmentContainer classes.
docs/​translations/​api-docs/​pigment-container/​pigment-container.json Adds class descriptions.
docs/​pages/​material-ui/​api/​pigment-stack.json Removes the invalid package-root import.
docs/​pages/​material-ui/​api/​pigment-grid.json Removes the invalid package-root import.
docs/​pages/​material-ui/​api/​pigment-container.json Corrects imports and documents MuiContainer classes.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs cherry-pick The PR should be cherry-picked to master after merge. scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305). type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. v9.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants