From 4146cbaac5d96e45da07819ce2c105d46652451f Mon Sep 17 00:00:00 2001 From: Omar Ismail Date: Thu, 6 Jun 2024 16:32:23 +0100 Subject: [PATCH] Make sure there is separator preceding @sample --- .../java/com/facebook/ktfmt/kdoc/ParagraphListBuilder.kt | 1 + .../test/java/com/facebook/ktfmt/format/FormatterTest.kt | 2 ++ .../java/com/facebook/ktfmt/kdoc/KDocFormatterTest.kt | 8 +++++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/facebook/ktfmt/kdoc/ParagraphListBuilder.kt b/core/src/main/java/com/facebook/ktfmt/kdoc/ParagraphListBuilder.kt index d48a3796..ef5414f7 100644 --- a/core/src/main/java/com/facebook/ktfmt/kdoc/ParagraphListBuilder.kt +++ b/core/src/main/java/com/facebook/ktfmt/kdoc/ParagraphListBuilder.kt @@ -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) diff --git a/core/src/test/java/com/facebook/ktfmt/format/FormatterTest.kt b/core/src/test/java/com/facebook/ktfmt/format/FormatterTest.kt index 479d09c1..9f37fa1a 100644 --- a/core/src/test/java/com/facebook/ktfmt/format/FormatterTest.kt +++ b/core/src/test/java/com/facebook/ktfmt/format/FormatterTest.kt @@ -1355,6 +1355,7 @@ class FormatterTest { | * Old {@link JavaDocLink} that gets removed. | * | * @sample Example + | * | * @param unused [Param] | * @return [Unit] as [ReturnedValue] | * @property JavaDocLink [Param] @@ -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 | */ diff --git a/core/src/test/java/com/facebook/ktfmt/kdoc/KDocFormatterTest.kt b/core/src/test/java/com/facebook/ktfmt/kdoc/KDocFormatterTest.kt index d88a5518..53d28a73 100644 --- a/core/src/test/java/com/facebook/ktfmt/kdoc/KDocFormatterTest.kt +++ b/core/src/test/java/com/facebook/ktfmt/kdoc/KDocFormatterTest.kt @@ -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) @@ -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 */ """ @@ -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