From a72e788d1077deca52b0e0d17705e5cc3e03b473 Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Thu, 10 Aug 2023 10:30:10 -0500 Subject: [PATCH] chore: format generated property types --- .../docusaurus-plugin-ionic-component-api/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/docusaurus-plugin-ionic-component-api/index.js b/plugins/docusaurus-plugin-ionic-component-api/index.js index 25dec8d1441..56f5f39d16a 100644 --- a/plugins/docusaurus-plugin-ionic-component-api/index.js +++ b/plugins/docusaurus-plugin-ionic-component-api/index.js @@ -121,6 +121,18 @@ function formatMultiline(str) { return str.split('\n\n').join('

').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', 'string'); + } + return type.replace(/\|/g, '\uff5c'); +} + function renderProperties({ props: properties }) { if (properties.length === 0) { return 'No properties available for this component.'; @@ -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}\` | `;