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C,IAAI,CAAC,IAAI,CAAC,CAAC;aACpB;QACL,CAAC;QAED,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACtB,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACjB,CAAC;IAKM,QAAQ;QACX,OAAO;YACH,EAAE;YACF,UAAU,GAAG,aAAW,CAAC,OAAO;YAChC,mBAAmB,GAAG,IAAI,CAAC,oBAAoB,EAAE,GAAG,QAAQ,GAAG,IAAI,CAAC,iBAAiB,EAAE;YACvF,EAAE;SACL,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;CACJ,CAAA;AA9MU,mBAAO,GAAG,eAAe,CAAC;AAnBjC;IANC,kBAAM,CAAC;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,6DAA6D;QACnE,YAAY,EAAE,SAAS;QACvB,IAAI,EAAE,2BAAa,CAAC,KAAK;KAC5B,CAAC;+CAC6B;AAO/B;IALC,kBAAM,CAAC;QACJ,IAAI,EAAE,sBAAsB;QAC5B,IAAI,EAAE,0FAA0F;QAChG,IAAI,EAAE,2BAAa,CAAC,OAAO;KAC9B,CAAC;yDAC6B;AAO/B;IALC,kBAAM,CAAC;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,2DAA2D;QACjE,IAAI,EAAE,2BAAa,CAAC,KAAK;KAC5B,CAAC;4CACsB;AA7Cf,WAAW;IADvB,qBAAS,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;GACtC,WAAW,CAgQvB;AAhQY,kCAAW","sourcesContent":["/**\n * The TypeDoc main module and namespace.\n *\n * The [[Application]] class holds the core logic of the cli application. All code related\n * to resolving reflections is stored in [[TypeDoc.Factories]], the actual data models can be found\n * in [[TypeDoc.Models]] and the final rendering is defined in [[TypeDoc.Output]].\n */\n\nimport * as Path from 'path';\nimport * as FS from 'fs';\nimport * as typescript from 'typescript';\n\nimport { Converter } from './converter/index';\nimport { Renderer } from './output/renderer';\nimport { Serializer } from './serialization';\nimport { ProjectReflection } from './models/index';\nimport { Logger, ConsoleLogger, CallbackLogger, PluginHost, writeFile } from './utils/index';\nimport { createMinimatch } from './utils/paths';\n\nimport {\n AbstractComponent,\n ChildableComponent,\n Component,\n Option,\n DUMMY_APPLICATION_OWNER\n} from './utils/component';\nimport { Options, OptionsReadMode, OptionsReadResult } from './utils/options/index';\nimport { ParameterType } from './utils/options/declaration';\n\n/**\n * The default TypeDoc main application class.\n *\n * This class holds the two main components of TypeDoc, the [[Dispatcher]] and\n * the [[Renderer]]. When running TypeDoc, first the [[Dispatcher]] is invoked which\n * generates a [[ProjectReflection]] from the passed in source files. The\n * [[ProjectReflection]] is a hierarchical model representation of the TypeScript\n * project. Afterwards the model is passed to the [[Renderer]] which uses an instance\n * of [[BaseTheme]] to generate the final documentation.\n *\n * Both the [[Dispatcher]] and the [[Renderer]] are subclasses of the [[EventDispatcher]]\n * and emit a series of events while processing the project. Subscribe to these Events\n * to control the application flow or alter the output.\n */\n@Component({ name: 'application', internal: true })\nexport class Application extends ChildableComponent<Application, AbstractComponent<Application>> {\n options: Options;\n\n /**\n * The converter used to create the declaration reflections.\n */\n converter: Converter;\n\n /**\n * The renderer used to generate the documentation output.\n */\n renderer: Renderer;\n\n /**\n * The serializer used to generate JSON output.\n */\n serializer: Serializer;\n\n /**\n * The logger that should be used to output messages.\n */\n logger: Logger;\n\n plugins: PluginHost;\n\n @Option({\n name: 'logger',\n help: \"Specify the logger that should be used, 'none' or 'console'\",\n defaultValue: 'console',\n type: ParameterType.Mixed\n })\n loggerType!: string | Function;\n\n @Option({\n name: 'ignoreCompilerErrors',\n help: 'Should TypeDoc generate documentation pages even after the compiler has returned errors?',\n type: ParameterType.Boolean\n })\n ignoreCompilerErrors!: boolean;\n\n @Option({\n name: 'exclude',\n help: 'Define patterns for excluded files when specifying paths.',\n type: ParameterType.Array\n })\n exclude!: Array<string>;\n\n /**\n * The version number of TypeDoc.\n */\n static VERSION = '{{ VERSION }}';\n\n /**\n * Create a new TypeDoc application instance.\n *\n * @param options An object containing the options that should be used.\n */\n constructor(options?: Object) {\n super(DUMMY_APPLICATION_OWNER);\n\n this.logger = new ConsoleLogger();\n this.converter = this.addComponent<Converter>('converter', Converter);\n this.serializer = this.addComponent<Serializer>('serializer', Serializer);\n this.renderer = this.addComponent<Renderer>('renderer', Renderer);\n this.plugins = this.addComponent('plugins', PluginHost);\n this.options = this.addComponent('options', Options);\n\n this.bootstrap(options);\n }\n\n /**\n * Initialize TypeDoc with the given options object.\n *\n * @param options The desired options to set.\n */\n protected bootstrap(options?: Object): OptionsReadResult {\n this.options.read(options, OptionsReadMode.Prefetch);\n\n const logger = this.loggerType;\n if (typeof logger === 'function') {\n this.logger = new CallbackLogger(<any> logger);\n } else if (logger === 'none') {\n this.logger = new Logger();\n }\n\n this.plugins.load();\n return this.options.read(this.options.getRawValues(), OptionsReadMode.Fetch);\n }\n\n /**\n * Return the application / root component instance.\n */\n get application(): Application {\n return this;\n }\n\n get isCLI(): boolean {\n return false;\n }\n\n /**\n * Return the path to the TypeScript compiler.\n */\n public getTypeScriptPath(): string {\n return Path.dirname(require.resolve('typescript'));\n }\n\n public getTypeScriptVersion(): string {\n const tsPath = this.getTypeScriptPath();\n const json = JSON.parse(FS.readFileSync(Path.join(tsPath, '..', 'package.json'), 'utf8'));\n return json.version;\n }\n\n /**\n * Run the converter for the given set of files and return the generated reflections.\n *\n * @param src A list of source that should be compiled and converted.\n * @returns An instance of ProjectReflection on success, undefined otherwise.\n */\n public convert(src: string[]): ProjectReflection | undefined {\n this.logger.writeln(\n 'Using TypeScript %s from %s',\n this.getTypeScriptVersion(),\n this.getTypeScriptPath()\n );\n\n const result = this.converter.convert(src);\n if (result.errors && result.errors.length) {\n this.logger.diagnostics(result.errors);\n if (this.ignoreCompilerErrors) {\n this.logger.resetErrors();\n return result.project;\n } else {\n return;\n }\n } else {\n return result.project;\n }\n }\n\n /**\n * @param src A list of source files whose documentation should be generated.\n */\n public generateDocs(src: string[], out: string): boolean;\n\n /**\n * @param project The project the documentation should be generated for.\n */\n public generateDocs(project: ProjectReflection, out: string): boolean;\n\n /**\n * Run the documentation generator for the given set of files.\n *\n * @param out The path the documentation should be written to.\n * @returns TRUE if the documentation could be generated successfully, otherwise FALSE.\n */\n public generateDocs(input: ProjectReflection | string[], out: string): boolean {\n const project = input instanceof ProjectReflection ? input : this.convert(input);\n if (!project) {\n return false;\n }\n\n out = Path.resolve(out);\n this.renderer.render(project, out);\n if (this.logger.hasErrors()) {\n this.logger.error('Documentation could not be generated due to the errors above.');\n } else {\n this.logger.success('Documentation generated at %s', out);\n }\n\n return true;\n }\n\n /**\n * @param src A list of source that should be compiled and converted.\n */\n public generateJson(src: string[], out: string): boolean;\n\n /**\n * @param project The project that should be converted.\n */\n public generateJson(project: ProjectReflection, out: string): boolean;\n\n /**\n * Run the converter for the given set of files and write the reflections to a json file.\n *\n * @param out The path and file name of the target file.\n * @returns TRUE if the json file could be written successfully, otherwise FALSE.\n */\n public generateJson(input: ProjectReflection | string[], out: string): boolean {\n const project = input instanceof ProjectReflection ? input : this.convert(input);\n if (!project) {\n return false;\n }\n\n out = Path.resolve(out);\n const eventData = { outputDirectory: Path.dirname(out), outputFile: Path.basename(out) };\n const ser = this.serializer.projectToObject(project, { begin: eventData, end: eventData });\n writeFile(out, JSON.stringify(ser, null, '\\t'), false);\n this.logger.success('JSON written to %s', out);\n\n return true;\n }\n\n /**\n * Expand a list of input files.\n *\n * Searches for directories in the input files list and replaces them with a\n * listing of all TypeScript files within them. One may use the ```--exclude``` option\n * to filter out files with a pattern.\n *\n * @param inputFiles The list of files that should be expanded.\n * @returns The list of input files with expanded directories.\n */\n public expandInputFiles(inputFiles: string[] = []): string[] {\n let files: string[] = [];\n\n const exclude = this.exclude ? createMinimatch(this.exclude) : [];\n\n function isExcluded(fileName: string): boolean {\n return exclude.some(mm => mm.match(fileName));\n }\n\n const supportedFileRegex = this.options.getCompilerOptions().allowJs ? /\\.[tj]sx?$/ : /\\.tsx?$/;\n function add(file: string) {\n if (isExcluded(file.replace(/\\\\/g, '/'))) {\n return;\n }\n\n if (FS.statSync(file).isDirectory()) {\n FS.readdirSync(file).forEach(next => {\n add(Path.join(file, next));\n });\n } else if (supportedFileRegex.test(file)) {\n files.push(file);\n }\n }\n\n inputFiles.forEach(file => {\n add(Path.resolve(file));\n });\n\n return files;\n }\n\n /**\n * Print the version number.\n */\n public toString() {\n return [\n '',\n 'TypeDoc ' + Application.VERSION,\n 'Using TypeScript ' + this.getTypeScriptVersion() + ' from ' + this.getTypeScriptPath(),\n ''\n ].join(typescript.sys.newLine);\n }\n}\n"]} |