UNPKG

5.34 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})();
15var __spreadArrays = (this && this.__spreadArrays) || function () {
16 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
17 for (var r = Array(s), k = 0, i = 0; i < il; i++)
18 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
19 r[k] = a[j];
20 return r;
21};
22Object.defineProperty(exports, "__esModule", { value: true });
23exports.DocComment = void 0;
24var DocNode_1 = require("./DocNode");
25var DocSection_1 = require("./DocSection");
26var StandardModifierTagSet_1 = require("../details/StandardModifierTagSet");
27var StringBuilder_1 = require("../emitters/StringBuilder");
28var DocParamCollection_1 = require("./DocParamCollection");
29/**
30 * Represents an entire documentation comment conforming to the TSDoc structure.
31 * This is the root of the DocNode tree.
32 */
33var DocComment = /** @class */ (function (_super) {
34 __extends(DocComment, _super);
35 /**
36 * Don't call this directly. Instead use {@link TSDocParser}
37 * @internal
38 */
39 function DocComment(parameters) {
40 var _this = _super.call(this, parameters) || this;
41 _this.summarySection = new DocSection_1.DocSection({ configuration: _this.configuration });
42 _this.remarksBlock = undefined;
43 _this.privateRemarks = undefined;
44 _this.deprecatedBlock = undefined;
45 _this.params = new DocParamCollection_1.DocParamCollection({ configuration: _this.configuration });
46 _this.typeParams = new DocParamCollection_1.DocParamCollection({ configuration: _this.configuration });
47 _this.returnsBlock = undefined;
48 _this.modifierTagSet = new StandardModifierTagSet_1.StandardModifierTagSet();
49 _this._seeBlocks = [];
50 _this._customBlocks = [];
51 return _this;
52 }
53 Object.defineProperty(DocComment.prototype, "kind", {
54 /** @override */
55 get: function () {
56 return DocNode_1.DocNodeKind.Comment;
57 },
58 enumerable: false,
59 configurable: true
60 });
61 Object.defineProperty(DocComment.prototype, "seeBlocks", {
62 /**
63 * The collection of all `@see` DockBlockTag nodes belonging to this doc comment.
64 */
65 get: function () {
66 return this._seeBlocks;
67 },
68 enumerable: false,
69 configurable: true
70 });
71 Object.defineProperty(DocComment.prototype, "customBlocks", {
72 /**
73 * The collection of all DocBlock nodes belonging to this doc comment.
74 */
75 get: function () {
76 return this._customBlocks;
77 },
78 enumerable: false,
79 configurable: true
80 });
81 /**
82 * Append an item to the seeBlocks collection.
83 * @internal
84 */
85 DocComment.prototype._appendSeeBlock = function (block) {
86 this._seeBlocks.push(block);
87 };
88 /**
89 * Append an item to the customBlocks collection.
90 */
91 DocComment.prototype.appendCustomBlock = function (block) {
92 this._customBlocks.push(block);
93 };
94 /** @override */
95 DocComment.prototype.onGetChildNodes = function () {
96 return __spreadArrays([
97 this.summarySection,
98 this.remarksBlock,
99 this.privateRemarks,
100 this.deprecatedBlock,
101 this.params.count > 0 ? this.params : undefined,
102 this.typeParams.count > 0 ? this.typeParams : undefined,
103 this.returnsBlock
104 ], this.customBlocks, this.seeBlocks, [
105 this.inheritDocTag
106 ], this.modifierTagSet.nodes);
107 };
108 /**
109 * Generates a doc comment corresponding to the `DocComment` tree. The output is in a normalized form,
110 * and may ignore formatting/spacing from the original input.
111 *
112 * @remarks
113 * After parsing a string, and possibly modifying the result, `emitAsTsdoc()` can be used to render the result
114 * as a doc comment in a normalized format. It can also be used to emit a `DocComment` tree that was constructed
115 * manually.
116 *
117 * This method is provided as convenience for simple use cases. To customize the output, or if you need
118 * to render into a `StringBuilder`, use the {@link TSDocEmitter} class instead.
119 */
120 DocComment.prototype.emitAsTsdoc = function () {
121 var stringBuilder = new StringBuilder_1.StringBuilder();
122 // eslint-disable-next-line @typescript-eslint/no-use-before-define
123 var emitter = new TSDocEmitter_1.TSDocEmitter();
124 emitter.renderComment(stringBuilder, this);
125 return stringBuilder.toString();
126 };
127 return DocComment;
128}(DocNode_1.DocNode));
129exports.DocComment = DocComment;
130// Circular reference
131var TSDocEmitter_1 = require("../emitters/TSDocEmitter");
132//# sourceMappingURL=DocComment.js.map
\No newline at end of file