File size: 1,831 Bytes
6abff73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocNodeContainer = void 0;
const DocNode_1 = require("./DocNode");
/**
 * DocNodeContainer is the base class for DocNode classes that allow arbitrary child nodes to be added by the consumer.
 * The child classes are {@link DocParagraph} and {@link DocSection}.
 */
class DocNodeContainer extends DocNode_1.DocNode {
    /**
     * Don't call this directly.  Instead use {@link TSDocParser}
     * @internal
     */
    constructor(parameters, childNodes) {
        super(parameters);
        this._nodes = [];
        if (childNodes !== undefined && childNodes.length > 0) {
            this.appendNodes(childNodes);
        }
    }
    /**
     * The nodes that were added to this container.
     */
    get nodes() {
        return this._nodes;
    }
    /**
     * Append a node to the container.
     */
    appendNode(docNode) {
        if (!this.configuration.docNodeManager.isAllowedChild(this.kind, docNode.kind)) {
            throw new Error(`The TSDocConfiguration does not allow a ${this.kind} node to` +
                ` contain a node of type ${docNode.kind}`);
        }
        this._nodes.push(docNode);
    }
    /**
     * Append nodes to the container.
     */
    appendNodes(docNodes) {
        for (const docNode of docNodes) {
            this.appendNode(docNode);
        }
    }
    /**
     * Remove all nodes from the container.
     */
    clearNodes() {
        this._nodes.length = 0;
    }
    /** @override */
    onGetChildNodes() {
        return this._nodes;
    }
}
exports.DocNodeContainer = DocNodeContainer;
//# sourceMappingURL=DocNodeContainer.js.map