/
produce.ts
46 lines (37 loc) · 1.07 KB
/
produce.ts
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
37
38
39
40
41
42
43
44
45
46
import * as td from 'typedoc'
export enum ExitCodes {
Ok = 0,
OptionError = 1,
NoEntryPoints = 2,
CompileError = 3,
ValidationError = 4,
OutputError = 5,
ExceptionThrown = 6,
}
export const produce = async (): Promise<td.JSONOutput.ProjectReflection | ExitCodes> => {
const app = new td.Application()
process.argv.push(
...(`--readme none --emit docs --excludeExternals --excludeInternal --excludePrivate --excludeProtected`
.split(' '))
)
app.options.addReader(new td.ArgumentsReader(0))
app.options.addReader(new td.TypeDocReader())
app.options.addReader(new td.TSConfigReader())
app.options.addReader(new td.ArgumentsReader(300))
app.bootstrap()
const project = app.convert()
if (!project)
return ExitCodes.CompileError
if (
app.options.getValue('treatWarningsAsErrors')
&& app.logger.hasWarnings()
) {
return ExitCodes.CompileError
}
app.validate(project)
if (app.logger.hasErrors())
return ExitCodes.ValidationError
const json = app.serializer.projectToObject(project)
json.name = 'api'
return json
}