UNPKG

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