-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Fix the prop type regression on the API pages #36168
[docs] Fix the prop type regression on the API pages #36168
Conversation
.replace(/>/g, '>') | ||
.replace(/"/g, '"') | ||
.replace(/'/g, '''); | ||
const typeName = propData.type.description || propData.type.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is basically reverting what I introduced in #35828
return { | ||
[propName]: { | ||
type: { | ||
name: propDescriptor.typeStr, | ||
description: propDescriptor.description ?? undefined, | ||
name: typeDescription, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the components, the type.name
refers to: shape
, union
etc, while the description contains the processed type. This is specific to the structure that react-docgen generates. In order to match the same and simplify things, I've added the type string to both the name and the description for the hooks' types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you leave this as a comment in code? Here maybe, https://github.com/mui/material-ui/pull/36168/files#r1104474099
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, added!
Netlify deploy previewhttps://deploy-preview-36168--material-ui.netlify.app/ Bundle size report |
The hooks json files are changed because of the change in the |
"name": "'touch' | 'mouse' | true | false", | ||
"description": "Control if the input should be blurred when an option is selected:\n\n- `false` the input is not blurred.\n- `true` the input is always blurred.\n- `touch` the input is blurred after a touch event.\n- `mouse` the input is blurred after a mouse event." | ||
"name": "'touch' | 'mouse' | true | false", | ||
"description": "'touch' | 'mouse' | true | false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does the 'real' description text is stored now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In docs\translations\api-docs\use-autocomplete\use-autocomplete.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first confusion with the hooks API generation, was that this is suppose to be the description, but it is not the case with the components' props, as docgen generates this structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just one comment.
return { | ||
[propName]: { | ||
type: { | ||
name: propDescriptor.typeStr, | ||
description: propDescriptor.description ?? undefined, | ||
name: typeDescription, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you leave this as a comment in code? Here maybe, https://github.com/mui/material-ui/pull/36168/files#r1104474099
Signed-off-by: Marija Najdova <mnajdova@gmail.com>
Fixes regression from #35828 on the component's API prop types.
Before: https://mui.com/base/api/tab-unstyled/

After: https://deploy-preview-36168--material-ui.netlify.app/base/api/tab-unstyled/

Hooks pages are not affected by the change:
Before: https://master--material-ui.netlify.app/base/api/use-tab/
After: https://deploy-preview-36168--material-ui.netlify.app/base/api/use-tab/