Skip to content
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

Merged

Conversation

mnajdova
Copy link
Member

@mnajdova mnajdova commented Feb 13, 2023

@mnajdova mnajdova added docs Improvements or additions to the documentation regression A bug, but worse labels Feb 13, 2023
.replace(/>/g, '&gt')
.replace(/"/g, '"')
.replace(/'/g, ''');
const typeName = propData.type.description || propData.type.name;
Copy link
Member Author

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,
Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, added!

@mui-bot
Copy link

mui-bot commented Feb 13, 2023

Netlify deploy preview

https://deploy-preview-36168--material-ui.netlify.app/

Bundle size report

No bundle size changes

Generated by 🚫 dangerJS against 4033a61

@mnajdova
Copy link
Member Author

The hooks json files are changed because of the change in the HookApiBuilder. Now we can use the same way for showing the type between the components and hooks.

"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"
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member Author

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.

Copy link
Member

@hbjORbj hbjORbj left a 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,
Copy link
Member

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation regression A bug, but worse
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants