fix: some work hacking docs fix

This commit is contained in:
Skillz4Killz
2023-02-25 03:57:40 +00:00
parent cd65e8d5fe
commit a379022d03
6 changed files with 51 additions and 15 deletions
+28
View File
@@ -0,0 +1,28 @@
import fs from 'node:fs'
import path from 'node:path'
// these two paths may vary depending on where you place this script, and your project structure including where typedoc generates its output files.
const typedocOutPath = await import('../typedoc.json', {
assert: { type: 'json' },
}).then((module) => module.default.out)
async function* walk(dir) {
for await (const d of await fs.promises.opendir(dir)) {
const entry = path.join(dir, d.name);
if (d.isDirectory()) yield* walk(entry);
else if (d.isFile()) yield entry;
}
}
for await (const filepath of walk(typedocOutPath)) {
let file = fs.readFileSync(filepath, 'utf-8')
// add all the words we need to replace here for invalid jsx errors
const words = ["internal"];
for (const word of words) {
file = file.replace(new RegExp(`<${word}>`, 'gi'), word);
}
fs.writeFileSync(filepath, file, function (err, result) { if (err) throw err });
}