2024-04-03 11:34:26 +00:00
|
|
|
import * as plugins from './plugins.js';
|
|
|
|
import * as paths from './paths.js';
|
2019-05-13 17:41:02 +00:00
|
|
|
|
2019-05-14 15:39:33 +00:00
|
|
|
export class TypeDoc {
|
|
|
|
public smartshellInstance = new plugins.smartshell.Smartshell({
|
|
|
|
executor: 'bash',
|
2020-11-24 20:24:30 +00:00
|
|
|
pathDirectories: [paths.binDir],
|
2019-05-14 15:39:33 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Static
|
|
|
|
public static async isTypeDocDir(dirPathArg: string): Promise<boolean> {
|
2022-06-07 15:54:00 +00:00
|
|
|
return true;
|
2019-05-14 15:39:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Instance
|
|
|
|
public typedocDirectory: string;
|
|
|
|
constructor(dirPathArg) {
|
2019-05-15 19:23:45 +00:00
|
|
|
this.typedocDirectory = dirPathArg;
|
2019-05-14 15:39:33 +00:00
|
|
|
}
|
|
|
|
|
2021-03-06 19:21:13 +00:00
|
|
|
public async compile(options?: { publicSubdir?: string }) {
|
2020-11-24 20:24:30 +00:00
|
|
|
const data = {
|
2024-03-31 13:09:30 +00:00
|
|
|
"compilerOptions": {
|
2022-06-07 15:54:00 +00:00
|
|
|
"experimentalDecorators": true,
|
|
|
|
"useDefineForClassFields": false,
|
|
|
|
"target": "ES2022",
|
2024-03-31 13:09:30 +00:00
|
|
|
"module": "NodeNext",
|
|
|
|
"moduleResolution": "NodeNext",
|
|
|
|
"esModuleInterop": true,
|
|
|
|
"verbatimModuleSyntax": true
|
2020-11-24 20:24:30 +00:00
|
|
|
},
|
|
|
|
include: [],
|
|
|
|
};
|
2021-03-08 01:26:42 +00:00
|
|
|
let startDirectory = '';
|
2021-03-08 01:06:18 +00:00
|
|
|
if (plugins.smartfile.fs.isDirectory(plugins.path.join(paths.cwd, './ts'))) {
|
|
|
|
data.include.push(plugins.path.join(paths.cwd, './ts/**/*'));
|
2021-03-08 01:26:42 +00:00
|
|
|
startDirectory = 'ts';
|
2021-03-08 01:06:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (plugins.smartfile.fs.isDirectory(plugins.path.join(paths.cwd, './ts_web'))) {
|
|
|
|
data.include.push(plugins.path.join(paths.cwd, './ts_web/**/*'));
|
2021-03-08 01:26:42 +00:00
|
|
|
if (!startDirectory) {
|
|
|
|
startDirectory = 'ts_web';
|
|
|
|
}
|
2021-03-08 01:06:18 +00:00
|
|
|
}
|
|
|
|
|
2020-11-24 20:24:30 +00:00
|
|
|
await plugins.smartfile.memory.toFs(JSON.stringify(data), paths.tsconfigFile);
|
2020-11-27 12:02:57 +00:00
|
|
|
let targetDir = paths.publicDir;
|
|
|
|
if (options?.publicSubdir) {
|
|
|
|
targetDir = plugins.path.join(targetDir, options.publicSubdir);
|
|
|
|
}
|
2019-05-15 19:23:45 +00:00
|
|
|
await this.smartshellInstance.exec(
|
2021-03-08 01:26:42 +00:00
|
|
|
`typedoc --tsconfig ${paths.tsconfigFile} --out ${targetDir} ${startDirectory}/index.ts`
|
2019-05-15 19:23:45 +00:00
|
|
|
);
|
2020-11-24 20:24:30 +00:00
|
|
|
plugins.smartfile.fs.remove(paths.tsconfigFile);
|
2019-05-14 15:39:33 +00:00
|
|
|
}
|
|
|
|
}
|