Skip to content

Commit

Permalink
chore: format generated property types
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-perkins committed Aug 10, 2023
1 parent 7e081fa commit a72e788
Showing 1 changed file with 13 additions and 1 deletion.
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

0 comments on commit a72e788

Please sign in to comment.