From bf20231a26b9f6158d296027446175468c728415 Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Tue, 7 Mar 2023 15:54:16 -0500 Subject: [PATCH] chore: clear docs/native directory when generating markdown --- scripts/native.js | 29 +++++++++++++++++------------ scripts/utils.js | 1 - 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/scripts/native.js b/scripts/native.js index 3688d2db901..ddd0fa68674 100644 --- a/scripts/native.js +++ b/scripts/native.js @@ -36,6 +36,14 @@ async function buildPluginApiDocs(pluginId) { const apiContent = createApiPage(pluginId, readme, pkgJson); const fileName = `${pluginId}.md`; + + // Delete all existing generated markdown files in docs/native + fs.readdirSync('docs/native').forEach((file) => { + if (file.endsWith('.md')) { + fs.rmSync(`docs/native/${file}`); + } + }); + fs.writeFileSync(`docs/native/${fileName}`, apiContent); fs.writeFileSync(`versioned_docs/version-v6/native/${fileName}`, apiContent); } @@ -85,18 +93,15 @@ function toTitleCase(str) { } if (!String.prototype.replaceAll) { - String.prototype.replaceAll = function(str, newStr){ - - // If a regex pattern - if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') { - return this.replace(str, newStr); - } - - // If a string - return this.replace(new RegExp(str, 'g'), newStr); - - }; + String.prototype.replaceAll = function (str, newStr) { + // If a regex pattern + if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') { + return this.replace(str, newStr); + } + + // If a string + return this.replace(new RegExp(str, 'g'), newStr); + }; } main(); - diff --git a/scripts/utils.js b/scripts/utils.js index 4ca6ca4a115..b98cdc034f3 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -53,7 +53,6 @@ function renderOptions(title, data) { ### ${title} ${data .map((item) => { - console.log(item); const alias = item.aliases.length > 0 ? '(or ' + item.aliases.map((alias) => `\`-${alias}\``).join(' ') + ')' : ''; let name = item.type === 'boolean' && item.default === true ? `no-${item.name}` : item.name; if (item.type === 'string') name += `=<${item.spec.value}>`;