Spaces:
Running
Running
File size: 3,771 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | "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.DocComment = void 0;
const DocNode_1 = require("./DocNode");
const DocSection_1 = require("./DocSection");
const StandardModifierTagSet_1 = require("../details/StandardModifierTagSet");
const StringBuilder_1 = require("../emitters/StringBuilder");
const TSDocEmitter_1 = require("../emitters/TSDocEmitter");
const DocParamCollection_1 = require("./DocParamCollection");
/**
* Represents an entire documentation comment conforming to the TSDoc structure.
* This is the root of the DocNode tree.
*/
class DocComment extends DocNode_1.DocNode {
/**
* Don't call this directly. Instead use {@link TSDocParser}
* @internal
*/
constructor(parameters) {
super(parameters);
this.summarySection = new DocSection_1.DocSection({ configuration: this.configuration });
this.remarksBlock = undefined;
this.privateRemarks = undefined;
this.deprecatedBlock = undefined;
this.params = new DocParamCollection_1.DocParamCollection({ configuration: this.configuration });
this.typeParams = new DocParamCollection_1.DocParamCollection({ configuration: this.configuration });
this.returnsBlock = undefined;
this.modifierTagSet = new StandardModifierTagSet_1.StandardModifierTagSet();
this._seeBlocks = [];
this._customBlocks = [];
}
/** @override */
get kind() {
return DocNode_1.DocNodeKind.Comment;
}
/**
* The collection of all `@see` DockBlockTag nodes belonging to this doc comment.
*/
get seeBlocks() {
return this._seeBlocks;
}
/**
* The collection of all DocBlock nodes belonging to this doc comment.
*/
get customBlocks() {
return this._customBlocks;
}
/**
* Append an item to the seeBlocks collection.
* @internal
*/
_appendSeeBlock(block) {
this._seeBlocks.push(block);
}
/**
* Append an item to the customBlocks collection.
*/
appendCustomBlock(block) {
this._customBlocks.push(block);
}
/** @override */
onGetChildNodes() {
return [
this.summarySection,
this.remarksBlock,
this.privateRemarks,
this.deprecatedBlock,
this.params.count > 0 ? this.params : undefined,
this.typeParams.count > 0 ? this.typeParams : undefined,
this.returnsBlock,
...this.customBlocks,
...this.seeBlocks,
this.inheritDocTag,
...this.modifierTagSet.nodes
];
}
/**
* Generates a doc comment corresponding to the `DocComment` tree. The output is in a normalized form,
* and may ignore formatting/spacing from the original input.
*
* @remarks
* After parsing a string, and possibly modifying the result, `emitAsTsdoc()` can be used to render the result
* as a doc comment in a normalized format. It can also be used to emit a `DocComment` tree that was constructed
* manually.
*
* This method is provided as convenience for simple use cases. To customize the output, or if you need
* to render into a `StringBuilder`, use the {@link TSDocEmitter} class instead.
*/
emitAsTsdoc() {
const stringBuilder = new StringBuilder_1.StringBuilder();
const emitter = new TSDocEmitter_1.TSDocEmitter();
emitter.renderComment(stringBuilder, this);
return stringBuilder.toString();
}
}
exports.DocComment = DocComment;
//# sourceMappingURL=DocComment.js.map |