A better name for ApiOptions

It's more about how rendering happens than options for the API.
This commit is contained in:
Ivan Lazar Miljenovic 2017-10-06 10:59:00 +11:00
parent e3c1c2b464
commit a693648044
2 changed files with 8 additions and 8 deletions

View file

@ -25,7 +25,7 @@ module Servant.Docs
( -- * 'HasDocs' class and key functions
HasDocs(..), docs, pretty, markdown
-- ** Customising generated documentation
, markdownWith, ApiOptions(..), defApiOptions
, markdownWith, RenderingOptions(..), defRenderingOptions
, requestExamples, responseExamples, ShowContentTypes(..)
-- * Generating docs with extra information
, docsWith, docsWithIntros, docsWithOptions

View file

@ -303,14 +303,14 @@ data ShowContentTypes = AllContentTypes | FirstContentType
deriving (Eq, Ord, Show, Read, Bounded, Enum)
-- | Customise how an 'API' is converted into documentation.
data ApiOptions = ApiOptions
data RenderingOptions = RenderingOptions
{ _requestExamples :: !ShowContentTypes
, _responseExamples :: !ShowContentTypes
} deriving (Show)
-- | Default API generation options.
defApiOptions :: ApiOptions
defApiOptions = ApiOptions
defRenderingOptions :: RenderingOptions
defRenderingOptions = RenderingOptions
{ _requestExamples = AllContentTypes
, _responseExamples = AllContentTypes
}
@ -326,7 +326,7 @@ makeLenses ''DocIntro
makeLenses ''DocNote
makeLenses ''Response
makeLenses ''Action
makeLenses ''ApiOptions
makeLenses ''RenderingOptions
-- | Generate the docs for a given API that implements 'HasDocs'. This is the
-- default way to create documentation.
@ -543,10 +543,10 @@ class ToAuthInfo a where
-- | Generate documentation in Markdown format for
-- the given 'API'.
markdown :: API -> String
markdown = markdownWith defApiOptions
markdown = markdownWith defRenderingOptions
markdownWith :: ApiOptions -> API -> String
markdownWith ApiOptions{..} api = unlines $
markdownWith :: RenderingOptions -> API -> String
markdownWith RenderingOptions{..} api = unlines $
introsStr (api ^. apiIntros)
++ (concatMap (uncurry printEndpoint) . sort . HM.toList $ api ^. apiEndpoints)