UNPKG

3.88 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 { DocNode, DocNodeKind } from './DocNode';
15import { DocExcerpt, ExcerptKind } from './DocExcerpt';
16import { StringBuilder } from '../emitters/StringBuilder';
17/**
18 * Represents an HTML end tag. Example: `</a>`
19 */
20var DocHtmlEndTag = /** @class */ (function (_super) {
21 __extends(DocHtmlEndTag, _super);
22 /**
23 * Don't call this directly. Instead use {@link TSDocParser}
24 * @internal
25 */
26 function DocHtmlEndTag(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.HtmlEndTag_OpeningDelimiter,
32 content: parameters.openingDelimiterExcerpt
33 });
34 _this._nameExcerpt = new DocExcerpt({
35 configuration: _this.configuration,
36 excerptKind: ExcerptKind.HtmlEndTag_Name,
37 content: parameters.nameExcerpt
38 });
39 if (parameters.spacingAfterNameExcerpt) {
40 _this._spacingAfterNameExcerpt = new DocExcerpt({
41 configuration: _this.configuration,
42 excerptKind: ExcerptKind.Spacing,
43 content: parameters.spacingAfterNameExcerpt
44 });
45 }
46 _this._closingDelimiterExcerpt = new DocExcerpt({
47 configuration: _this.configuration,
48 excerptKind: ExcerptKind.HtmlEndTag_ClosingDelimiter,
49 content: parameters.closingDelimiterExcerpt
50 });
51 }
52 else {
53 _this._name = parameters.name;
54 }
55 return _this;
56 }
57 Object.defineProperty(DocHtmlEndTag.prototype, "kind", {
58 /** @override */
59 get: function () {
60 return DocNodeKind.HtmlEndTag;
61 },
62 enumerable: false,
63 configurable: true
64 });
65 Object.defineProperty(DocHtmlEndTag.prototype, "name", {
66 /**
67 * The HTML element name.
68 */
69 get: function () {
70 if (this._name === undefined) {
71 this._name = this._nameExcerpt.content.toString();
72 }
73 return this._name;
74 },
75 enumerable: false,
76 configurable: true
77 });
78 /**
79 * Generates the HTML for this tag.
80 */
81 DocHtmlEndTag.prototype.emitAsHtml = function () {
82 // NOTE: Here we're assuming that the TSDoc representation for a tag is also a valid HTML expression.
83 var stringBuilder = new StringBuilder();
84 // eslint-disable-next-line @typescript-eslint/no-use-before-define
85 var emitter = new TSDocEmitter();
86 emitter.renderHtmlTag(stringBuilder, this);
87 return stringBuilder.toString();
88 };
89 /** @override */
90 DocHtmlEndTag.prototype.onGetChildNodes = function () {
91 return [
92 this._openingDelimiterExcerpt,
93 this._nameExcerpt,
94 this._spacingAfterNameExcerpt,
95 this._closingDelimiterExcerpt
96 ];
97 };
98 return DocHtmlEndTag;
99}(DocNode));
100export { DocHtmlEndTag };
101// Circular reference
102import { TSDocEmitter } from '../emitters/TSDocEmitter';
103//# sourceMappingURL=DocHtmlEndTag.js.map
\No newline at end of file