diff --git a/elm-format-markdown/Cheapskate/Parse.hs b/elm-format-markdown/Cheapskate/Parse.hs index 663c1a807..c17ad193b 100644 --- a/elm-format-markdown/Cheapskate/Parse.hs +++ b/elm-format-markdown/Cheapskate/Parse.hs @@ -237,8 +237,9 @@ processElts refmap (L _lineNumber lf : rest) = TextLine t | Just terms1 <- T.stripPrefix "@docs" t -> let docs = terms1 : map (cleanDoc . extractText) docLines + cleaned = filter ((/=) []) $ fmap (filter ((/=) "") . fmap T.strip . T.splitOn ",") docs in - singleton (ElmDocs $ filter ((/=) []) $ fmap (filter ((/=) ""). fmap T.strip . T.splitOn ",") docs) <> + (if null cleaned then mempty else singleton (ElmDocs cleaned)) <> processElts refmap rest' where (docLines, rest') = span isDocLine rest diff --git a/tests/test-files/transform/Elm-0.19/RemoveEmptyElmDocsProperly.elm b/tests/test-files/transform/Elm-0.19/RemoveEmptyElmDocsProperly.elm new file mode 100644 index 000000000..3badcb226 --- /dev/null +++ b/tests/test-files/transform/Elm-0.19/RemoveEmptyElmDocsProperly.elm @@ -0,0 +1,13 @@ +module A exposing (a) + +{-| + +@docs + +@docs a + +-} + + +a = + 1 diff --git a/tests/test-files/transform/Elm-0.19/RemoveEmptyElmDocsProperly.formatted.elm b/tests/test-files/transform/Elm-0.19/RemoveEmptyElmDocsProperly.formatted.elm new file mode 100644 index 000000000..832bebce0 --- /dev/null +++ b/tests/test-files/transform/Elm-0.19/RemoveEmptyElmDocsProperly.formatted.elm @@ -0,0 +1,11 @@ +module A exposing (a) + +{-| + +@docs a + +-} + + +a = + 1