Repository navigation
Enforce Javadoc-style docstrings in scalafmt - #319
Merged
Merged
Conversation
Scalafmt default folds the first line of a docstring onto the opening
`/**`, producing the Scaladoc one-line shape:
/** Some doc.
*
* More details.
*/
Setting `docstrings.blankFirstLine = yes` forces the opening `/**` onto
its own line, matching the Javadoc style that the rest of the codebase
(Java and Kotlin) already uses:
/**
* Some doc.
*
* More details.
*/
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
Force scalafmt to keep the opening
/**on its own line so Scala docstrings match the Javadoc layout that the Java and Kotlin code in this repo already use. With the scalafmt default, the first line of the docstring is folded onto/**, producing the Scaladoc one-line shape that looks foreign next to the rest of the codebase.Closes #
Changes
docstrings.blankFirstLine = yesto.scalafmt.conf.GenerateCodeStyleTask.generate()so./gradlew generateCodeStyleproduces a matching file.Example
Author writes:
Default scalafmt rewrites this to:
With
docstrings.blankFirstLine = yes:The leading-asterisk style (
*) is left at the scalafmt default; only the first line is forced to be blank, which is the single switch that flips Scaladoc-shape into Javadoc-shape.How to Test
./gradlew generateCodeStyleregenerates.scalafmt.confwith thedocstrings.blankFirstLine = yesline present../gradlew spotlessApply— the opening/**should stay on its own line.AI Assistance