-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenderdocs.js
36 lines (29 loc) · 1.02 KB
/
renderdocs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// @ts-check
"use strict";
if (!process.env.FOLDERNAME) {
process.env.CI && (void console.error("no folder name provided (and this is CI), aborting") || process.exit(1));
process.env.FOLDERNAME = "";
}
const fs = require("fs-extra");
const { Application, TSConfigReader } = require("typedoc");
const app = new Application();
const input = ["./src/index.ts"];
const outdir = "docs";
const out = `${outdir}/${process.env.FOLDERNAME}`;
const isreleasebuild = process.env.CI ? process.env.GITHUB_REF.includes("/tag") : false;
app.options.addReader(new TSConfigReader);
app.bootstrap({
entryPoints: input,
out: out,
excludePrivate: true,
includeVersion: isreleasebuild,
listInvalidSymbolLinks: true
});
const project = app.convert();
if (project) app.generateDocs(project, out).catch((...err) => void console.error(...err) || (process.exitCode = 1));
if (isreleasebuild) {
// also put it in folder "latest"
fs.copySync(`${outdir}/${process.env.FOLDERNAME}`, `${outdir}/latest`, {
errorOnExist: true
});
}