UNPKG

2.42 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 { DocNodeKind } from './DocNode';
15import { DocParagraph } from './DocParagraph';
16import { DocNodeContainer } from './DocNodeContainer';
17/**
18 * Represents a general block of rich text.
19 */
20var DocSection = /** @class */ (function (_super) {
21 __extends(DocSection, _super);
22 /**
23 * Don't call this directly. Instead use {@link TSDocParser}
24 * @internal
25 */
26 function DocSection(parameters, childNodes) {
27 return _super.call(this, parameters, childNodes) || this;
28 }
29 Object.defineProperty(DocSection.prototype, "kind", {
30 /** @override */
31 get: function () {
32 return DocNodeKind.Section;
33 },
34 enumerable: false,
35 configurable: true
36 });
37 /**
38 * If the last item in DocSection.nodes is not a DocParagraph, a new paragraph
39 * is started. Either way, the provided docNode will be appended to the paragraph.
40 */
41 DocSection.prototype.appendNodeInParagraph = function (docNode) {
42 var paragraphNode = undefined;
43 if (this.nodes.length > 0) {
44 var lastNode = this.nodes[this.nodes.length - 1];
45 if (lastNode.kind === DocNodeKind.Paragraph) {
46 paragraphNode = lastNode;
47 }
48 }
49 if (!paragraphNode) {
50 paragraphNode = new DocParagraph({ configuration: this.configuration });
51 this.appendNode(paragraphNode);
52 }
53 paragraphNode.appendNode(docNode);
54 };
55 DocSection.prototype.appendNodesInParagraph = function (docNodes) {
56 for (var _i = 0, docNodes_1 = docNodes; _i < docNodes_1.length; _i++) {
57 var docNode = docNodes_1[_i];
58 this.appendNodeInParagraph(docNode);
59 }
60 };
61 return DocSection;
62}(DocNodeContainer));
63export { DocSection };
64//# sourceMappingURL=DocSection.js.map
\No newline at end of file