A better name for ApiOptions
It's more about how rendering happens than options for the API.
This commit is contained in:
parent
e3c1c2b464
commit
a693648044
|
@ -25,7 +25,7 @@ module Servant.Docs
|
||||||
( -- * 'HasDocs' class and key functions
|
( -- * 'HasDocs' class and key functions
|
||||||
HasDocs(..), docs, pretty, markdown
|
HasDocs(..), docs, pretty, markdown
|
||||||
-- ** Customising generated documentation
|
-- ** Customising generated documentation
|
||||||
, markdownWith, ApiOptions(..), defApiOptions
|
, markdownWith, RenderingOptions(..), defRenderingOptions
|
||||||
, requestExamples, responseExamples, ShowContentTypes(..)
|
, requestExamples, responseExamples, ShowContentTypes(..)
|
||||||
-- * Generating docs with extra information
|
-- * Generating docs with extra information
|
||||||
, docsWith, docsWithIntros, docsWithOptions
|
, docsWith, docsWithIntros, docsWithOptions
|
||||||
|
|
|
@ -303,14 +303,14 @@ data ShowContentTypes = AllContentTypes | FirstContentType
|
||||||
deriving (Eq, Ord, Show, Read, Bounded, Enum)
|
deriving (Eq, Ord, Show, Read, Bounded, Enum)
|
||||||
|
|
||||||
-- | Customise how an 'API' is converted into documentation.
|
-- | Customise how an 'API' is converted into documentation.
|
||||||
data ApiOptions = ApiOptions
|
data RenderingOptions = RenderingOptions
|
||||||
{ _requestExamples :: !ShowContentTypes
|
{ _requestExamples :: !ShowContentTypes
|
||||||
, _responseExamples :: !ShowContentTypes
|
, _responseExamples :: !ShowContentTypes
|
||||||
} deriving (Show)
|
} deriving (Show)
|
||||||
|
|
||||||
-- | Default API generation options.
|
-- | Default API generation options.
|
||||||
defApiOptions :: ApiOptions
|
defRenderingOptions :: RenderingOptions
|
||||||
defApiOptions = ApiOptions
|
defRenderingOptions = RenderingOptions
|
||||||
{ _requestExamples = AllContentTypes
|
{ _requestExamples = AllContentTypes
|
||||||
, _responseExamples = AllContentTypes
|
, _responseExamples = AllContentTypes
|
||||||
}
|
}
|
||||||
|
@ -326,7 +326,7 @@ makeLenses ''DocIntro
|
||||||
makeLenses ''DocNote
|
makeLenses ''DocNote
|
||||||
makeLenses ''Response
|
makeLenses ''Response
|
||||||
makeLenses ''Action
|
makeLenses ''Action
|
||||||
makeLenses ''ApiOptions
|
makeLenses ''RenderingOptions
|
||||||
|
|
||||||
-- | Generate the docs for a given API that implements 'HasDocs'. This is the
|
-- | Generate the docs for a given API that implements 'HasDocs'. This is the
|
||||||
-- default way to create documentation.
|
-- default way to create documentation.
|
||||||
|
@ -543,10 +543,10 @@ class ToAuthInfo a where
|
||||||
-- | Generate documentation in Markdown format for
|
-- | Generate documentation in Markdown format for
|
||||||
-- the given 'API'.
|
-- the given 'API'.
|
||||||
markdown :: API -> String
|
markdown :: API -> String
|
||||||
markdown = markdownWith defApiOptions
|
markdown = markdownWith defRenderingOptions
|
||||||
|
|
||||||
markdownWith :: ApiOptions -> API -> String
|
markdownWith :: RenderingOptions -> API -> String
|
||||||
markdownWith ApiOptions{..} api = unlines $
|
markdownWith RenderingOptions{..} api = unlines $
|
||||||
introsStr (api ^. apiIntros)
|
introsStr (api ^. apiIntros)
|
||||||
++ (concatMap (uncurry printEndpoint) . sort . HM.toList $ api ^. apiEndpoints)
|
++ (concatMap (uncurry printEndpoint) . sort . HM.toList $ api ^. apiEndpoints)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user