From: Jérôme Benoit Date: Sat, 12 Aug 2023 09:16:01 +0000 (+0200) Subject: docs: make the typedoc generation portable X-Git-Tag: v2.6.24~12 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=2ab815450d7de12d7d63c46f6192aae2eb6e9b36;p=poolifier.git docs: make the typedoc generation portable Signed-off-by: Jérôme Benoit --- diff --git a/.eslintrc.js b/.eslintrc.js index 3a35e685..0188819b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -66,6 +66,7 @@ module.exports = defineConfig({ 'jsdoc', 'microjob', 'mjs', + 'npx', 'num', 'os', 'perf', diff --git a/.gitignore b/.gitignore index 2dea9b80..404473ff 100644 --- a/.gitignore +++ b/.gitignore @@ -77,5 +77,6 @@ package-lock.json *.bak lib dist +tmp reports/ benchmarks/internal/results/ diff --git a/package.json b/package.json index 4c07c976..d2f72a57 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "lint:fix": "eslint . --cache --fix", "lint:report": "eslint . --cache --format json --output-file reports/eslint.json", "release": "release-it", - "typedoc": "mkdir ./tmp && cp ./docs/*.md ./tmp && typedoc && cp ./tmp/*.md ./docs && rm -rf ./tmp", + "typedoc": "node typedoc.mjs", "prepublishOnly": "pnpm build:prod" }, "ts-standard": { diff --git a/typedoc.json b/typedoc.json index 0512900b..d95b2637 100644 --- a/typedoc.json +++ b/typedoc.json @@ -1,6 +1,6 @@ { "$schema": "https://typedoc.org/schema.json", - "tsconfig": "./tsconfig.production.json", + "tsconfig": "tsconfig.production.json", "entryPoints": ["src"], "out": "docs", "readme": "none", diff --git a/typedoc.mjs b/typedoc.mjs new file mode 100644 index 00000000..b9f9cc99 --- /dev/null +++ b/typedoc.mjs @@ -0,0 +1,32 @@ +import { copyFileSync, mkdirSync, readdirSync, rmSync } from 'node:fs' +import { dirname, join } from 'node:path' +import { fileURLToPath } from 'node:url' +import { execSync } from 'node:child_process' + +try { + mkdirSync(join(dirname(fileURLToPath(import.meta.url)), 'tmp'), { + recursive: true + }) + const markdownFiles = readdirSync( + join(dirname(fileURLToPath(import.meta.url)), 'docs') + ).filter(file => file.endsWith('.md')) + for (const markdownFile of markdownFiles) { + copyFileSync( + join(dirname(fileURLToPath(import.meta.url)), 'docs', markdownFile), + join(dirname(fileURLToPath(import.meta.url)), 'tmp', markdownFile) + ) + } + execSync('npx typedoc', { stdio: 'inherit' }) + for (const markdownFile of markdownFiles) { + copyFileSync( + join(dirname(fileURLToPath(import.meta.url)), 'tmp', markdownFile), + join(dirname(fileURLToPath(import.meta.url)), 'docs', markdownFile) + ) + } + rmSync(join(dirname(fileURLToPath(import.meta.url)), 'tmp'), { + recursive: true, + force: true + }) +} catch (e) { + console.error(e) +}