react-native-navigation的迁移库

ReflectionsReader.ts 922B

123456789101112131415161718192021222324252627282930
  1. import * as Typedoc from 'typedoc';
  2. import { OptionsReadMode } from 'typedoc/dist/lib/utils/options';
  3. import * as fs from 'fs';
  4. const OPTIONS = {
  5. excludeExternals: true,
  6. excludePrivate: true,
  7. includeDeclarations: true,
  8. mode: 'modules',
  9. module: 'commonjs',
  10. readme: 'none',
  11. target: 'ES6'
  12. };
  13. export class ReflectionsReader {
  14. private typedocApp: Typedoc.Application;
  15. constructor(tsconfigPath) {
  16. const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath).toString());
  17. this.typedocApp = new Typedoc.Application({ ...OPTIONS, ...tsconfig.compilerOptions });
  18. }
  19. public read(rootPath: string): Typedoc.ProjectReflection {
  20. const expandedFiles = this.typedocApp.expandInputFiles([rootPath]);
  21. const projectReflection = this.typedocApp.convert(expandedFiles);
  22. // console.log(JSON.stringify(this.typedocApp.serializer.projectToObject(projectReflection)));
  23. return projectReflection;
  24. }
  25. }