Skip to content

Commit

Permalink
feat(default-value): treat as code block for better styling (#2370)
Browse files Browse the repository at this point in the history
* feat(default-value): treat as code block for better styling
* refactor(parser): consider defaultValue
* chore: apply prettier
  • Loading branch information
roggervalf committed Aug 25, 2023
1 parent c83f2c3 commit 028a141
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/converter/comments/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ function blockTag(
let content: CommentDisplayPart[];
if (tagName === "@example" && config.jsDocCompatibility.exampleTag) {
content = exampleBlockContent(comment, lexer, config, warning);
} else if (tagName === "@default" && config.jsDocCompatibility.defaultTag) {
} else if (
(tagName === "@default" && config.jsDocCompatibility.defaultTag) ||
tagName === "@defaultValue"
) {
content = defaultBlockContent(comment, lexer, config, warning);
} else {
content = blockContent(comment, lexer, config, warning);
Expand Down
13 changes: 13 additions & 0 deletions src/test/behavior.c2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,19 @@ describe("Behavior Tests", () => {
logger.expectNoOtherMessages();
});

it("Handles @defaultValue tags", () => {
const project = convert("defaultValueTag");
const foo = query(project, "foo");
const tags = foo.comment?.blockTags.map((tag) => tag.content);

equal(tags, [
[{ kind: "code", text: "```ts\n\n```" }],
[{ kind: "code", text: "```ts\nfn({})\n```" }],
]);

logger.expectNoOtherMessages();
});

it("Handles @example tags with JSDoc compat turned on", () => {
const project = convert("exampleTags");
const foo = query(project, "foo");
Expand Down
5 changes: 5 additions & 0 deletions src/test/converter2/behavior/defaultValueTag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* @defaultValue
* @defaultValue fn({})
*/
export const foo = 1;

0 comments on commit 028a141

Please sign in to comment.