blob: 4ac4fbf977639929d2aab4536d5468543dfe38af (
plain)
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
47
48
49
50
51
52
53
54
55
56
|
import { resolve } from 'path';
import * as TypeDoc from 'typedoc';
import { writeApiPagesIndex } from './apidoc/apiDocsWriter';
import { processDirectMethods } from './apidoc/directMethods';
import { processModuleMethods } from './apidoc/moduleMethods';
import {
DefaultParameterAwareSerializer,
parameterDefaultReader,
patchProjectParameterDefaults,
} from './apidoc/parameterDefaults';
import type { PageIndex } from './apidoc/utils';
import { pathOutputDir } from './apidoc/utils';
const pathOutputJson = resolve(pathOutputDir, 'typedoc.json');
async function build(): Promise<void> {
const app = new TypeDoc.Application();
app.options.addReader(new TypeDoc.TSConfigReader());
// If you want TypeDoc to load typedoc.json files
//app.options.addReader(new TypeDoc.TypeDocReader());
// Read parameter defaults
app.converter.on(
TypeDoc.Converter.EVENT_CREATE_DECLARATION,
parameterDefaultReader
);
// Add to debug json output
app.serializer.addSerializer(new DefaultParameterAwareSerializer(undefined));
app.bootstrap({
entryPoints: ['src/index.ts'],
pretty: true,
cleanOutputDir: true,
});
const project = app.convert();
if (!project) {
// Project may not have converted correctly
return;
}
// Useful for manually analyzing the content
await app.generateJson(project, pathOutputJson);
console.log(pathOutputDir);
patchProjectParameterDefaults(project);
const modulesPages: PageIndex = [];
modulesPages.push({ text: 'Localization', link: '/api/localization.html' });
modulesPages.push(...processModuleMethods(project));
modulesPages.push(...processDirectMethods(project));
writeApiPagesIndex(modulesPages);
}
build().catch(console.error);
|