File tree Expand file tree Collapse file tree
gulp-core-build-typescript/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44import * as ts from 'typescript' ;
55import * as os from 'os' ;
6- import * as path from 'path' ;
76import Extractor from './Extractor' ;
87import ApiFileGenerator from './generators/ApiFileGenerator' ;
98import ApiJsonGenerator from './generators/ApiJsonGenerator' ;
@@ -27,7 +26,7 @@ const extractor: Extractor = new Extractor( {
2726 }
2827} ) ;
2928
30- extractor . loadExternalPackages ( path . join ( __dirname , '/ external-api-json') ) ;
29+ extractor . loadExternalPackages ( './testInputs/ external-api-json') ;
3130
3231extractor . analyze ( { entryPointFile : './testInputs/example2/index.ts' ,
3332 otherFiles : [ ] } ) ;
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ export default class DocItemLoader {
122122 */
123123 public loadPackageIntoCache ( packageJsonFilePath : string ) : IDocPackage {
124124 if ( ! fsx . existsSync ( path . join ( packageJsonFilePath ) ) ) {
125- return undefined ;
125+ throw new Error ( `External json package file does not exist: ${ packageJsonFilePath } ` ) ;
126126 }
127127
128128 const apiPackage : IDocPackage = JsonFile . loadJsonFile ( packageJsonFilePath ) as IDocPackage ;
Original file line number Diff line number Diff line change @@ -26,11 +26,11 @@ export interface IExtractorOptions {
2626/**
2727 * Options for Extractor.analyze()
2828 */
29- export interface IApiAnalyzerOptions {
29+ export interface IExtractorAnalyzeOptions {
3030 /**
3131 * The entry point for the project. This should correspond to the "main" field
3232 * from NPM's package.json file. If it is a relative path, it will be relative to
33- * the project folder described by IApiAnalyzerOptions .compilerOptions.
33+ * the project folder described by IExtractorAnalyzeOptions .compilerOptions.
3434 */
3535 entryPointFile : string ;
3636
@@ -76,7 +76,7 @@ export default class Extractor {
7676 /**
7777 * Analyzes the specified project.
7878 */
79- public analyze ( options : IApiAnalyzerOptions ) : void {
79+ public analyze ( options : IExtractorAnalyzeOptions ) : void {
8080 const rootFiles : string [ ] = [ options . entryPointFile ] . concat ( options . otherFiles || [ ] ) ;
8181
8282 const program : ts . Program = ts . createProgram ( rootFiles , this . _compilerOptions ) ;
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ class TestApiDocumentation extends ApiDocumentation {
4242 }
4343}
4444
45+ extractor . loadExternalPackages ( './testInputs/external-api-json' ) ;
4546// Run the analyzer once to be used by unit tests
4647extractor . analyze ( {
4748 entryPointFile : path . join ( inputFolder , 'index.ts' )
Original file line number Diff line number Diff line change 55 */
66declare const packageDescription : void ;
77
8- export { default as Extractor , IExtractorOptions , IApiAnalyzerOptions , ApiErrorHandler } from './Extractor' ;
8+ export { default as Extractor , IExtractorOptions , IExtractorAnalyzeOptions , ApiErrorHandler } from './Extractor' ;
99export { default as ApiFileGenerator } from './generators/ApiFileGenerator' ;
1010export { default as ApiJsonGenerator } from './generators/ApiJsonGenerator' ;
1111export { default as ExternalApiHelper } from './ExternalApiHelper' ;
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ class TestApiDocumentation extends ApiDocumentation {
5050 }
5151}
5252
53+ extractor . loadExternalPackages ( './testInputs/external-api-json' ) ;
5354// Run the analyze method once to be used by unit tests
5455extractor . analyze ( {
5556 entryPointFile : path . join ( inputFolder , 'index.ts' )
Original file line number Diff line number Diff line change 11/// <reference types="mocha" />
22
3- import { assert } from 'chai' ;
43import { IDocItem } from '../IDocItem' ;
54import DocItemLoader from '../DocItemLoader' ;
65import TestFileComparer from '../TestFileComparer' ;
@@ -29,18 +28,5 @@ describe('DocItemLoader tests', function (): void {
2928 './testInputs/inheritedDoc-output.json'
3029 ) ;
3130 } ) ;
32-
33- it ( 'Should not raise error without scope and not found' , ( ) : void => {
34- const apiDefRef : IApiDefinitionReference = {
35- scopeName : '' ,
36- packageName : 'sp-core-libarary' ,
37- exportName : 'DisplayMode' ,
38- memberName : ''
39- } ;
40- const docItemLoader : DocItemLoader = new DocItemLoader ( './testInputs/example2' ) ;
41-
42- const apiDocItem : IDocItem = docItemLoader . getItem ( apiDefRef ) ;
43- assert . equal ( apiDocItem , undefined ) ;
44- } ) ;
4531 } ) ;
4632} ) ;
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ class ExternalApiHelper {
5555class Extractor {
5656 // (undocumented)
5757 constructor ( options : IExtractorOptions ) ;
58- public analyze ( options : IApiAnalyzerOptions ) : void ;
58+ public analyze ( options : IExtractorAnalyzeOptions ) : void ;
5959 public static defaultErrorHandler ( message : string , fileName : string , lineNumber : number ) : void ;
6060 public docItemLoader : DocItemLoader ;
6161 // (undocumented)
@@ -68,7 +68,7 @@ class Extractor {
6868 public typeChecker : ts . TypeChecker ;
6969}
7070
71- interface IApiAnalyzerOptions {
71+ interface IExtractorAnalyzeOptions {
7272 entryPointFile : string ;
7373 otherFiles ?: string [ ] ;
7474}
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import * as gulpUtil from 'gulp-util';
88import { GulpTask } from '@microsoft/gulp-core-build' ;
99import { Extractor ,
1010 IExtractorOptions ,
11- IApiAnalyzerOptions ,
11+ IExtractorAnalyzeOptions ,
1212 ApiFileGenerator ,
1313 ApiJsonGenerator } from '@microsoft/api-extractor' ;
1414import { TypeScriptConfiguration } from './TypeScriptConfiguration' ;
@@ -103,14 +103,14 @@ export class ApiExtractorTask extends GulpTask<IApiExtractorTaskConfig> {
103103 }
104104 } ;
105105
106- const analyzerOptions : IApiAnalyzerOptions = {
106+ const analyzeOptions : IExtractorAnalyzeOptions = {
107107 entryPointFile,
108108 otherFiles
109109 } as any ; /* tslint:disable-line:no-any */
110110
111111 const extractor : Extractor = new Extractor ( extractorOptions ) ;
112112 extractor . loadExternalPackages ( path . join ( __dirname , 'external-api-json' ) ) ;
113- extractor . analyze ( analyzerOptions ) ;
113+ extractor . analyze ( analyzeOptions ) ;
114114
115115 const jsonGenerator : ApiJsonGenerator = new ApiJsonGenerator ( ) ;
116116 // const jsonContent: string = generator.generateJsonFileContent(analyzer);
You can’t perform that action at this time.
0 commit comments