mui / mui/material-ui

[material-ui] Provide more direct documentation access to props of "inherited" components

Open
#18,288 8 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs scope: docs-infra
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:

  1. 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: Menu wraps Popover which in turn wraps Modal.
  2. 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: Select leverages Menu and receives props for the Menu element via its MenuProps prop.

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.