Skip to content

Commit 028a141

Browse files
authored
feat(default-value): treat as code block for better styling (#2370)
* feat(default-value): treat as code block for better styling * refactor(parser): consider defaultValue * chore: apply prettier
1 parent c83f2c3 commit 028a141

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/lib/converter/comments/parser.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,10 @@ function blockTag(
215215
let content: CommentDisplayPart[];
216216
if (tagName === "@example" && config.jsDocCompatibility.exampleTag) {
217217
content = exampleBlockContent(comment, lexer, config, warning);
218-
} else if (tagName === "@default" && config.jsDocCompatibility.defaultTag) {
218+
} else if (
219+
(tagName === "@default" && config.jsDocCompatibility.defaultTag) ||
220+
tagName === "@defaultValue"
221+
) {
219222
content = defaultBlockContent(comment, lexer, config, warning);
220223
} else {
221224
content = blockContent(comment, lexer, config, warning);

src/test/behavior.c2.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,19 @@ describe("Behavior Tests", () => {
277277
logger.expectNoOtherMessages();
278278
});
279279

280+
it("Handles @defaultValue tags", () => {
281+
const project = convert("defaultValueTag");
282+
const foo = query(project, "foo");
283+
const tags = foo.comment?.blockTags.map((tag) => tag.content);
284+
285+
equal(tags, [
286+
[{ kind: "code", text: "```ts\n\n```" }],
287+
[{ kind: "code", text: "```ts\nfn({})\n```" }],
288+
]);
289+
290+
logger.expectNoOtherMessages();
291+
});
292+
280293
it("Handles @example tags with JSDoc compat turned on", () => {
281294
const project = convert("exampleTags");
282295
const foo = query(project, "foo");
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* @defaultValue
3+
* @defaultValue fn({})
4+
*/
5+
export const foo = 1;

0 commit comments

Comments
 (0)