Skip to content

Commit 220ba97

Browse files
committed
Refactor
1 parent 445886f commit 220ba97

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/plugin/utils/ast-utils.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,18 @@ export function getDefaultTypeFormatFlags(enclosingNode: Node) {
138138
return formatFlags;
139139
}
140140

141-
export function getMainCommentOfNode(
142-
node: Node,
143-
sourceFile: SourceFile
144-
): string {
141+
export function getDocComment(node: Node): DocComment {
145142
const tsdocParser: TSDocParser = new TSDocParser();
146143
const parserContext: ParserContext = tsdocParser.parseString(
147144
node.getFullText()
148145
);
149-
const docComment: DocComment = parserContext.docComment;
146+
return parserContext.docComment;
147+
}
148+
export function getMainCommentOfNode(
149+
node: Node,
150+
sourceFile: SourceFile
151+
): string {
152+
const docComment = getDocComment(node);
150153
return renderDocNode(docComment.summarySection).trim();
151154
}
152155

@@ -168,11 +171,7 @@ export function parseCommentDocValue(docValue: string, type: ts.Type) {
168171
}
169172

170173
export function getTsDocTagsOfNode(node: Node, typeChecker: TypeChecker) {
171-
const tsdocParser: TSDocParser = new TSDocParser();
172-
const parserContext: ParserContext = tsdocParser.parseString(
173-
node.getFullText()
174-
);
175-
const docComment: DocComment = parserContext.docComment;
174+
const docComment = getDocComment(node);
176175

177176
const tagDefinitions: {
178177
[key: string]: {

0 commit comments

Comments
 (0)