UNPKG

@git.zone/tsdoc

Version:

A comprehensive TypeScript documentation tool that leverages AI to generate and enhance project documentation, including dynamic README creation, API docs via TypeDoc, and smart commit message generation.

59 lines (52 loc) 1.75 kB
import * as plugins from './plugins.js'; import * as paths from './paths.js'; export class TypeDoc { public smartshellInstance = new plugins.smartshell.Smartshell({ executor: 'bash', pathDirectories: [paths.binDir], }); // Static public static async isTypeDocDir(dirPathArg: string): Promise<boolean> { return true; } // Instance public typedocDirectory: string; constructor(dirPathArg) { this.typedocDirectory = dirPathArg; } public async compile(options?: { publicSubdir?: string }) { const data = { compilerOptions: { experimentalDecorators: true, useDefineForClassFields: false, target: 'ES2022', module: 'NodeNext', moduleResolution: 'NodeNext', esModuleInterop: true, verbatimModuleSyntax: true, skipLibCheck: true, }, include: [], }; let startDirectory = ''; if (plugins.smartfile.fs.isDirectory(plugins.path.join(paths.cwd, './ts'))) { data.include.push(plugins.path.join(paths.cwd, './ts/**/*')); startDirectory = 'ts'; } if (plugins.smartfile.fs.isDirectory(plugins.path.join(paths.cwd, './ts_web'))) { data.include.push(plugins.path.join(paths.cwd, './ts_web/**/*')); if (!startDirectory) { startDirectory = 'ts_web'; } } await plugins.smartfile.memory.toFs(JSON.stringify(data), paths.tsconfigFile); let targetDir = paths.publicDir; if (options?.publicSubdir) { targetDir = plugins.path.join(targetDir, options.publicSubdir); } await this.smartshellInstance.exec( `typedoc --tsconfig ${paths.tsconfigFile} --out ${targetDir} ${startDirectory}/index.ts`, ); plugins.smartfile.fs.remove(paths.tsconfigFile); } }