[material-ui] Provide more direct documentation access to props of "inherited" components
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
This actually is a duplicate of #7981, but that issue is quite old and I think this would be worth re-visiting.
Summary 💡
Many Material UI components delegate to other Material UI components.
There are two main flavors of this delegation:
- Delegating to a root element wrapped by the main component. Any props not recognized by the main component will be passed down to this root element. Example:
MenuwrapsPopoverwhich in turn wrapsModal. - Delegating to components other than the root element. Props are generally passed to these components via a prop on the main component with a name of
<InnerComponentName>Props. Example:SelectleveragesMenuand receives props for theMenuelement via itsMenuPropsprop.
It is the first case (delegation to a root element) for which I think the documentation could be considerably improved.
Currently the documentation forces you to follow links to these other components in order to discover the full set of props that a component supports. Many people, especially new users of the library, do not notice (or fully understand) the "Any other props supplied will be provided to the root element" portion and miss the fact that many more props may be supported by the component. I think it would be much better for users of the documentation if all of the props from "inherited" components were included directly. So in the case of Menu, the props for Popover and Modal would be included directly in the Menu documentation. It seems like it should be doable for buildApi.js and generateMarkdown.js to be enhanced to automatically include the comprehensive props.
Examples 🌈
This Stack Overflow question shows one example of users assuming that a component (AppBar in this case) only supports the properties shown directly on its API page.
Motivation 🔦
I understand that the current way of documenting the properties was an easier approach to implement, but given the place of "Better documentation" within the roadmap priorities, I think it would be worth the additional complexity in the API doc generation (which is already aware of the inherited component) to allow users to find the comprehensive props more easily/quickly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with docs/scripts/buildApi.js and docs/src/modules/utils/generateMarkdown.js, then trace how inherited component props are currently represented in the generated API documentation. Define the generated output for components such as Menu, Popover, Modal, Select, and AppBar, and add or update documentation-generation tests so inherited root-component props appear directly without losing their source context.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation, tooling
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100