Socket
Socket
Sign inDemoInstall

@microsoft/api-extractor

Package Overview
Dependencies
Maintainers
2
Versions
486
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/api-extractor - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

lib/Extractor.d.ts

12

CHANGELOG.json

@@ -5,2 +5,14 @@ {

{
"version": "1.1.5",
"tag": "@microsoft/api-extractor_v1.1.5",
"date": "Fri, 27 Jan 2017 20:04:15 GMT",
"comments": {
"patch": [
{
"comment": "Changed name of Analyzer to Extractor, added support for external api json doc loading."
}
]
}
},
{
"version": "1.1.4",

@@ -7,0 +19,0 @@ "tag": "@microsoft/api-extractor_v1.1.4",

9

CHANGELOG.md
# Change Log - @microsoft/api-extractor
This log was last generated on Fri, 27 Jan 2017 02:35:10 GMT and should not be manually modified.
This log was last generated on Fri, 27 Jan 2017 20:04:15 GMT and should not be manually modified.
## 1.1.5
Fri, 27 Jan 2017 20:04:15 GMT
### Patches
- Changed name of Analyzer to Extractor, added support for external api json doc loading.
## 1.1.4

@@ -6,0 +13,0 @@ Fri, 27 Jan 2017 02:35:10 GMT

49

lib/DebugRun.js

@@ -6,31 +6,36 @@ // NOTE: THIS SOURCE FILE IS FOR DEBUGGING PURPOSES ONLY.

var os = require("os");
var Analyzer_1 = require("./Analyzer");
var Extractor_1 = require("./Extractor");
var ApiFileGenerator_1 = require("./generators/ApiFileGenerator");
var ApiJsonGenerator_1 = require("./generators/ApiJsonGenerator");
var analyzer = new Analyzer_1.default(function (message, fileName, lineNumber) {
console.log("ErrorHandler: " + message + os.EOL
+ (" " + fileName + "#" + lineNumber));
var compilerOptions = {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
experimentalDecorators: true,
jsx: ts.JsxEmit.React,
rootDir: './testInputs/example2'
};
var extractor = new Extractor_1.default({
compilerOptions: compilerOptions,
errorHandler: function (message, fileName, lineNumber) {
console.log("ErrorHandler: " + message + os.EOL
+ (" " + fileName + "#" + lineNumber));
}
});
/**
* Debugging inheritdoc expression parser.
* Analyzer on example2 is needed for testing the parser.
*/
analyzer.analyze({
compilerOptions: {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
experimentalDecorators: true,
jsx: ts.JsxEmit.React,
rootDir: './testInputs/example2'
},
entryPointFile: './testInputs/example2/index.ts',
otherFiles: []
});
extractor.loadExternalPackages('./testInputs/external-api-json');
extractor.analyze({ entryPointFile: './testInputs/example2/index.ts',
otherFiles: [] });
var externalPackageApiRef = {
scopeName: '',
packageName: 'es6-collections',
exportName: '',
memberName: ''
};
console.log(extractor.docItemLoader.getPackage(externalPackageApiRef, console.log));
var apiFileGenerator = new ApiFileGenerator_1.default();
apiFileGenerator.writeApiFile('./lib/DebugRun.api.ts', analyzer);
apiFileGenerator.writeApiFile('./lib/DebugRun.api.ts', extractor);
var apiJsonGenerator = new ApiJsonGenerator_1.default();
apiJsonGenerator.writeJsonFile('./lib/DebugRun.json', analyzer);
apiJsonGenerator.writeJsonFile('./lib/DebugRun.json', extractor);
console.log('DebugRun completed.');
//# sourceMappingURL=DebugRun.js.map

@@ -293,3 +293,3 @@ /* tslint:disable:no-bitwise */

// Atempt to locate the apiDefinitionRef
var inheritedDoc = this.docItemLoader.getItem(apiDefinitionRef);
var inheritedDoc = this.docItemLoader.getItem(apiDefinitionRef, this.reportError);
// If no IDocItem found then nothing to inherit

@@ -296,0 +296,0 @@ // But for the time being set the summary to a text object

@@ -22,3 +22,3 @@ "use strict";

var memberOptions = {
analyzer: _this.analyzer,
extractor: _this.extractor,
declaration: memberDeclaration,

@@ -25,0 +25,0 @@ declarationSymbol: memberSymbol,

@@ -31,3 +31,3 @@ "use strict";

_this.params.push(new ApiParameter_1.default({
analyzer: _this.analyzer,
extractor: _this.extractor,
declaration: param,

@@ -34,0 +34,0 @@ declarationSymbol: declarationSymbol,

import * as ts from 'typescript';
import Analyzer from '../Analyzer';
import Extractor from '../Extractor';
import ApiDocumentation from './ApiDocumentation';

@@ -9,5 +9,5 @@ /**

/**
* The associated Analyzer object for this ApiItem
* The associated Extractor object for this ApiItem
*/
analyzer: Analyzer;
extractor: Extractor;
/**

@@ -51,3 +51,3 @@ * The declaration node for the main syntax item that this ApiItem is associated with.

/**
* A list of analyzer warnings that were reported using ApiItem.reportWarning().
* A list of extractor warnings that were reported using ApiItem.reportWarning().
* Whereas an "error" will break the build, a "warning" will merely be tracked in

@@ -65,5 +65,5 @@ * the API file produced by ApiFileGenerator.

/**
* The Analyzer object that acts as the root of the abstract syntax tree that this item belongs to.
* The Extractor object that acts as the root of the abstract syntax tree that this item belongs to.
*/
protected analyzer: Analyzer;
protected extractor: Extractor;
/**

@@ -122,3 +122,3 @@ * Syntax information from the TypeScript Compiler API, corresponding to the place

/**
* Reports an error through the ApiErrorHandler interface that was registered with the Analyzer,
* Reports an error through the ApiErrorHandler interface that was registered with the Extractor,
* adding the filename and line number information for the declaration of this ApiItem.

@@ -125,0 +125,0 @@ */

@@ -19,8 +19,8 @@ /* tslint:disable:no-bitwise */

this.warnings = [];
this.analyzer = options.analyzer;
this.extractor = options.extractor;
this.declarationSymbol = options.declarationSymbol;
this.exportSymbol = options.exportSymbol || this.declarationSymbol;
this.name = this.exportSymbol.name || '???';
this.typeChecker = this.analyzer.typeChecker;
this.documentation = new ApiDocumentation_1.default(this, options.analyzer.docItemLoader, this.reportError);
this.typeChecker = this.extractor.typeChecker;
this.documentation = new ApiDocumentation_1.default(this, options.extractor.docItemLoader, this.reportError);
}

@@ -76,7 +76,7 @@ /**

/**
* Reports an error through the ApiErrorHandler interface that was registered with the Analyzer,
* Reports an error through the ApiErrorHandler interface that was registered with the Extractor,
* adding the filename and line number information for the declaration of this ApiItem.
*/
ApiItem.prototype.reportError = function (message) {
this.analyzer.reportError(message, this._errorNode.getSourceFile(), this._errorNode.getStart());
this.extractor.reportError(message, this._errorNode.getSourceFile(), this._errorNode.getStart());
};

@@ -83,0 +83,0 @@ /**

@@ -58,3 +58,3 @@ "use strict";

var typeLiteralOptions = {
analyzer: _this.analyzer,
extractor: _this.extractor,
declaration: propertyTypeDeclaration,

@@ -61,0 +61,0 @@ declarationSymbol: propertyTypeSymbol,

@@ -31,3 +31,3 @@ "use strict";

_this.params.push(new ApiParameter_1.default({
analyzer: _this.analyzer,
extractor: _this.extractor,
declaration: param,

@@ -34,0 +34,0 @@ declarationSymbol: declarationSymbol,

import * as ts from 'typescript';
import Analyzer from '../Analyzer';
import Extractor from '../Extractor';
import ApiItemContainer from './ApiItemContainer';
/**
* This class is part of the ApiItem abstract syntax tree. It represents the top-level
* exports for an Rush package. This object acts as the root of the Analyzer's tree.
* exports for an Rush package. This object acts as the root of the Extractor's tree.
*/
export default class ApiPackage extends ApiItemContainer {
private static _getOptions(analyzer, rootFile);
constructor(analyzer: Analyzer, rootFile: ts.SourceFile);
private static _getOptions(extractor, rootFile);
constructor(extractor: Extractor, rootFile: ts.SourceFile);
shouldHaveDocumentation(): boolean;
}

@@ -16,8 +16,8 @@ /* tslint:disable:no-bitwise */

* This class is part of the ApiItem abstract syntax tree. It represents the top-level
* exports for an Rush package. This object acts as the root of the Analyzer's tree.
* exports for an Rush package. This object acts as the root of the Extractor's tree.
*/
var ApiPackage = (function (_super) {
__extends(ApiPackage, _super);
function ApiPackage(analyzer, rootFile) {
var _this = _super.call(this, ApiPackage._getOptions(analyzer, rootFile)) || this;
function ApiPackage(extractor, rootFile) {
var _this = _super.call(this, ApiPackage._getOptions(extractor, rootFile)) || this;
var exportSymbols = _this.typeChecker.getExportsOfModule(_this.declarationSymbol);

@@ -35,3 +35,3 @@ if (exportSymbols) {

var options = {
analyzer: _this.analyzer,
extractor: _this.extractor,
declaration: declaration,

@@ -59,3 +59,3 @@ declarationSymbol: followedSymbol,

}
ApiPackage._getOptions = function (analyzer, rootFile) {
ApiPackage._getOptions = function (extractor, rootFile) {
var rootFileSymbol = TypeScriptHelpers_1.default.getSymbolForDeclaration(rootFile);

@@ -77,3 +77,3 @@ var statement;

return {
analyzer: analyzer,
extractor: extractor,
declaration: rootFileSymbol.declarations[0],

@@ -80,0 +80,0 @@ declarationSymbol: rootFileSymbol,

@@ -159,3 +159,3 @@ /* tslint:disable:no-bitwise */

var memberOptions = {
analyzer: this.analyzer,
extractor: this.extractor,
declaration: memberDeclaration,

@@ -162,0 +162,0 @@ declarationSymbol: memberSymbol,

@@ -11,3 +11,3 @@ /// <reference types="mocha" />

var path = require("path");
var Analyzer_1 = require("../../Analyzer");
var Extractor_1 = require("../../Extractor");
var ApiDocumentation_1 = require("../ApiDocumentation");

@@ -19,4 +19,13 @@ /* tslint:disable:no-function-expression - Mocha uses a poorly scoped "this" pointer */

}
var analyzer = new Analyzer_1.default(testErrorHandler);
var inputFolder = './testInputs/example2';
var compilerOptions = {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
rootDir: inputFolder
};
var extractor = new Extractor_1.default({
compilerOptions: compilerOptions,
errorHandler: testErrorHandler
});
var myDocumentedClass;

@@ -29,17 +38,12 @@ /**

function TestApiDocumentation() {
return _super.call(this, myDocumentedClass, analyzer.docItemLoader, function (msg) { return; }) || this;
return _super.call(this, myDocumentedClass, extractor.docItemLoader, function (msg) { return; }) || this;
}
return TestApiDocumentation;
}(ApiDocumentation_1.default));
extractor.loadExternalPackages('./testInputs/external-api-json');
// Run the analyzer once to be used by unit tests
analyzer.analyze({
compilerOptions: {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
rootDir: inputFolder
},
extractor.analyze({
entryPointFile: path.join(inputFolder, 'index.ts')
});
myDocumentedClass = analyzer.package.getSortedMemberItems()
myDocumentedClass = extractor.package.getSortedMemberItems()
.filter(function (apiItem) { return apiItem.name === 'MyDocumentedClass'; })[0];

@@ -46,0 +50,0 @@ describe('ApiDocumentation tests', function () {

@@ -25,4 +25,5 @@ import { IDocItem, IDocPackage } from './IDocItem';

export default class DocItemLoader {
private cache;
private projectFolder;
private _cache;
private _projectFolder;
private _errorHandler;
/**

@@ -39,3 +40,3 @@ * The projectFolder is the top-level folder containing package.json for a project

*/
getItem(apiDefinitionRef: IApiDefinitionReference): IDocItem;
getItem(apiDefinitionRef: IApiDefinitionReference, reportError: (message: string) => void): IDocItem;
/**

@@ -47,3 +48,8 @@ * Attempts to locate and load the IDocPackage object from the project folder's

*/
getPackage(apiDefinitionRef: IApiDefinitionReference): IDocPackage;
getPackage(apiDefinitionRef: IApiDefinitionReference, reportError: (message: string) => void): IDocPackage;
/**
* Loads the API documentation json file and validates that it conforms to our schema. If it does,
* then the json file is saved in the cache and returned.
*/
loadPackageIntoCache(packageJsonFilePath: string): IDocPackage;
}

@@ -22,4 +22,4 @@ "use strict";

}
this.projectFolder = projectFolder;
this.cache = new Map();
this._projectFolder = projectFolder;
this._cache = new Map();
}

@@ -32,8 +32,9 @@ /**

*/
DocItemLoader.prototype.getItem = function (apiDefinitionRef) {
DocItemLoader.prototype.getItem = function (apiDefinitionRef, reportError) {
if (!apiDefinitionRef) {
throw new Error('Expected param to DocItemLoader.getItem() to be defined');
reportError('Expected reference within {@inheritdoc} tag');
return undefined;
}
// Try to load the package given the provided packageName into the cache
var docPackage = this.getPackage(apiDefinitionRef);
var docPackage = this.getPackage(apiDefinitionRef, reportError);
// Check if package was not found

@@ -69,3 +70,3 @@ if (!docPackage) {

*/
DocItemLoader.prototype.getPackage = function (apiDefinitionRef) {
DocItemLoader.prototype.getPackage = function (apiDefinitionRef, reportError) {
var cachePackageName = '';

@@ -80,10 +81,23 @@ // We concatenate the scopeName and packageName in case there are packageName conflicts

// Check if package exists in cache
if (cachePackageName in this.cache) {
return this.cache[cachePackageName];
if (this._cache.has(cachePackageName)) {
return this._cache.get(cachePackageName);
}
if (!apiDefinitionRef.packageName) {
// Local export resolution is currently not supported yet
return;
}
// Doesn't exist in cache, attempt to load the json file
var packageJsonFilePath = path.join(this.projectFolder, 'node_modules', apiDefinitionRef.scopeName, apiDefinitionRef.packageName, "dist/" + apiDefinitionRef.packageName + ".api.json");
var packageJsonFilePath = path.join(this._projectFolder, 'node_modules', apiDefinitionRef.scopeName, apiDefinitionRef.packageName, "dist/" + apiDefinitionRef.packageName + ".api.json");
if (!fsx.existsSync(path.join(packageJsonFilePath))) {
return undefined;
// package not found in node_modules
reportError("@inheritdoc referenced package (\"" + apiDefinitionRef.packageName + "\") not found in node modules.");
return;
}
return this.loadPackageIntoCache(packageJsonFilePath);
};
/**
* Loads the API documentation json file and validates that it conforms to our schema. If it does,
* then the json file is saved in the cache and returned.
*/
DocItemLoader.prototype.loadPackageIntoCache = function (packageJsonFilePath) {
var apiPackage = JsonFile_1.default.loadJsonFile(packageJsonFilePath);

@@ -98,4 +112,4 @@ // Validate that the output conforms to our JSON schema

});
// JSON schema has been found and validated
this.cache[cachePackageName] = apiPackage;
var packageName = path.basename(packageJsonFilePath).split('.').shift();
this._cache.set(packageName, apiPackage);
return apiPackage;

@@ -102,0 +116,0 @@ };

@@ -16,2 +16,17 @@ {

"exports": {
"IExternalPackageLookup": {
"kind": "interface",
"extends": "",
"implements": "",
"typeParameters": [],
"deprecatedMessage": [],
"summary": [
{
"kind": "textDocElement",
"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."
}
],
"remarks": [],
"isBeta": false
},
"inheritCorrectlyButNotFound": {

@@ -18,0 +33,0 @@ "kind": "enum",

@@ -6,3 +6,3 @@ "use strict";

var fs = require("fs");
var Analyzer_1 = require("./Analyzer");
var Extractor_1 = require("./Extractor");
var ApiJsonGenerator_1 = require("./generators/ApiJsonGenerator");

@@ -28,5 +28,16 @@ /**

ExternalApiHelper.generateApiJson = function (rootDir, libFolder, externalPackageFilePath) {
var analyzer = new Analyzer_1.default(function (message, fileName, lineNumber) {
console.log("TypeScript error: " + message + os.EOL
+ (" " + fileName + "#" + lineNumber));
var compilerOptions = {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
experimentalDecorators: true,
jsx: ts.JsxEmit.React,
rootDir: rootDir
};
var extractor = new Extractor_1.default({
compilerOptions: compilerOptions,
errorHandler: function (message, fileName, lineNumber) {
console.log("TypeScript error: " + message + os.EOL
+ (" " + fileName + "#" + lineNumber));
}
});

@@ -44,11 +55,3 @@ var outputPath = path.join(rootDir, libFolder);

var entryPointFile = path.join(rootDir, externalPackageFilePath);
analyzer.analyze({
compilerOptions: {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
experimentalDecorators: true,
jsx: ts.JsxEmit.React,
rootDir: rootDir
},
extractor.analyze({
entryPointFile: entryPointFile,

@@ -58,3 +61,3 @@ otherFiles: []

var apiJsonGenerator = new ApiJsonGenerator_1.default();
apiJsonGenerator.writeJsonFile(outputApiJsonFilePath, analyzer);
apiJsonGenerator.writeJsonFile(outputApiJsonFilePath, extractor);
};

@@ -61,0 +64,0 @@ return ExternalApiHelper;

@@ -1,2 +0,2 @@

import Analyzer from '../Analyzer';
import Extractor from '../Extractor';
import ApiStructuredType from '../definitions/ApiStructuredType';

@@ -32,7 +32,8 @@ import ApiEnum from '../definitions/ApiEnum';

* Generates the report and writes it to disk.
*
* @param reportFilename - The output filename
* @param analyzer - An Analyzer object representing the input project.
*/
writeApiFile(reportFilename: string, analyzer: Analyzer): void;
generateApiFileContent(analyzer: Analyzer): string;
writeApiFile(reportFilename: string, extractor: Extractor): void;
generateApiFileContent(extractor: Extractor): string;
protected visitApiStructuredType(apiStructuredType: ApiStructuredType): void;

@@ -39,0 +40,0 @@ protected visitApiEnum(apiEnum: ApiEnum): void;

@@ -44,12 +44,13 @@ "use strict";

* Generates the report and writes it to disk.
*
* @param reportFilename - The output filename
* @param analyzer - An Analyzer object representing the input project.
*/
ApiFileGenerator.prototype.writeApiFile = function (reportFilename, analyzer) {
var fileContent = this.generateApiFileContent(analyzer);
ApiFileGenerator.prototype.writeApiFile = function (reportFilename, extractor) {
var fileContent = this.generateApiFileContent(extractor);
fs.writeFileSync(reportFilename, fileContent);
};
ApiFileGenerator.prototype.generateApiFileContent = function (analyzer) {
ApiFileGenerator.prototype.generateApiFileContent = function (extractor) {
// Normalize to CRLF
this.visit(analyzer.package);
this.visit(extractor.package);
var fileContent = this._indentedWriter.toString().replace(/\r?\n/g, '\r\n');

@@ -56,0 +57,0 @@ return fileContent;

@@ -1,2 +0,2 @@

import Analyzer from '../Analyzer';
import Extractor from '../Extractor';
import ApiStructuredType from '../definitions/ApiStructuredType';

@@ -35,3 +35,3 @@ import ApiEnum from '../definitions/ApiEnum';

protected jsonOutput: Object;
writeJsonFile(reportFilename: string, analyzer: Analyzer): void;
writeJsonFile(reportFilename: string, extractor: Extractor): void;
protected visitApiStructuredType(apiStructuredType: ApiStructuredType, refObject?: Object): void;

@@ -38,0 +38,0 @@ protected visitApiEnum(apiEnum: ApiEnum, refObject?: Object): void;

@@ -37,4 +37,4 @@ "use strict";

}
ApiJsonGenerator.prototype.writeJsonFile = function (reportFilename, analyzer) {
this.visit(analyzer.package, this.jsonOutput);
ApiJsonGenerator.prototype.writeJsonFile = function (reportFilename, extractor) {
this.visit(extractor.package, this.jsonOutput);
// Write the output before validating the schema, so we can debug it

@@ -41,0 +41,0 @@ JsonFile_1.default.saveJsonFile(reportFilename, this.jsonOutput);

@@ -7,3 +7,3 @@ /// <reference types="mocha" />

var path = require("path");
var Analyzer_1 = require("../../Analyzer");
var Extractor_1 = require("../../Extractor");
var ApiFileGenerator_1 = require("../../generators/ApiFileGenerator");

@@ -26,17 +26,20 @@ /* tslint:disable:no-function-expression - Mocha uses a poorly scoped "this" pointer */

it('Example 1', function () {
var analyzer = new Analyzer_1.default(testErrorHandler);
var inputFolder = './testInputs/example1';
var outputFile = './lib/example1-output.ts';
var expectedFile = path.join(inputFolder, 'example1-output.ts');
analyzer.analyze({
compilerOptions: {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
rootDir: inputFolder
},
var compilerOptions = {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
rootDir: inputFolder
};
var extractor = new Extractor_1.default({
compilerOptions: compilerOptions,
errorHandler: testErrorHandler
});
extractor.analyze({
entryPointFile: path.join(inputFolder, 'index.ts')
});
var apiFileGenerator = new ApiFileGenerator_1.default();
apiFileGenerator.writeApiFile(outputFile, analyzer);
apiFileGenerator.writeApiFile(outputFile, extractor);
assertFileMatchesExpected(outputFile, expectedFile);

@@ -43,0 +46,0 @@ /**

@@ -5,3 +5,3 @@ /// <reference types="mocha" />

var path = require("path");
var Analyzer_1 = require("../../Analyzer");
var Extractor_1 = require("../../Extractor");
var ApiJsonGenerator_1 = require("../../generators/ApiJsonGenerator");

@@ -18,17 +18,21 @@ var TestFileComparer_1 = require("../../TestFileComparer");

it('Example 1', function () {
var analyzer = new Analyzer_1.default(testErrorHandler);
var inputFolder = './testInputs/example2';
var outputFile = './lib/example2-output.json';
var expectedFile = path.join(inputFolder, 'example2-output.json');
analyzer.analyze({
compilerOptions: {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
rootDir: inputFolder
},
var compilerOptions = {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
rootDir: inputFolder
};
var extractor = new Extractor_1.default({
compilerOptions: compilerOptions,
errorHandler: testErrorHandler
});
extractor.loadExternalPackages('./testInputs/external-api-json');
extractor.analyze({
entryPointFile: path.join(inputFolder, 'index.ts')
});
var apiJsonGenerator = new ApiJsonGenerator_1.default();
apiJsonGenerator.writeJsonFile(outputFile, analyzer);
apiJsonGenerator.writeJsonFile(outputFile, extractor);
TestFileComparer_1.default.assertFileMatchesExpected(outputFile, expectedFile);

@@ -35,0 +39,0 @@ });

@@ -1,4 +0,4 @@

export { default as Analyzer, IApiAnalyzerOptions, ApiErrorHandler } from './Analyzer';
export { default as Extractor, IExtractorOptions, IExtractorAnalyzeOptions, ApiErrorHandler } from './Extractor';
export { default as ApiFileGenerator } from './generators/ApiFileGenerator';
export { default as ApiJsonGenerator } from './generators/ApiJsonGenerator';
export { default as ExternalApiHelper } from './ExternalApiHelper';
"use strict";
var Analyzer_1 = require("./Analyzer");
exports.Analyzer = Analyzer_1.default;
var Extractor_1 = require("./Extractor");
exports.Extractor = Extractor_1.default;
var ApiFileGenerator_1 = require("./generators/ApiFileGenerator");

@@ -5,0 +5,0 @@ exports.ApiFileGenerator = ApiFileGenerator_1.default;

@@ -15,3 +15,3 @@ /// <reference types="mocha" />

var ApiDocumentation_1 = require("../definitions/ApiDocumentation");
var Analyzer_1 = require("./../Analyzer");
var Extractor_1 = require("./../Extractor");
var Tokenizer_1 = require("./../Tokenizer");

@@ -22,5 +22,14 @@ var capturedErrors = [];

}
var analyzer = new Analyzer_1.default(testErrorHandler);
var inputFolder = './testInputs/example2';
var myDocumentedClass;
var compilerOptions = {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
rootDir: inputFolder
};
var extractor = new Extractor_1.default({
compilerOptions: compilerOptions,
errorHandler: testErrorHandler
});
/**

@@ -32,3 +41,3 @@ * Dummy class wrapping ApiDocumentation to test its protected methods

function TestApiDocumentation() {
return _super.call(this, myDocumentedClass, analyzer.docItemLoader, function (msg) { return; }) || this;
return _super.call(this, myDocumentedClass, extractor.docItemLoader, function (msg) { return; }) || this;
}

@@ -40,13 +49,8 @@ TestApiDocumentation.prototype.parseParam = function (tokenizer) {

}(ApiDocumentation_1.default));
// Run the analyzer once to be used by unit tests
analyzer.analyze({
compilerOptions: {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
rootDir: inputFolder
},
extractor.loadExternalPackages('./testInputs/external-api-json');
// Run the analyze method once to be used by unit tests
extractor.analyze({
entryPointFile: path.join(inputFolder, 'index.ts')
});
myDocumentedClass = analyzer.package.getSortedMemberItems()
myDocumentedClass = extractor.package.getSortedMemberItems()
.filter(function (apiItem) { return apiItem.name === 'MyDocumentedClass'; })[0];

@@ -53,0 +57,0 @@ describe('DocElementParser tests', function () {

/// <reference types="mocha" />
"use strict";
var chai_1 = require("chai");
var DocItemLoader_1 = require("../DocItemLoader");

@@ -20,17 +19,6 @@ var TestFileComparer_1 = require("../TestFileComparer");

/* ts-lint:diasble:no-unused-variable */
var apiDocItem = docItemLoader.getItem(apiDefRef);
var apiDocItem = docItemLoader.getItem(apiDefRef, console.log);
JsonFile_1.default.saveJsonFile('./lib/inheritedDoc-output.json', JSON.stringify(apiDocItem));
TestFileComparer_1.default.assertFileMatchesExpected('./lib/inheritedDoc-output.json', './testInputs/inheritedDoc-output.json');
});
it('Should not raise error without scope and not found', function () {
var apiDefRef = {
scopeName: '',
packageName: 'sp-core-libarary',
exportName: 'DisplayMode',
memberName: ''
};
var docItemLoader = new DocItemLoader_1.default('./testInputs/example2');
var apiDocItem = docItemLoader.getItem(apiDefRef);
chai_1.assert.equal(apiDocItem, undefined);
});
});

@@ -37,0 +25,0 @@ });

@@ -6,19 +6,22 @@ // NOTE: THIS SOURCE FILE IS FOR DEBUGGING PURPOSES ONLY.

var path = require("path");
var Analyzer_1 = require("./Analyzer");
var Extractor_1 = require("./Extractor");
var ApiFileGenerator_1 = require("./generators/ApiFileGenerator");
var analyzer = new Analyzer_1.default();
var inputFolder = './testInputs/example1';
var outputFile = './lib/example1-output.ts';
analyzer.analyze({
compilerOptions: {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
rootDir: inputFolder
},
var compilerOptions = {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
rootDir: inputFolder
};
var extractor = new Extractor_1.default({
compilerOptions: compilerOptions,
errorHandler: console.log
});
extractor.analyze({
entryPointFile: path.join(inputFolder, 'index.ts')
});
var apiFileGenerator = new ApiFileGenerator_1.default();
apiFileGenerator.writeApiFile(outputFile, analyzer);
apiFileGenerator.writeApiFile(outputFile, extractor);
//# sourceMappingURL=TestRun.js.map
{
"name": "@microsoft/api-extractor",
"version": "1.1.4",
"version": "1.1.5",
"description": "Validatation, documentation, and auditing for the exported API of a TypeScript package",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc