Skip to content

Commit

Permalink
FormatWriter: first line of docstrings for wrap=no
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Oct 5, 2020
1 parent 48e136c commit 5588a94
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,9 @@ class FormatWriter(formatOps: FormatOps) {
while (matcher.find()) {
val contentBeg = matcher.start(2)
val contentEnd = matcher.end(2)
if (contentBeg == contentEnd) prevWasBlank = true
else {
if (contentBeg == contentEnd) {
if (sb.length() != sbLen) prevWasBlank = true
} else {
if (sb.length() != sbLen) appendBreak()
if (prevWasBlank) {
appendBreak
Expand Down
6 changes: 2 additions & 4 deletions scalafmt-tests/src/test/resources/default/DefDef.stat
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ object a {
>>>
object a {

/**
* Returns True is this state will always return better formatting than other.
/** Returns True is this state will always return better formatting than other.
*/
def alwaysBetter(other: State): Boolean = this.cost <= other.cost &&
this.indentation <= other.indentation
Expand Down Expand Up @@ -107,8 +106,7 @@ final def getSelectChain(child: Term.Select,
TypedPipe.from[U](pipe, fields)(flowDef, mode, conv)
})
>>>
/**
* If any errors happen below this line, but before a groupBy, write to a TypedSink
/** If any errors happen below this line, but before a groupBy, write to a TypedSink
*/
def addTrap[U >: T](trapSink: Source with TypedSink[T])(implicit
conv: TupleConverter[U]): TypedPipe[U] =
Expand Down
3 changes: 1 addition & 2 deletions scalafmt-tests/src/test/resources/newlines/source.source
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ private[parser] trait CacheControlHeader { this: Parser with CommonRules with Co
}
}
>>>
/**
* Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
/** Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
*/

package akka.http.impl.model.parser
Expand Down
36 changes: 12 additions & 24 deletions scalafmt-tests/src/test/resources/test/JavaDoc.stat
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ docstrings.style = SpaceAsterisk
*/
class Main
>>>
/**
* Main entry-point.
/** Main entry-point.
*/
class Main
<<< #1403 1: AsteriskSpace 1
Expand All @@ -99,8 +98,7 @@ docstrings.style = AsteriskSpace
*/
class Main
>>>
/**
* Indent0
/** Indent0
* Indent1
* Indent2
* Indent3
Expand Down Expand Up @@ -1100,11 +1098,9 @@ object a {
object a {

/** alias for [[literal]] */
/**
* alias for [[literal]]
/** alias for [[literal]]
*/
/**
* alias for [[literal]]
/** alias for [[literal]]
* alias for [[literal]]
*/
}
Expand All @@ -1131,8 +1127,7 @@ object a {

/** alias for [[literal]] */
/** alias for [[literal]] */
/**
* alias for [[literal]]
/** alias for [[literal]]
* alias for [[literal]]
*/
}
Expand All @@ -1159,11 +1154,9 @@ object a {

/** alias for [[literal]]
*/
/**
* alias for [[literal]]
/** alias for [[literal]]
*/
/**
* alias for [[literal]]
/** alias for [[literal]]
* alias for [[literal]]
*/
}
Expand All @@ -1189,11 +1182,9 @@ object a {
object a {

/** alias for [[literal]] */
/**
* alias for [[literal]]
/** alias for [[literal]]
*/
/**
* alias for [[literal]]
/** alias for [[literal]]
* alias for [[literal]]
*/
}
Expand All @@ -1220,8 +1211,7 @@ object a {

/** alias for [[literal]] */
/** alias for [[literal]] */
/**
* alias for [[literal]]
/** alias for [[literal]]
* alias for [[literal]]
*/
}
Expand All @@ -1248,11 +1238,9 @@ object a {

/** alias for [[literal]]
*/
/**
* alias for [[literal]]
/** alias for [[literal]]
*/
/**
* alias for [[literal]]
/** alias for [[literal]]
* alias for [[literal]]
*/
}
Expand Down
6 changes: 2 additions & 4 deletions scalafmt-tests/src/test/resources/unit/Basic.source
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ object a {
>>>
object a {

/**
* One
/** One
*/
def one = 1

/**
* Two
/** Two
*/
def two = 2
}
9 changes: 3 additions & 6 deletions scalafmt-tests/src/test/resources/unit/Import.source
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ object a
import foo.bar
import kaz.bar

/**
* Docstring
/** Docstring
*/
object a
<<< Rename
Expand Down Expand Up @@ -109,8 +108,7 @@ import d.e.f
>>>
package a.b.c

/**
* docstring
/** docstring
*/

import d.e.f
Expand All @@ -125,8 +123,7 @@ package a.b.c
import d.e.f
>>>
package a.b.c
/**
* docstring
/** docstring
*/

import d.e.f
3 changes: 1 addition & 2 deletions scalafmt-tests/src/test/resources/unit/Package.source
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ object a
>>>
package foo

/**
* comment
/** comment
*/
object a

Expand Down

0 comments on commit 5588a94

Please sign in to comment.