Repository navigation
fix: capitalize description starting on next line - #276
Open
anubhavlal07 wants to merge 1 commit into
Open
anubhavlal07 wants to merge 1 commit into
anubhavlal07 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Root cause
The parser uses comment-parser's
preservedescription tokenizer, which keeps the leading\non this kind of description.formatDescriptionthen callscapitalizer, andcapitalizeruppercasesstr[0]. Herestr[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
capitalizernow 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, expectsDescription on next lineafter 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).