@microsoft/api-extractor
Version:
Validatation, documentation, and auditing for the exported API of a TypeScript package
74 lines (72 loc) • 2.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Allowed Token types.
*/
var TokenType;
(function (TokenType) {
/**
* A Token that contains only text.
*/
TokenType[TokenType["Text"] = 0] = "Text";
/**
* A Token that specifies a tag.
* Example: \@link, \@internal, etc.
*/
TokenType[TokenType["Tag"] = 1] = "Tag";
/**
* This is a specific kind of Tag that is important to
* distinguish because it contains additional parameters.
*
* Example:
* \{@link http://microosft.com | microsoft home \}
* \{@inheritdoc @ microsoft/sp-core-library:Guid.newGuid \}
*/
TokenType[TokenType["Inline"] = 2] = "Inline";
})(TokenType = exports.TokenType || (exports.TokenType = {}));
/**
* A structured object created from a doc comment string within a JSDoc comment block.
*/
var Token = (function () {
function Token(type, tag, text) {
this._type = type;
this._tag = tag ? tag : '';
this._text = text ? this._unescape(text) : '';
return this;
}
/**
* Determines if the type is not what we expect.
*/
Token.prototype.requireType = function (type) {
if (this._type !== type) {
throw new Error("Encountered a token of type \"" + this._type + "\" when expecting \"" + type + "\"");
}
};
Object.defineProperty(Token.prototype, "type", {
get: function () {
return this._type;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Token.prototype, "tag", {
get: function () {
return this._tag;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Token.prototype, "text", {
get: function () {
return this._text;
},
enumerable: true,
configurable: true
});
Token.prototype._unescape = function (text) {
return text.replace('\\@', '@').replace('\\{', '{').replace('\\\\', '\\').replace('\\}', '}');
};
return Token;
}());
exports.default = Token;
//# sourceMappingURL=Token.js.map