diff --git a/package.json b/package.json index 67d8a5d9..85721c1e 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "test": "yarn run build && web-ext build --source-dir ./build --overwrite-dest && jest --silent", "update-buildsystem": "rm -rf src/node_modules; yarn run clean", "watch": "echo 'watch is broken, use build instead'; exit 0;", + "makedocs": "node scripts/make_docs.js", "install": "git config core.hookspath hooks/" }, "author": "Colin Caine", diff --git a/scripts/make_docs.js b/scripts/make_docs.js new file mode 100644 index 00000000..4925a815 --- /dev/null +++ b/scripts/make_docs.js @@ -0,0 +1,45 @@ +const TypeDoc = require("typedoc"); + + +// Make the theme + +// Theme docs: https://github.com/TypeStrong/typedoc/blob/master/internal-docs/custom-themes.md +// Theme example: https://github.com/Gerrit0/typedoc-custom-theme-demo/blob/main/src/index.tsx +function load(app) { + app.renderer.defineTheme("tridactyl", TypeDoc.DefaultTheme); +} + + + +// Build the docs +async function main() { + const app = new TypeDoc.Application(); + // console.log(app.options); + + // Load our theme + load(app); + + // Read the tsconfig.json + app.options.addReader(new TypeDoc.TSConfigReader()); + + app.bootstrap({ + // typedoc options here + entryPoints: ["src"], + theme: "tridactyl", + entryPointStrategy: "expand", + skipErrorChecking: true, + exclude: "src/**/?(test_utils|*.test).ts", + }); + + const project = app.convert(); + + if (project) { + // Project may not have converted correctly + const outputDir = "generated/static/docs"; + + // Rendered docs + await app.generateDocs(project, outputDir); + } +} + +main().catch(console.error); diff --git a/scripts/make_docs.sh b/scripts/make_docs.sh index 1f636e84..9bd47d94 100755 --- a/scripts/make_docs.sh +++ b/scripts/make_docs.sh @@ -1,5 +1,5 @@ #!/bin/sh +# nb this is also defined in the makedocs script dest=generated/static/docs -"$(yarn bin)/typedoc" --entryPointStrategy expand --skipErrorChecking --exclude "src/**/?(test_utils|*.test).ts" --out $dest src -#"$(yarn bin)/typedoc" --entryPointStrategy expand --skipErrorChecking --theme src/static/typedoc/ --exclude "src/**/?(test_utils|*.test).ts" --out $dest src +yarn run makedocs cp -r $dest build/static/