Skip to content

Commit 42e8ec3

Browse files
created renderParameters function in docusaurus script to include row for method parameters generated in renderMethods function (#4139)
1 parent 36ffb61 commit 42e8ec3

File tree

1 file changed

+20
-0
lines changed
  • plugins/docusaurus-plugin-ionic-component-api

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,25 @@ function renderEvents({ events }) {
173173
${events.map((event) => `| \`${event.event}\` | ${formatMultiline(event.docs)} | \`${event.bubbles}\` |`).join('\n')}`;
174174
}
175175

176+
/**
177+
* Formats method parameters for the optional Parameters row of each method table
178+
* @param {*} paramsArr Array of method parameters
179+
* @returns formatted parameters for methods table
180+
*/
181+
function renderParameters(paramsArr) {
182+
if (!paramsArr.some((param) => param.docs)) {
183+
return '';
184+
}
185+
186+
const documentedParams = paramsArr.filter((param) => param.docs);
187+
const formattedParams = documentedParams
188+
.map((param) => {
189+
return `**${param.name}**: ${formatMultiline(param.docs)}`;
190+
})
191+
.join('<br/>');
192+
return `| **Parameters** | ${formattedParams} |`;
193+
}
194+
176195
function renderMethods({ methods }) {
177196
if (methods.length === 0) {
178197
return 'No public methods available for this component.';
@@ -189,6 +208,7 @@ ${methods
189208
| --- | --- |
190209
| **Description** | ${formatMultiline(method.docs)} |
191210
| **Signature** | \`${method.signature.replace(/\|/g, '\uff5c')}\` |
211+
${method.parameters.length !== 0 ? renderParameters(method.parameters) : ''}
192212
`
193213
)
194214
.join('\n')}

0 commit comments

Comments
 (0)