@microsoft/api-extractor
Version:
Validate, document, and review the exported API for a TypeScript library
67 lines • 2.28 kB
JavaScript
;
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
const node_core_library_1 = require("@microsoft/node-core-library");
/**
* {@inheritdoc IApiDefinitionReferenceParts}
*/
class ApiDefinitionReference {
/**
* Creates an ApiDefinitionReference instance given strings that symbolize the public
* properties of ApiDefinitionReference.
*/
static createFromParts(parts) {
return new ApiDefinitionReference(parts);
}
/**
* Stringifies the ApiDefinitionReferenceOptions up and including the
* scope and package name.
*
* Example output: '@microsoft/Utilities'
*/
toScopePackageString() {
if (!this.packageName) {
return '';
}
return node_core_library_1.PackageName.combineParts(this.scopeName, this.packageName);
}
/**
* Stringifies the ApiDefinitionReferenceOptions up and including the
* scope, package and export name.
*
* Example output: '@microsoft/Utilities.Parse'
*/
toExportString() {
let result = this.toScopePackageString();
if (result) {
result += '#';
}
return result + `${this.exportName}`;
}
/**
* Stringifies the ApiDefinitionReferenceOptions up and including the
* scope, package, export and member name.
*
* Example output: '@microsoft/Utilities#Parse.parseJsonToString'
*/
toMemberString() {
return this.toExportString() + `.${this.memberName}`;
}
toApiItemReference() {
return {
scopeName: this.scopeName,
packageName: this.packageName,
exportName: this.exportName,
memberName: this.memberName
};
}
constructor(parts) {
this.scopeName = parts.scopeName;
this.packageName = parts.packageName;
this.exportName = parts.exportName;
this.memberName = parts.memberName;
}
}
exports.ApiDefinitionReference = ApiDefinitionReference;
//# sourceMappingURL=ApiDefinitionReference.js.map