packages feed

mdoc-0.1.0.0: test/Mdoc/Gen/DescriptionSpec.hs

-- |
--
-- Module      : Mdoc.Gen.DescriptionSpec
-- Copyright   : (c) 2026 Patrick Brisbin
-- License     : AGPL-3
-- Maintainer  : pbrisbin@gmail.com
-- Stability   : experimental
-- Portability : POSIX
module Mdoc.Gen.DescriptionSpec
  ( spec
  ) where

import Mdoc.Prelude

import Mdoc.Gen.Config
import Mdoc.Gen.Described
import Mdoc.Gen.Description
import Mdoc.Gen.Optionality
import Mdoc.MdocLine
import Mdoc.Pretty
import Mdoc.Pretty.MdocLine
import Test.Hspec

spec :: Spec
spec = do
  describe "configLines" $ do
    it "renders with literal examples" $ do
      let config =
            Described
              { item =
                  Config
                    { name = "git.push"
                    , schema = Simple "boolean"
                    , exampleLines = Just $ "# disable pushing" :| ["git.push: false"]
                    }
              , optionality = Required
              , multiple = False
              , helpLines = Just $ pure "Push to git remote"
              }

      render (configLines config)
        `shouldBe` mconcat
          [ ".It Cm git.push Ns : Ar boolean\n"
          , "Push to git remote\n"
          , ".Pp\n"
          , "Example:\n"
          , ".Bd -literal -offset indent\n"
          , "# disable pushing\n"
          , "git.push: false\n"
          , ".Ed\n"
          ]

render :: [MdocLine] -> Text
render = renderPlain . vsep . map prettyMdocLine