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

chore: format generated property types #3080

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion plugins/docusaurus-plugin-ionic-component-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ function formatMultiline(str) {
return str.split('\n\n').join('<br /><br />').split('\n').join(' ');
}

function formatType(attr, type) {
if (attr === 'color') {
/**
* The `color` attribute has an additional type that we don't want to display.
* The union type is used to allow intellisense to recommend the color names,
* while still accepting any string value.
*/
type = type.replace('string & Record<never, never>', 'string');
}
return type.replace(/\|/g, '\uff5c');
}

function renderProperties({ props: properties }) {
if (properties.length === 0) {
return 'No properties available for this component.';
Expand All @@ -141,7 +153,7 @@ ${properties
| --- | --- |
| **Description** | ${formatMultiline(docs)} |
| **Attribute** | \`${prop.attr}\` |
| **Type** | \`${prop.type.replace(/\|/g, '\uff5c')}\` |
| **Type** | \`${formatType(prop.attr, prop.type)}\` |
| **Default** | \`${prop.default}\` |

`;
Expand Down