UNPKG

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