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] Move data grid interfaces to standard API page layout #12016

Merged
merged 9 commits into from
Mar 29, 2024

Conversation

alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Feb 9, 2024

Move interface API pages to the same behavior as other pages:

  • a json for data
  • a json for translation
  • a jsx component to render it

Moving this script to the core package seems tricky, because core has a behavior where each project can be handled independently. Whereas we have interfaces shared between multiple projects and we need to access to them together to do know if properties are available in community, pro; or premium

Still todo:

  • Fix the ToC (I removed it)
  • Fix type display
  • Fix MIT/pro/premium display
  • Add correct imports
  • Remove default column

Examples

@alexfauquette alexfauquette added docs Improvements or additions to the documentation component: data grid This is the name of the generic UI component, not the React module! labels Feb 9, 2024
@mui-bot
Copy link

mui-bot commented Feb 9, 2024

Deploy preview: https://deploy-preview-12016--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 2c252af

@flaviendelangle flaviendelangle changed the title [WIP] Move data grid interfaces to stadard API page layout [WIP] Move data grid interfaces to standard API page layout Feb 9, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 12, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 12, 2024
@alexfauquette alexfauquette changed the title [WIP] Move data grid interfaces to standard API page layout [docs] Move data grid interfaces to standard API page layout Feb 12, 2024
Copy link

netlify bot commented Feb 13, 2024

Deploy Preview for material-ui-x ready!

Name Link
🔨 Latest commit
🔍 Latest deploy log https://app.netlify.com/sites/material-ui-x/deploys/65cb6bb82b7eac0e41172e2f
😎 Deploy Preview https://deploy-preview-12016--material-ui-x.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@alexfauquette alexfauquette marked this pull request as ready for review February 14, 2024 09:35
@alexfauquette alexfauquette changed the title [docs] Move data grid interfaces to standard API page layout [docs][Do not merge] Move data grid interfaces to standard API page layout Feb 14, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 14, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged and removed PR: out-of-date The pull request has merge conflicts and can't be merged labels Feb 20, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 20, 2024
Comment on lines -197 to -208
let planImg: string;
if (property.projects.includes('x-data-grid')) {
planImg = '';
} else if (property.projects.includes('x-data-grid-pro')) {
planImg =
' [<span class="plan-pro" title="Pro plan"></span>](/x/introduction/licensing/#pro-plan)';
} else if (property.projects.includes('x-data-grid-premium')) {
planImg =
' [<span class="plan-premium" title="Premium plan"></span>](/x/introduction/licensing/#premium-plan)';
} else {
throw new Error(`No valid plan found for ${property.name} property in ${object.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.

extracted in getPlanLevel()

Comment on lines -210 to -228
const formattedName = property.isOptional
? `<span class="prop-name optional">${property.name}<sup><abbr title="optional">?</abbr></sup>${planImg}</span>`
: `<span class="prop-name">${property.name}${planImg}</span>`;

const formattedType = `<span class="prop-type">${escapeCell(property.typeStr)}</span>`;

const formattedDefaultValue =
defaultValue == null ? '' : `<span class="prop-default">${escapeCell(defaultValue)}</span>`;

const formattedDescription = escapeCell(
linkify(property.description, documentedInterfaces, 'markdown'),
);

if (hasDefaultValue) {
text += `| ${formattedName} | ${formattedType} | ${formattedDefaultValue} | ${formattedDescription} |\n`;
} else {
text += `| ${formattedName} | ${formattedType} | ${formattedDescription} |\n`;
}
});
Copy link
Member Author

Choose a reason for hiding this comment

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

Formatting and linkify is done when generating the JSON. The rendering aspect (column order, adding plan image, ...) is done in the PropsTable component done in mui/material-ui#41069

}
const demos = tagInfo.text
Copy link
Member Author

Choose a reason for hiding this comment

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

Because it was markdown rendering, the interface description used markdown format to add links to demo

Here I parse them to extract the url and the name to render

docs/scripts/api/buildInterfacesDocumentation.ts Outdated Show resolved Hide resolved
.replace(/>/g, '&gt;')
.replace(/\|/g, '\\|')
.replace(/\r?\n/g, '<br />');
return value.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\r?\n/g, '<br />');
Copy link
Member Author

Choose a reason for hiding this comment

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

Remove this escape aspect because it's only for markdown

.replace(/\|/g, '\\|')

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 20, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 21, 2024
@alexfauquette alexfauquette changed the title [docs][Do not merge] Move data grid interfaces to standard API page layout [docs] Move data grid interfaces to standard API page layout Feb 22, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 20, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 20, 2024
@MBilalShafi MBilalShafi changed the base branch from next to master March 21, 2024 02:22
description={description}
disableToc={false}
toc={[]}
location={apiSourceLocation}
Copy link
Member

Choose a reason for hiding this comment

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

The "Edit this page" button is broken – it links to https://github.com/mui/mui-x/settings/master
Previously, we were linking to the .md file, but did it make much sense if the file was autogenerated?

I think we should remove the "Edit this page" button from the interfaces pages.
What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

The link point to https://github.com/mui/mui-x/edit/master/[the location] but the location is an empty string. And https://github.com/mui/mui-x/edit/master/ goes to settings because it's a folder, not a file

Will be fixed with this PR.

mui/material-ui#41702

docs/scripts/api/buildInterfacesDocumentation.ts Outdated Show resolved Hide resolved
docs/scripts/api/buildInterfacesDocumentation.ts Outdated Show resolved Hide resolved
@@ -31,14 +31,18 @@ interface ParsedProperty {
name: string;
description: string;
tags: { [tagName: string]: ts.JSDocTagInfo };
isOptional: boolean;
required: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

PropertiesSection expects the required field.

required: property.required,
}))
.sort((a, b) => {
if ((a.required && b.required) || (!a.required && !b.required)) {
Copy link
Member

Choose a reason for hiding this comment

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

To list the required properties first

Copy link
Member

@cherniavskii cherniavskii left a comment

Choose a reason for hiding this comment

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

@alexfauquette alexfauquette merged commit 28da4ca into mui:master Mar 29, 2024
17 checks passed
@alexfauquette alexfauquette deleted the data-grid-interface branch March 29, 2024 12:26
joakimtveter pushed a commit to joakimtveter/mui-x that referenced this pull request Jun 6, 2024
Co-authored-by: Andrew Cherniavskyi <andrew@mui.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants