fix(formatter/jsdoc): preserve paragraphs by checking @description tag width (#27439)

Fixes #27410
This commit is contained in:
leaysgur committed 2026-10-08 07:00:01 +00:00
1 parent f330f8d62d
commit 676cc60a96
3 files changed
+43 -10

No files matched your search

@@ -139,7 +139,7 @@ impl<'a, 'o> JsdocFormatter<'a, 'o> {
continue;
}
if *normalized_kind == "description" {
let desc_content = tag.comment().parsed();
let desc_content = tag.comment().parsed_preserving_whitespace();
let desc_content = desc_content.trim();
if !desc_content.is_empty() {
if !merged_desc.is_empty() {
@@ -171,22 +171,18 @@ impl<'a, 'o> JsdocFormatter<'a, 'o> {
// Format and emit the merged description
if !merged_desc.is_empty() {
let tag_prefix = if self.options.description_tag { "@description " } else { "" };
let desc = format_description_mdast(
&merged_desc,
self.wrap_width,
0,
tag_prefix.len(),
self.options.capitalize_descriptions,
self.format_options,
self.session,
);
if self.options.description_tag {
// Emit as @description tag
let s = self.content_lines.begin_line();
s.push_str("@description ");
s.push_str(&desc);
} else {
self.content_lines.push(desc);
}
let s = self.content_lines.begin_line();
s.push_str(tag_prefix);
s.push_str(&desc);
}
// Reorder @param tags to match the function signature order
@@ -0,0 +1,18 @@
/**
* Show the account summary with the primary account action.
*
* Reach for {@link ExampleAvatar} when you need the standalone block.
*/
export function headerToTag() {}
/**
* @description Show the account summary with the primary account action.
*
* Reach for {@link ExampleAvatar} when you need the standalone block.
*/
export function existingTag() {}
/**
* Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et.
*/
export function prefixWidth() {}
@@ -0,0 +1,19 @@
/**
* @description Show the account summary with the primary account action.
*
* Reach for {@link ExampleAvatar} when you need the standalone block.
*/
export function headerToTag() {}
/**
* @description Show the account summary with the primary account action.
*
* Reach for {@link ExampleAvatar} when you need the standalone block.
*/
export function existingTag() {}
/**
* @description Lorem ipsum dolor sit amet consectetur adipiscing elit sed do
* eiusmod tempor incididunt ut labore et.
*/
export function prefixWidth() {}