mdoc-0.1.0.0: src/Env/Mdoc.hs
-- |
--
-- Module : Env.Mdoc
-- Copyright : (c) 2026 Patrick Brisbin
-- License : AGPL-3
-- Maintainer : pbrisbin@gmail.com
-- Stability : experimental
-- Portability : POSIX
module Env.Mdoc
( addToMan1
) where
import Mdoc.Prelude
import Env.Internal.Free
import Env.Internal.Parser
import Mdoc.Gen.Described
import Mdoc.Gen.EnvVar
import Mdoc.Gen.Man1
import Mdoc.Gen.Optionality
addToMan1 :: Parser e a -> Man1 -> Man1
addToMan1 p base =
base
{ environment = base.environment <> envs
}
where
envs = foldAlt varToEnvVar $ unParser p
varToEnvVar :: VarF e a -> [Described EnvVar]
varToEnvVar v =
[ Described
{ item = EnvVar {names = pure $ varfName v, argument = Nothing}
, optionality = maybe Required Defaulted (varfHelpDef v)
, multiple = False
, helpLines = nonEmpty . lines =<< varfHelp v
}
]