Skip to content

Commit 84e8ae2

Browse files
authored
chore: format generated property types (#3080)
1 parent f593596 commit 84e8ae2

File tree

1 file changed

+13
-1
lines changed
  • plugins/docusaurus-plugin-ionic-component-api

1 file changed

+13
-1
lines changed

plugins/docusaurus-plugin-ionic-component-api/index.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@ function formatMultiline(str) {
121121
return str.split('\n\n').join('<br /><br />').split('\n').join(' ');
122122
}
123123

124+
function formatType(attr, type) {
125+
if (attr === 'color') {
126+
/**
127+
* The `color` attribute has an additional type that we don't want to display.
128+
* The union type is used to allow intellisense to recommend the color names,
129+
* while still accepting any string value.
130+
*/
131+
type = type.replace('string & Record<never, never>', 'string');
132+
}
133+
return type.replace(/\|/g, '\uff5c');
134+
}
135+
124136
function renderProperties({ props: properties }) {
125137
if (properties.length === 0) {
126138
return 'No properties available for this component.';
@@ -141,7 +153,7 @@ ${properties
141153
| --- | --- |
142154
| **Description** | ${formatMultiline(docs)} |
143155
| **Attribute** | \`${prop.attr}\` |
144-
| **Type** | \`${prop.type.replace(/\|/g, '\uff5c')}\` |
156+
| **Type** | \`${formatType(prop.attr, prop.type)}\` |
145157
| **Default** | \`${prop.default}\` |
146158
147159
`;

0 commit comments

Comments
 (0)