Skip to content

Commit 8861bdd

Browse files
committed
Added external json loading test file
1 parent 3f27756 commit 8861bdd

3 files changed

Lines changed: 66 additions & 21 deletions

File tree

‎api-extractor/src/generators/test/ApiJsonGenerator.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ describe('ApiJsonGenerator tests', function (): void {
3737
errorHandler: testErrorHandler
3838
});
3939

40-
// This file is in lib/generators/tests/, we need to be in /lib
41-
extractor.loadExternalPackages(path.join(__dirname, '/../../external-api-json'));
40+
extractor.loadExternalPackages('./testInputs/external-api-json');
4241
extractor.analyze({
4342
entryPointFile: path.join(inputFolder, 'index.ts')
4443
});
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"kind": "package",
3+
"exports": {
4+
"ForEachable": {
5+
"kind": "interface",
6+
"extends": "",
7+
"implements": "",
8+
"typeParameters": [
9+
"T"
10+
],
11+
"deprecatedMessage": [],
12+
"summary": [
13+
{
14+
"kind": "textDocElement",
15+
"value": "this summary description has been added manually. It does not actually exist in the json documentation but it was added to demonstate the external packages loader is working."
16+
}
17+
],
18+
"remarks": [],
19+
"isBeta": false,
20+
"members": {
21+
"forEach": {
22+
"kind": "method",
23+
"signature": "forEach(callbackfn: (value: T) => void): void;",
24+
"accessModifier": "",
25+
"isOptional": false,
26+
"isStatic": false,
27+
"returnValue": {
28+
"type": "void",
29+
"description": []
30+
},
31+
"parameters": {},
32+
"deprecatedMessage": [],
33+
"summary": [],
34+
"remarks": [],
35+
"isBeta": false
36+
}
37+
}
38+
}
39+
}
40+
}

‎common/reviews/api/api-extractor.api.ts‎

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,9 @@
1-
class Analyzer {
2-
// (undocumented)
3-
constructor(errorHandler?: ApiErrorHandler);
4-
public analyze(options: IApiAnalyzerOptions): void;
5-
public static defaultErrorHandler(message: string, fileName: string, lineNumber: number): void;
6-
public docItemLoader: DocItemLoader;
7-
// (undocumented)
8-
public errorHandler: ApiErrorHandler;
9-
// (undocumented)
10-
public package: ApiPackage;
11-
public reportError(message: string, sourceFile: ts.SourceFile, start: number): void;
12-
// (undocumented)
13-
public typeChecker: ts.TypeChecker;
14-
}
15-
161
class ApiFileGenerator extends ApiItemVisitor {
172
// (undocumented)
183
protected _indentedWriter: IndentedWriter;
194
public static areEquivalentApiFileContents(actualFileContent: string, expectedFileContent: string): boolean;
205
// (undocumented)
21-
public generateApiFileContent(analyzer: Analyzer): string;
6+
public generateApiFileContent(extractor: Extractor): string;
227
// (undocumented)
238
protected visitApiEnum(apiEnum: ApiEnum): void;
249
// (undocumented)
@@ -33,7 +18,7 @@ class ApiFileGenerator extends ApiItemVisitor {
3318
protected visitApiParam(apiParam: ApiParameter): void;
3419
// (undocumented)
3520
protected visitApiStructuredType(apiStructuredType: ApiStructuredType): void;
36-
public writeApiFile(reportFilename: string, analyzer: Analyzer): void;
21+
public writeApiFile(reportFilename: string, extractor: Extractor): void;
3722
}
3823

3924
class ApiJsonGenerator extends ApiItemVisitor {
@@ -60,17 +45,38 @@ class ApiJsonGenerator extends ApiItemVisitor {
6045
// (undocumented)
6146
protected visitApiStructuredType(apiStructuredType: ApiStructuredType, refObject?: Object): void;
6247
// (undocumented)
63-
public writeJsonFile(reportFilename: string, analyzer: Analyzer): void;
48+
public writeJsonFile(reportFilename: string, extractor: Extractor): void;
6449
}
6550

6651
class ExternalApiHelper {
6752
public static generateApiJson(rootDir: string, libFolder: string, externalPackageFilePath: string): void;
6853
}
6954

55+
class Extractor {
56+
// (undocumented)
57+
constructor(options: IExtractorOptions);
58+
public analyze(options: IApiAnalyzerOptions): void;
59+
public static defaultErrorHandler(message: string, fileName: string, lineNumber: number): void;
60+
public docItemLoader: DocItemLoader;
61+
// (undocumented)
62+
public errorHandler: ApiErrorHandler;
63+
public loadExternalPackages(externalJsonCollectionPath: string): void;
64+
// (undocumented)
65+
public package: ApiPackage;
66+
public reportError(message: string, sourceFile: ts.SourceFile, start: number): void;
67+
// (undocumented)
68+
public typeChecker: ts.TypeChecker;
69+
}
70+
7071
interface IApiAnalyzerOptions {
71-
compilerOptions: ts.CompilerOptions;
7272
entryPointFile: string;
7373
otherFiles?: string[];
7474
}
7575

76+
interface IExtractorOptions {
77+
compilerOptions: ts.CompilerOptions;
78+
// (undocumented)
79+
errorHandler?: ApiErrorHandler;
80+
}
81+
7682
// WARNING: Unsupported export: ApiErrorHandler

0 commit comments

Comments
 (0)