Skip to content

fix: capitalize description starting on next line - #276

Open
anubhavlal07 wants to merge 1 commit into
fardad-dev:masterfrom
anubhavlal07:fix/capitalize-next-line-description
Open

anubhavlal07 wants to merge 1 commit into
fardad-dev:masterfrom
anubhavlal07:fix/capitalize-next-line-description

Conversation

@anubhavlal07

Copy link
Copy Markdown

Fixes #275

Bug

If a tag's description starts on the line after the name, the first format leaves it lowercase. The second format capitalizes it, so the output is not idempotent:

/**
 * @param {string} a
 * description on next line
 */

Root cause

The parser uses comment-parser's preserve description tokenizer, which keeps the leading \n on this kind of description. formatDescription then calls capitalizer, and capitalizer uppercases str[0]. Here str[0] is the \n, so the first word stays lowercase. On the second run the description is already on the tag line, and it gets capitalized then.

Fix

capitalizer now skips leading newlines and capitalizes the rest. It skips only newlines, not spaces, so indented code blocks are left as they are.

Test

Added a case to tests/descriptions.test.ts. It formats the comment above, expects Description on next line after one pass, and checks that a second pass gives the same output. The test fails without the fix. The full suite passes with no snapshot changes (148 tests, 204 snapshots).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Description on the line after @param name is only capitalized on the second format

1 participant