forked from nativescript-community/ui-material-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
builddoc.mjs
54 lines (49 loc) · 1.71 KB
/
builddoc.mjs
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
import td from 'typedoc';
import ts from 'typescript';
import * as path from 'path';
import {globby} from 'globby';
import typedocJson from './typedoc.js';
/**
* @param {Object} options
* @param {string} options.entryPoint
* @param {string} options.outDir
* @param {Partial<import('typedoc').TypeDocOptions>} [typeDocOptions]
*/
export async function createTypeScriptApiDocs ({ outDir }, typeDocOptions = {}) {
const app = new td.Application();
app.options.addReader(new td.TSConfigReader());
console.log('createTypeScriptApiDocs', typeDocOptions);
const files = await globby(['src/**/*.d.ts', 'src/**/index.ts', '!**/references.d.ts', '!**/appbar', '!**/page', '!**/typings', '!**/angular', '!**/vue', '!**/react'], {
absolute: true,
cwd: path.join(process.cwd())
});
console.log('files', files);
app.bootstrap({
logger: "console",
disableSources: true,
cleanOutputDir: true,
tsconfig: 'tsconfig.doc.json',
entryPointStrategy: td.EntryPointStrategy.Expand,
entryPoints: files,
...typedocJson,
...typeDocOptions
});
//@ts-ignore
app.options.setCompilerOptions(files, {
esModuleInterop: true
});
// const program = ts.createProgram(app.options.getFileNames(), app.options.getCompilerOptions());
const project = app.converter.convert(app.getEntryPoints() ?? []);
if (project) {
await app.generateDocs(project, outDir);
} else {
throw new Error(`Error creating the typedoc project`);
}
};
// app.generateDocs(project, "./docs");
// app.generateJson(project, "./docs.json");
try {
await createTypeScriptApiDocs({ outDir: './docs' });
} catch(err) {
console.error(err);
}