UNPKG

3.11 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 };
9 return function (d, b) {
10 extendStatics(d, b);
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13 };
14})();
15Object.defineProperty(exports, "__esModule", { value: true });
16exports.DocCodeSpan = void 0;
17var DocNode_1 = require("./DocNode");
18var DocExcerpt_1 = require("./DocExcerpt");
19/**
20 * Represents CommonMark-style code span, i.e. code surrounded by
21 * backtick characters.
22 */
23var DocCodeSpan = /** @class */ (function (_super) {
24 __extends(DocCodeSpan, _super);
25 /**
26 * Don't call this directly. Instead use {@link TSDocParser}
27 * @internal
28 */
29 function DocCodeSpan(parameters) {
30 var _this = _super.call(this, parameters) || this;
31 if (DocNode_1.DocNode.isParsedParameters(parameters)) {
32 _this._openingDelimiterExcerpt = new DocExcerpt_1.DocExcerpt({
33 configuration: _this.configuration,
34 excerptKind: DocExcerpt_1.ExcerptKind.CodeSpan_OpeningDelimiter,
35 content: parameters.openingDelimiterExcerpt
36 });
37 _this._codeExcerpt = new DocExcerpt_1.DocExcerpt({
38 configuration: _this.configuration,
39 excerptKind: DocExcerpt_1.ExcerptKind.CodeSpan_Code,
40 content: parameters.codeExcerpt
41 });
42 _this._closingDelimiterExcerpt = new DocExcerpt_1.DocExcerpt({
43 configuration: _this.configuration,
44 excerptKind: DocExcerpt_1.ExcerptKind.CodeSpan_ClosingDelimiter,
45 content: parameters.closingDelimiterExcerpt
46 });
47 }
48 else {
49 _this._code = parameters.code;
50 }
51 return _this;
52 }
53 Object.defineProperty(DocCodeSpan.prototype, "kind", {
54 /** @override */
55 get: function () {
56 return DocNode_1.DocNodeKind.CodeSpan;
57 },
58 enumerable: false,
59 configurable: true
60 });
61 Object.defineProperty(DocCodeSpan.prototype, "code", {
62 /**
63 * The text that should be rendered as code, excluding the backtick delimiters.
64 */
65 get: function () {
66 if (this._code === undefined) {
67 this._code = this._codeExcerpt.content.toString();
68 }
69 return this._code;
70 },
71 enumerable: false,
72 configurable: true
73 });
74 /** @override */
75 DocCodeSpan.prototype.onGetChildNodes = function () {
76 return [this._openingDelimiterExcerpt, this._codeExcerpt, this._closingDelimiterExcerpt];
77 };
78 return DocCodeSpan;
79}(DocNode_1.DocNode));
80exports.DocCodeSpan = DocCodeSpan;
81//# sourceMappingURL=DocCodeSpan.js.map
\No newline at end of file