UNPKG

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