UNPKG

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