react-native-navigation的迁移库

ReflectionsReader.ts 958B

1234567891011121314151617181920212223242526272829
  1. import * as Typedoc from 'typedoc';
  2. const OPTIONS = {
  3. excludeExternals: true,
  4. excludePrivate: true,
  5. includeDeclarations: true,
  6. mode: 'modules',
  7. module: 'commonjs',
  8. readme: 'none',
  9. target: 'ES6'
  10. };
  11. export class ReflectionsReader {
  12. private typedocApp: Typedoc.Application;
  13. constructor(tsconfig) {
  14. this.typedocApp = new Typedoc.Application({ ...OPTIONS, ...tsconfig.compilerOptions });
  15. }
  16. public read(modulePath: string): Typedoc.DeclarationReflection {
  17. const expandedFiles = this.typedocApp.expandInputFiles([modulePath]);
  18. const projectReflection = this.typedocApp.convert(expandedFiles);
  19. // console.log(JSON.stringify(this.typedocApp.serializer.projectToObject(projectReflection)));
  20. const externalModule = projectReflection.getChildrenByKind(Typedoc.ReflectionKind.ExternalModule)[0];
  21. const classReflection = externalModule.getChildrenByKind(Typedoc.ReflectionKind.Class)[0];
  22. return classReflection;
  23. }
  24. }