UNPKG

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