mdoc 0.5.0.0 → 0.6.0.0
raw patch · 9 files changed
+67/−33 lines, 9 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Mdoc.Data.Named: [names] :: Named -> NonEmpty Text
- Mdoc.Data.Named: addSecondary :: Text -> Named -> Named
+ Mdoc.Data.Named: [name] :: Named -> Text
+ Mdoc.Examples.Person: Address :: Text -> Text -> Text -> Text -> Address
+ Mdoc.Examples.Person: Person :: Text -> Int -> Maybe Address -> Maybe [Text] -> Person
+ Mdoc.Examples.Person: [address] :: Person -> Maybe Address
+ Mdoc.Examples.Person: [age] :: Person -> Int
+ Mdoc.Examples.Person: [city] :: Address -> Text
+ Mdoc.Examples.Person: [hobbies] :: Person -> Maybe [Text]
+ Mdoc.Examples.Person: [name] :: Person -> Text
+ Mdoc.Examples.Person: [postalCode] :: Address -> Text
+ Mdoc.Examples.Person: [state] :: Address -> Text
+ Mdoc.Examples.Person: [street] :: Address -> Text
+ Mdoc.Examples.Person: data Address
+ Mdoc.Examples.Person: data Person
+ Mdoc.Optics: head1 :: Lens' (NonEmpty a) a
- Mdoc.Data.Named: Named :: NonEmpty Text -> Text -> Page -> Named
+ Mdoc.Data.Named: Named :: Text -> Text -> Page -> Named
Files
- data/name.mustache +2/−5
- examples/examplerc.5 +33/−0
- mdoc.cabal +1/−1
- src/Mdoc/Data/Named.hs +5/−15
- src/Mdoc/Examples/OptEnvConf.hs +9/−2
- src/Mdoc/Examples/Person.hs +3/−1
- src/Mdoc/Optics.hs +4/−0
- src/OptEnvConf/Mdoc.hs +8/−7
- test/Mdoc/ExamplesSpec.hs +2/−2
data/name.mustache view
@@ -1,6 +1,3 @@ .Sh NAME-{{#name.init}}-.Nm {{{.}}} ,-{{/name.init}}-.Nm {{{name.last}}}-.Nd {{{name.description}}}+.Nm {{{name}}}+.Nd {{{description}}}
examples/examplerc.5 view
@@ -17,6 +17,39 @@ .Ed .It Cm file : Ar string (required)+.It Cm person : Ar object+A person+(required)+.Pp+Example:+.Bd -literal -offset indent+person:+ name: John+.Ed+.It Cm person.address : Ar object+Their address+(optional)+.It Cm person.address.city : Ar string+The city+(required)+.It Cm person.address.postalCode : Ar string+The postal code+(required)+.It Cm person.address.state : Ar string+The state+(required)+.It Cm person.address.street : Ar string+The street+(required)+.It Cm person.age : Ar number+Their age+(required)+.It Cm person.hobbies : Ar string Ns []+Their hobbies+(optional)+.It Cm person.name : Ar string+Their name+(required) .It Cm verbose : Ar boolean (optional, default: False) .El
mdoc.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: mdoc-version: 0.5.0.0+version: 0.6.0.0 license: AGPL-3 license-file: COPYING maintainer: Pat Brisbin
src/Mdoc/Data/Named.hs view
@@ -9,7 +9,6 @@ module Mdoc.Data.Named ( Named (..) , name- , addSecondary ) where import Mdoc.Prelude@@ -17,10 +16,9 @@ import Data.Aeson (object, (.=)) import Data.Text qualified as T import Mdoc.Data.Page-import Mdoc.Optics data Named = Named- { names :: NonEmpty Text+ { name :: Text , description :: Text , page :: Page }@@ -29,19 +27,11 @@ instance ToJSON Named where toJSON named = object- [ "title" .= T.toUpper (esc $ head named.names)- , "name"- .= object- [ "init" .= map esc (init named.names)- , "last" .= esc (last named.names)- , "description" .= esc named.description- ]+ [ "title" .= T.toUpper (esc $ named.name)+ , "name" .= esc named.name+ , "description" .= esc named.description , "page" .= named.page ] name :: Text -> Text -> Page -> Named-name primary description page =- Named {names = pure primary, description, page}--addSecondary :: Text -> Named -> Named-addSecondary x = field @"names" <>~ pure x+name n description page = Named {name = n, description, page}
src/Mdoc/Examples/OptEnvConf.hs view
@@ -15,6 +15,7 @@ import Mdoc.Prelude import Mdoc.Data.Named+import Mdoc.Examples.Person import OptEnvConf hiding (name) import OptEnvConf.Mdoc @@ -41,8 +42,14 @@ {- FOURMOLU_DISABLE -} exampleParser :: Parser ()-exampleParser = void $ (,,,,,)- <$> switch' [ long "debug", help "Enable debug", env "DEBUG", conf "debug", example "# enable debug\ndebug: true"]+exampleParser = void $ (,,,,,,)+ <$> setting [ conf @Person "person", help "A person"+ , example (unlines+ [ "person:"+ , " name: John"+ ])+ ]+ <*> switch' [ long "debug", help "Enable debug", env "DEBUG", conf "debug", example "# enable debug\ndebug: true"] <*> switch' [short 'v', long "verbose", conf "verbose"] <*> ( switch' [short 'a', long "apple", help "Use apples"] <|> switch' [short 'b', long "banana", help "Use bananas"])
src/Mdoc/Examples/Person.hs view
@@ -7,7 +7,9 @@ -- Stability : experimental -- Portability : POSIX module Mdoc.Examples.Person- ( person5+ ( Person (..)+ , Address (..)+ , person5 ) where import Mdoc.Prelude
src/Mdoc/Optics.hs view
@@ -10,6 +10,7 @@ ( field -- * Missing Optics+ , head1 , last1 -- * Application@@ -38,6 +39,9 @@ import Data.Generics.Product.Fields import Optics++head1 :: Lens' (NonEmpty a) a+head1 = lens head $ \x y -> y :| tail x last1 :: Lens' (NonEmpty a) a last1 = lens last $ \x y -> init x |: y
src/OptEnvConf/Mdoc.hs view
@@ -58,6 +58,7 @@ import Mdoc.Data.Option import Mdoc.Data.Optionality import Mdoc.Data.Page+import Mdoc.Optics import Mdoc.Syntax import OptEnvConf (CommandDoc (..), Parser, SetDoc (..)) import OptEnvConf.Args (Dashed (..))@@ -88,7 +89,7 @@ , Endo . addOption <$> traverse setDocToOption d , Endo . addArgument <$> traverse (setDocToArgument index) d , Endo . addEnvVar <$> traverse setDocToEnvVar d- , Just $ foldMap (Endo . addConfig) $ traverse setDocToConfigs d+ , Just $ foldMap (Endo . addConfig) $ expandConfigs d ] setDocToFlag :: SetDoc -> Maybe Flag@@ -116,12 +117,12 @@ names <- setDocEnvVars doc pure $ EnvVar {names, argument = setDocMetavar doc <&> fromString} -setDocToConfigs :: SetDoc -> [Config]-setDocToConfigs =- map (.item)- . concatMap (\(keys, js) -> JSONSchema.getConfigs (Just keys) js)- . maybe [] toList- . setDocConfKeys+expandConfigs :: Described SetDoc -> [Described Config]+expandConfigs d = concatMap go $ maybe [] toList $ setDocConfKeys d.item+ where+ go (keys, js) = maybe [] toList $ do+ cs <- nonEmpty $ JSONSchema.getConfigs (Just keys) js+ pure $ cs & head1 %~ (\x -> x.item <$ d) foldSetDocs :: (Int -> Page -> Described SetDoc -> Page)
test/Mdoc/ExamplesSpec.hs view
@@ -77,7 +77,7 @@ pure @IO Golden { output = fixMdocDate mdoc- , encodePretty = show -- unpack . renderPlain . prettyMdoc+ , encodePretty = unpack . renderPlain . prettyMdoc , writeToFile = \fp -> T.writeFile fp . (<> "\n") . renderPlain . prettyMdoc , readFromFile = \fp -> either exitParseError (pure . fixMdocDate)@@ -95,7 +95,7 @@ error "unreachable" where path :: FilePath- path = unpack (head named.names) <.> show section+ path = unpack named.name <.> show section fixMdocDate :: Mdoc -> Mdoc fixMdocDate = updateMdocdateTo $ fromGregorian 2026 9 20