react-native-navigation的迁移库

ReflectionsReader.ts 796B

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