Repository navigation
Disable scalafmt docstring wrapping - #318
Merged
Merged
Conversation
With the default `docstrings.wrap = yes`, scalafmt reflows the contents of `/** ... */` blocks as if they were one paragraph. A Korean docstring with a four-item numbered list collapses into one line where items 1-4 sit side by side, and the line is then hard-wrapped at maxColumn, producing nonsense indentation. `docstrings.wrap = no` keeps the original line breaks inside the docstring, which is what every existing docstring in the repo is already written for. The other two docstring options (`docstrings.style` and `docstrings.oneline`) are already at sensible defaults, so only `wrap` needs to change. The same line is added to `GenerateCodeStyleTask.generate()` so that `./gradlew generateCodeStyle` produces a matching `scalafmt.conf`. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.
Summary
Scalafmt 3.8.3 defaults
docstrings.wrap = yes, which reflows the body of a/** ... */block as if it were one paragraph and then hard-wraps it atmaxColumn. For docstrings that intentionally use multi-line structure — numbered lists, step-by-step rules — this destroys the layout. Settingdocstrings.wrap = nopreserves the line breaks the author wrote, which is what every existing docstring in the repo already assumes.Closes #
Changes
docstrings.wrap = noto.scalafmt.conf.GenerateCodeStyleTask.generate()so that./gradlew generateCodeStyleproduces a matching file.docstrings.style,docstrings.oneline) are already at sensible defaults, so onlywrapneeds to change.Example
Author writes:
With the default (
docstrings.wrap = yes), scalafmt rewrites this to:The four numbered items are joined into one paragraph and the line is then hard-wrapped at
maxColumn, leaving1.,2.,3.,4.sitting side by side. Withdocstrings.wrap = nothe original line structure is left alone.How to Test
./gradlew spotlessApply— the docstring should be left unchanged (modulo leading-asterisk style)../gradlew generateCodeStyleregenerates.scalafmt.confand thedocstrings.wrap = noline is present.AI Assistance