UNPKG

3.5 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.DocInlineTag = void 0;
17var DocNode_1 = require("./DocNode");
18var DocExcerpt_1 = require("./DocExcerpt");
19var DocInlineTagBase_1 = require("./DocInlineTagBase");
20/**
21 * Represents a generic TSDoc inline tag, including custom tags.
22 *
23 * @remarks
24 * NOTE: Certain tags such as `{@link}` and `{@inheritDoc}` have specialized structures and parser rules,
25 * and thus are represented using {@link DocLinkTag} or {@link DocInheritDocTag} instead. However, if the
26 * specialized parser rule encounters a syntax error, but the outer framing is correct, then the parser constructs
27 * a generic `DocInlineTag` instead of `DocErrorText`. This means, for example, that it is possible sometimes for
28 * `DocInlineTag.tagName` to be `"@link"`.
29 */
30var DocInlineTag = /** @class */ (function (_super) {
31 __extends(DocInlineTag, _super);
32 /**
33 * Don't call this directly. Instead use {@link TSDocParser}
34 * @internal
35 */
36 function DocInlineTag(parameters) {
37 var _this = _super.call(this, parameters) || this;
38 if (DocNode_1.DocNode.isParsedParameters(parameters)) {
39 if (parameters.tagContentExcerpt) {
40 _this._tagContentExcerpt = new DocExcerpt_1.DocExcerpt({
41 configuration: _this.configuration,
42 excerptKind: DocExcerpt_1.ExcerptKind.InlineTag_TagContent,
43 content: parameters.tagContentExcerpt
44 });
45 }
46 }
47 else {
48 _this._tagContent = parameters.tagContent;
49 }
50 return _this;
51 }
52 Object.defineProperty(DocInlineTag.prototype, "kind", {
53 /** @override */
54 get: function () {
55 return DocNode_1.DocNodeKind.InlineTag;
56 },
57 enumerable: false,
58 configurable: true
59 });
60 Object.defineProperty(DocInlineTag.prototype, "tagContent", {
61 /**
62 * The tag content.
63 * @remarks
64 * For example, if the tag is `{@myTag x=12.34 y=56.78 }` then the tag content
65 * would be `x=12.34 y=56.78 `, including the trailing space but not the leading space.
66 */
67 get: function () {
68 if (this._tagContent === undefined) {
69 if (this._tagContentExcerpt) {
70 this._tagContent = this._tagContentExcerpt.content.toString();
71 }
72 else {
73 return '';
74 }
75 }
76 return this._tagContent;
77 },
78 enumerable: false,
79 configurable: true
80 });
81 /** @override */
82 DocInlineTag.prototype.getChildNodesForContent = function () {
83 // abstract
84 return [this._tagContentExcerpt];
85 };
86 return DocInlineTag;
87}(DocInlineTagBase_1.DocInlineTagBase));
88exports.DocInlineTag = DocInlineTag;
89//# sourceMappingURL=DocInlineTag.js.map
\No newline at end of file