Skip to content

Commit 5045ed4

Browse files
authored
chore: clear docs/native directory when generating markdown (#2812)
1 parent cb7a235 commit 5045ed4

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

scripts/native.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ async function buildPluginApiDocs(pluginId) {
3636

3737
const apiContent = createApiPage(pluginId, readme, pkgJson);
3838
const fileName = `${pluginId}.md`;
39+
40+
// Delete all existing generated markdown files in docs/native
41+
fs.readdirSync('docs/native').forEach((file) => {
42+
if (file.endsWith('.md')) {
43+
fs.rmSync(`docs/native/${file}`);
44+
}
45+
});
46+
3947
fs.writeFileSync(`docs/native/${fileName}`, apiContent);
4048
fs.writeFileSync(`versioned_docs/version-v6/native/${fileName}`, apiContent);
4149
}
@@ -85,18 +93,15 @@ function toTitleCase(str) {
8593
}
8694

8795
if (!String.prototype.replaceAll) {
88-
String.prototype.replaceAll = function(str, newStr){
89-
90-
// If a regex pattern
91-
if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') {
92-
return this.replace(str, newStr);
93-
}
94-
95-
// If a string
96-
return this.replace(new RegExp(str, 'g'), newStr);
97-
98-
};
96+
String.prototype.replaceAll = function (str, newStr) {
97+
// If a regex pattern
98+
if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') {
99+
return this.replace(str, newStr);
100+
}
101+
102+
// If a string
103+
return this.replace(new RegExp(str, 'g'), newStr);
104+
};
99105
}
100106

101107
main();
102-

scripts/utils.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ function renderOptions(title, data) {
5353
### ${title}
5454
${data
5555
.map((item) => {
56-
console.log(item);
5756
const alias = item.aliases.length > 0 ? '(or ' + item.aliases.map((alias) => `\`-${alias}\``).join(' ') + ')' : '';
5857
let name = item.type === 'boolean' && item.default === true ? `no-${item.name}` : item.name;
5958
if (item.type === 'string') name += `=<${item.spec.value}>`;

0 commit comments

Comments
 (0)