ronn 1.1.0.0 → 1.1.1.0
raw patch · 6 files changed
+38/−6 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Ronn: class HasSections p
+ Ronn: getEnvDefinitions :: HasSections p => p a -> Maybe [Definition]
+ Ronn: getOptDefinitions :: HasSections p => p a -> Maybe [Definition]
+ Ronn: getSections :: HasSections p => Text -> p a -> [Section]
+ Ronn: getSynopsis :: HasSections p => p a -> Maybe [Part]
Files
- CHANGELOG.md +5/−1
- README.md +2/−2
- ronn.cabal +1/−1
- src/Ronn.hs +27/−0
- tests/Main.hs +2/−1
- tests/Ronn/RenderSpec.hs +1/−1
CHANGELOG.md view
@@ -1,4 +1,8 @@-## [_Unreleased_](https://github.com/pbrisbin/ronn/compare/ronn-v1.1.0.0...main)+## [_Unreleased_](https://github.com/pbrisbin/ronn/compare/ronn-v1.1.1.0...main)++## [v1.1.1.0](https://github.com/pbrisbin/ronn/tree/ronn-v1.1.1.0)++- Add `HasSections` and `getSections` ## [v1.1.0.0](https://github.com/pbrisbin/ronn/tree/ronn-v1.1.0.0)
README.md view
@@ -10,8 +10,8 @@ See [the test][test] and [the result][golden]. -[test]: ./ronn/tests/Ronn/RenderSpec.hs-[golden]: ./doc/ronn.1.ronn+[test]: ./tests/Ronn/RenderSpec.hs+[golden]: ./../doc/ronn.1.ronn ---
ronn.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: ronn-version: 1.1.0.0+version: 1.1.1.0 license: AGPL-3 maintainer: Pat Brisbin homepage: https://github.com/pbrisbin/ronn#readme
src/Ronn.hs view
@@ -11,6 +11,10 @@ , module Ronn.Render , ronnFilePath + -- * Parser-based sections+ , HasSections (..)+ , getSections+ -- * Higher-level builders , synopsisSection , seeAlsoSection@@ -22,6 +26,7 @@ import Prelude import Data.List (intersperse, sort)+import Data.Maybe (catMaybes) import Data.Text (Text, unpack) import Ronn.AST import Ronn.Render@@ -31,6 +36,28 @@ unpack ref.name <> "." <> show (manSectionNumber ref.section) <> ".ronn" where ref = ronn.name++-- | Parser types can be made an instance of this for use with 'getSections'+class HasSections p where+ -- | Options parsers should produce @[-f|--foo] --bar@ synopsis parts+ getSynopsis :: p a -> Maybe [Part]+ getSynopsis _ = Nothing++ -- | Options parsers should produce a list of option/help definitions+ getOptDefinitions :: p a -> Maybe [Definition]+ getOptDefinitions _ = Nothing++ -- | Environment parsers should produce a list of variable/help definitions+ getEnvDefinitions :: p a -> Maybe [Definition]+ getEnvDefinitions _ = Nothing++getSections :: HasSections p => Text -> p a -> [Section]+getSections name p =+ catMaybes+ [ synopsisSection name <$> getSynopsis p+ , definitionsSection "OPTIONS" <$> getOptDefinitions p+ , definitionsSection "ENVIRONMENT" <$> getEnvDefinitions p+ ] synopsisSection :: Text -> [Part] -> Section synopsisSection name = oneLineSection "SYNOPSIS" . (Code (Raw name) :)
tests/Main.hs view
@@ -1,3 +1,5 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover -Wno-missing-export-lists #-}+ -- | -- -- Module : Main@@ -6,4 +8,3 @@ -- Maintainer : pbrisbin@gmail.com -- Stability : experimental -- Portability : POSIX-{-# OPTIONS_GHC -F -pgmF hspec-discover -Wno-missing-export-lists #-}
tests/Ronn/RenderSpec.hs view
@@ -38,7 +38,7 @@ [ Code "ronn" , Brackets $ Code "-h" , Brackets $ Code "--help"- , Brackets $ mconcat [Code "--debug", "|", Code "--trace"]+ , Brackets $ mconcat [Code "--debug", "\\|", Code "--trace"] , Brackets $ mconcat [Code "-o", " ", Variable "FILE"] , Brackets $ mconcat [Code "--output", "=", Variable "FILE"] , Variable "INPUT"