Skip to content

Commit

Permalink
Make sure there is separator preceding @sample
Browse files Browse the repository at this point in the history
  • Loading branch information
omarismail94 committed Jun 6, 2024
1 parent fea31d4 commit 4146cba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ class ParagraphListBuilder(
paragraph.separate =
when {
prev == null -> false
prev.text.startsWith("@sample") -> true
paragraph.preformatted && prev.preformatted -> false
paragraph.table ->
paragraph.separate && (!prev.block || prev.text.isKDocTag() || prev.table)
Expand Down
2 changes: 2 additions & 0 deletions core/src/test/java/com/facebook/ktfmt/format/FormatterTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,7 @@ class FormatterTest {
| * Old {@link JavaDocLink} that gets removed.
| *
| * @sample Example
| *
| * @param unused [Param]
| * @return [Unit] as [ReturnedValue]
| * @property JavaDocLink [Param]
Expand Down Expand Up @@ -5298,6 +5299,7 @@ class FormatterTest {
| * @param marginPrefix non-blank string, which is used as a margin delimiter. Default is `|` (pipe
| * character).
| * @sample samples.text.Strings.trimMargin
| *
| * @see trimIndent
| * @see kotlin.text.isWhitespace
| */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1990,9 +1990,9 @@ class KDocFormatterTest {
/**
* Constructs a new location range for the given file, from start to
* end. If the length of the range is not known, end may be null.
*
* @return Something
* @sample Other
*
* @return Something
* @param file the associated file (but see the documentation for
* [Location.file] for more information on what the file
* represents)
Expand All @@ -2017,13 +2017,14 @@ class KDocFormatterTest {
* Constructs a new location range for the given file, from start to
* end. If the length of the range is not known, end may be null.
*
* @sample Other
*
* @param file the associated file (but see the documentation for
* [Location.file] for more information on what the file
* represents)
* @param start the starting position, or null
* @param end the ending position, or null
* @return Something
* @sample Other
* @see More
*/
"""
Expand Down Expand Up @@ -4321,6 +4322,7 @@ class KDocFormatterTest {
* `stateSaver` param.
*
* @sample androidx.compose.runtime.saveable.samples.RememberSaveableWithMutableStateAndCustomSaver
*
* @param inputs A set of inputs such that, when any of them have changed,
* will cause the state to reset and [init] to be rerun
* @param saver The [Saver] object which defines how the state is saved and
Expand Down

0 comments on commit 4146cba

Please sign in to comment.