UNPKG

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