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][material-ui] Format key prop JSDoc description in Snackbar component code correctly #38603

Conversation

jaydenseric
Copy link
Contributor

@jaydenseric jaydenseric commented Aug 23, 2023

This PR correctly formats inline code in the component Snackbar prop key JSDoc description. I also improved the sentences and grammar, and formatted the JSDoc comment to 80 char line lengths.

Inline code examples in JSDoc descriptions should be contained within markdown backticks. This ensures they render correctly as code in editor IntelliSense as well as in the generated Material UI API docs page. This is especially important if the code example looks like a JSX or HTML tag, otherwise markdown renderers will attempt to render it as HTML. If the renderer only accepts a subset of HTML tags (such as VS Code IntelliSense) then it will strip the code example out of the rendered HTML. In other situations where React is used to render the markdown without an allowlist for JSX/HTML (e.g. the Storybook docs page props table), then not wrapping JSX code examples in backticks in the source JSDoc description markdown can cause a React render error.

Here is the VS Code IntelliSense for the component Snackbar prop key before this PR:

Screenshot 2023-08-23 at 3 06 34 pm

Note the inline code examples have been stripped out by the markdown renderer.

Here is after this PR:

Screenshot 2023-08-23 at 3 05 51 pm

Note the inline code examples render correctly.

Here is Storybook docs page prop table rendering before this PR:

Screenshot 2023-08-23 at 2 54 34 pm

Note the React rendering error causing the code examples not to display:

Screenshot 2023-08-23 at 2 52 13 pm

After this PR:

Screenshot 2023-08-23 at 3 27 18 pm

Note there is no longer React rendering errors, and the code examples display correctly in the HMTL.

Here is the Material UI API docs for the component Snackbar prop key before this PR:

https://mui.com/material-ui/api/snackbar/#Snackbar-prop-key

Screenshot 2023-08-23 at 3 09 00 pm

Note the inline code is rendering as text, instead of code. This should be fixed after this PR.

…ption.

Inline code examples in JSDoc descriptions should be contained within markdown backticks. This ensures they render correctly as code in editor IntelliSense as well as in the generated Material UI API docs page. This is especially important if the code example looks like a JSX or HTML tag, otherwise markdown renderers will attempt to render it as HTML. If the renderer only accepts a subset of HTML tags (such as VS Code IntelliSense) then it will strip the code example out of the rendered HTML. In other situations where React is used to render the markdown without an allowlist for JSX/HTML (e.g. the Storybook docs page props table), then not wrapping JSX code examples in backticks in the source JSDoc description markdown can cause a React render error.
@mui-bot
Copy link

mui-bot commented Aug 23, 2023

Netlify deploy preview

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

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against 6ce7817

@jaydenseric jaydenseric changed the title Correctly format code in component Snackbar prop key JSDoc description [Snackbar] Correctly format code in component Snackbar prop key JSDoc description Aug 23, 2023
@zannager zannager added the component: snackbar This is the name of the generic UI component, not the React module! label Aug 23, 2023
@zannager zannager requested a review from siriwatknp August 23, 2023 10:20
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli 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 phrased a bit better.

packages/mui-material/src/Snackbar/Snackbar.d.ts Outdated Show resolved Hide resolved
@ZeeshanTamboli ZeeshanTamboli added bug 🐛 Something doesn't work docs Improvements or additions to the documentation package: material-ui Specific to @mui/material labels Aug 23, 2023
@ZeeshanTamboli ZeeshanTamboli changed the title [Snackbar] Correctly format code in component Snackbar prop key JSDoc description [docs][material-ui] Format key prop JSDoc description in Snackbar component code correctly Aug 23, 2023
@ZeeshanTamboli ZeeshanTamboli changed the title [docs][material-ui] Format key prop JSDoc description in Snackbar component code correctly [docs][material-ui] Format key prop JSDoc description in Snackbar component code correctly Aug 23, 2023
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

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

@jaydenseric Thanks for your first contribution at MUI! Looking forward for more!

@ZeeshanTamboli ZeeshanTamboli merged commit 9b49328 into mui:master Aug 24, 2023
@jaydenseric jaydenseric deleted the jaydenseric/fix-snackbar-prop-key-jsdoc-description branch August 24, 2023 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: snackbar This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants