Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Following 2.7.4: can't find a way to keep first line blank in docstrings with docstrings = Scaladoc / docstrings.style = SpaceAsterisk #2218

Closed
neko-kai opened this issue Oct 7, 2020 · 2 comments · Fixed by #2221

Comments

@neko-kai
Copy link

neko-kai commented Oct 7, 2020

version = 2.7.4
docstrings = ScalaDoc

Steps

Given code like this:

/**
  * abc
  * cba
  */
def x: Unit = ()

Problem

Scalafmt formats code like this (with either setting for docstrings.wrap):

/** abc cba
  */
def x: Unit = ()

Expectation

I would like the formatted output to look like this:

// docstrings.wrap = false // keep starting newline as in 2.7.3
/**
  * abc
  * cba
  */
def x: Unit = ()
// docstrings.wrap = true // fold everything?
/** abc cba */
def x: Unit = ()

Workaround

None

Notes

None

@kitbellew
Copy link
Collaborator

https://docs.scala-lang.org/style/scaladoc.html:

Note that, in contrast to the Javadoc convention, the text in the Scaladoc styles begins on the first line of the comment.

I can add a new docstrings = AsIs which will not format the docstring at all. Including indent and leading asterisks.

@neko-kai
Copy link
Author

neko-kai commented Oct 7, 2020

@kitbellew
I understand the recommendation, but it's not really followed universally, even in scala/scala. Scalafmt sorting out with the leading asterisks is a big help, so omitting all formatting would be regrettable. Maybe a separate option, such as docstrings.spaces = fold/unfold ?

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

Successfully merging a pull request may close this issue.

2 participants