cabal-gild 1.1.0.0 → 1.1.0.1
raw patch · 4 files changed
+41/−3 lines, 4 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ CabalGild.Extra.Name: isElif :: Name a -> Bool
+ CabalGild.Extra.Name: isElse :: Name a -> Bool
+ CabalGild.Extra.Name: isIf :: Name a -> Bool
Files
- cabal-gild.cabal +1/−1
- source/library/CabalGild/Action/Render.hs +2/−2
- source/library/CabalGild/Extra/Name.hs +13/−0
- source/test-suite/Main.hs +25/−0
cabal-gild.cabal view
@@ -11,7 +11,7 @@ maintainer: Taylor Fausak name: cabal-gild synopsis: Formats package descriptions.-version: 1.1.0.0+version: 1.1.0.1 source-repository head type: git
source/library/CabalGild/Action/Render.hs view
@@ -59,8 +59,8 @@ } <> fieldLines (i + 1) fls Fields.Section n sas fs ->- Lens.set Block.lineBeforeLens True- . Lens.set Block.lineAfterLens True+ Lens.set Block.lineBeforeLens (not $ Name.isElif n || Name.isElse n)+ . Lens.set Block.lineAfterLens (not $ Name.isIf n || Name.isElif n) $ comments i (Name.annotation n) <> comments i (concatMap SectionArg.annotation sas) <> Block.fromLine
source/library/CabalGild/Extra/Name.hs view
@@ -1,5 +1,6 @@ module CabalGild.Extra.Name where +import qualified CabalGild.Extra.String as String import qualified Distribution.Compat.Lens as Lens import qualified Distribution.Fields as Fields @@ -14,3 +15,15 @@ -- | Extracts the value from the given 'Fields.Name'. value :: Fields.Name a -> Fields.FieldName value (Fields.Name _ x) = x++-- | Returns true when the name is @"if"@, false otherwise.+isIf :: Fields.Name a -> Bool+isIf = (== String.toUtf8 "if") . value++-- | Returns true when the name is @"elif"@, false otherwise.+isElif :: Fields.Name a -> Bool+isElif = (== String.toUtf8 "elif") . value++-- | Returns true when the name is @"else"@, false otherwise.+isElse :: Fields.Name a -> Bool+isElse = (== String.toUtf8 "else") . value
source/test-suite/Main.hs view
@@ -970,6 +970,31 @@ "s{t{}}" "s\n t\n" + Hspec.it "groups 'else' with 'if'" $ do+ expectGilded+ "if p\n a\nelse\n b"+ "if p\n a\nelse\n b\n"++ Hspec.it "groups 'elif' with 'if'" $ do+ expectGilded+ "if p\n a\nelif q\n b"+ "if p\n a\nelif q\n b\n"++ Hspec.it "groups 'else' with 'elif'" $ do+ expectGilded+ "if p\n a\nelif q\n b\nelse\n c"+ "if p\n a\nelif q\n b\nelse\n c\n"++ Hspec.it "does not group 'else' with anything else" $ do+ expectGilded+ "library\nelse p\n a"+ "library\n\nelse p\n a\n"++ Hspec.it "does not group 'elif' with anything else" $ do+ expectGilded+ "library\nelif p\n a"+ "library\n\nelif p\n a\n"+ expectGilded :: (Stack.HasCallStack) => String -> String -> Hspec.Expectation expectGilded input expected = do let (a, s, w) =