Migrate typedoc script to JS

Needed to do this to make the new theme, apparently
This commit is contained in:
Oliver Blanthorn 2023-03-14 19:32:55 +01:00
parent 9e3095570e
commit e02b06fec3
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
3 changed files with 48 additions and 2 deletions

View file

@ -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",

45
scripts/make_docs.js Normal file
View file

@ -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);

View file

@ -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/