|
3 | 3 |
|
4 | 4 | import * as ts from 'typescript'; |
5 | 5 | import * as os from 'os'; |
6 | | -import Analyzer from './Analyzer'; |
| 6 | +import * as path from 'path'; |
| 7 | +import Extractor from './Extractor'; |
7 | 8 | import ApiFileGenerator from './generators/ApiFileGenerator'; |
8 | 9 | import ApiJsonGenerator from './generators/ApiJsonGenerator'; |
| 10 | +import { IApiDefinitionReference } from './IApiDefinitionReference'; |
9 | 11 |
|
10 | | -const analyzer: Analyzer = new Analyzer( |
11 | | - (message: string, fileName: string, lineNumber: number): void => { |
12 | | - console.log(`ErrorHandler: ${message}` + os.EOL |
13 | | - + ` ${fileName}#${lineNumber}`); |
14 | | - } |
15 | | -); |
16 | | - |
17 | | -/** |
18 | | - * Debugging inheritdoc expression parser. |
19 | | - * Analyzer on example2 is needed for testing the parser. |
20 | | - */ |
21 | | -analyzer.analyze({ |
22 | | - compilerOptions: { |
23 | | - target: ts.ScriptTarget.ES5, |
24 | | - module: ts.ModuleKind.CommonJS, |
25 | | - moduleResolution: ts.ModuleResolutionKind.NodeJs, |
26 | | - experimentalDecorators: true, |
27 | | - jsx: ts.JsxEmit.React, |
28 | | - rootDir: './testInputs/example2' |
29 | | - }, |
30 | | - entryPointFile: './testInputs/example2/index.ts', |
31 | | - otherFiles: [] |
| 12 | +const compilerOptions: ts.CompilerOptions = { |
| 13 | + target: ts.ScriptTarget.ES5, |
| 14 | + module: ts.ModuleKind.CommonJS, |
| 15 | + moduleResolution: ts.ModuleResolutionKind.NodeJs, |
| 16 | + experimentalDecorators: true, |
| 17 | + jsx: ts.JsxEmit.React, |
| 18 | + rootDir: './testInputs/example2' |
| 19 | +}; |
| 20 | + |
| 21 | +const extractor: Extractor = new Extractor( { |
| 22 | + compilerOptions: compilerOptions, |
| 23 | + errorHandler: |
| 24 | + (message: string, fileName: string, lineNumber: number): void => { |
| 25 | + console.log(`ErrorHandler: ${message}` + os.EOL |
| 26 | + + ` ${fileName}#${lineNumber}`); |
| 27 | + } |
32 | 28 | }); |
33 | 29 |
|
| 30 | +extractor.loadExternalPackages(path.join(__dirname, '/external-api-json')); |
| 31 | + |
| 32 | +extractor.analyze({entryPointFile: './testInputs/example2/index.ts', |
| 33 | + otherFiles: []}); |
| 34 | + |
| 35 | +const externalPackageApiRef: IApiDefinitionReference = { |
| 36 | + scopeName: '', |
| 37 | + packageName: 'es6-collections', |
| 38 | + exportName: '', |
| 39 | + memberName: '' |
| 40 | +}; |
| 41 | +console.log(extractor.docItemLoader.getPackage(externalPackageApiRef)); |
| 42 | + |
34 | 43 | const apiFileGenerator: ApiFileGenerator = new ApiFileGenerator(); |
35 | | -apiFileGenerator.writeApiFile('./lib/DebugRun.api.ts', analyzer); |
| 44 | +apiFileGenerator.writeApiFile('./lib/DebugRun.api.ts', extractor); |
36 | 45 |
|
37 | 46 | const apiJsonGenerator: ApiJsonGenerator = new ApiJsonGenerator(); |
38 | | -apiJsonGenerator.writeJsonFile('./lib/DebugRun.json', analyzer); |
| 47 | +apiJsonGenerator.writeJsonFile('./lib/DebugRun.json', extractor); |
39 | 48 |
|
40 | 49 | console.log('DebugRun completed.'); |
0 commit comments