UNPKG

2.83 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.DocNodeContainer = void 0;
17var DocNode_1 = require("./DocNode");
18/**
19 * DocNodeContainer is the base class for DocNode classes that allow arbitrary child nodes to be added by the consumer.
20 * The child classes are {@link DocParagraph} and {@link DocSection}.
21 */
22var DocNodeContainer = /** @class */ (function (_super) {
23 __extends(DocNodeContainer, _super);
24 /**
25 * Don't call this directly. Instead use {@link TSDocParser}
26 * @internal
27 */
28 function DocNodeContainer(parameters, childNodes) {
29 var _this = _super.call(this, parameters) || this;
30 _this._nodes = [];
31 if (childNodes !== undefined && childNodes.length > 0) {
32 _this.appendNodes(childNodes);
33 }
34 return _this;
35 }
36 Object.defineProperty(DocNodeContainer.prototype, "nodes", {
37 /**
38 * The nodes that were added to this container.
39 */
40 get: function () {
41 return this._nodes;
42 },
43 enumerable: false,
44 configurable: true
45 });
46 /**
47 * Append a node to the container.
48 */
49 DocNodeContainer.prototype.appendNode = function (docNode) {
50 if (!this.configuration.docNodeManager.isAllowedChild(this.kind, docNode.kind)) {
51 throw new Error("The TSDocConfiguration does not allow a " + this.kind + " node to" +
52 (" contain a node of type " + docNode.kind));
53 }
54 this._nodes.push(docNode);
55 };
56 /**
57 * Append nodes to the container.
58 */
59 DocNodeContainer.prototype.appendNodes = function (docNodes) {
60 for (var _i = 0, docNodes_1 = docNodes; _i < docNodes_1.length; _i++) {
61 var docNode = docNodes_1[_i];
62 this.appendNode(docNode);
63 }
64 };
65 /**
66 * Remove all nodes from the container.
67 */
68 DocNodeContainer.prototype.clearNodes = function () {
69 this._nodes.length = 0;
70 };
71 /** @override */
72 DocNodeContainer.prototype.onGetChildNodes = function () {
73 return this._nodes;
74 };
75 return DocNodeContainer;
76}(DocNode_1.DocNode));
77exports.DocNodeContainer = DocNodeContainer;
78//# sourceMappingURL=DocNodeContainer.js.map
\No newline at end of file