@@ -298,17 +298,29 @@ defAction =
298single :: Endpoint -> Action -> API
298single :: Endpoint -> Action -> API
299single e a = API mempty (HM.singleton e a)
299single e a = API mempty (HM.singleton e a)
301−-- | How many examples should be shown?
301+-- | How many content-types for each example should be shown?
302−data ShowContentTypes = AllContentTypes | FirstContentType
304+data ShowContentTypes = AllContentTypes -- ^ For each example, show each content type.
305+ | FirstContentType -- ^ For each example, show only one content type.
303 deriving (Eq, Ord, Show, Read, Bounded, Enum)
306 deriving (Eq, Ord, Show, Read, Bounded, Enum)
305-- | Customise how an 'API' is converted into documentation.
308-- | Customise how an 'API' is converted into documentation.
306data RenderingOptions = RenderingOptions
311data RenderingOptions = RenderingOptions
307 { _requestExamples :: !ShowContentTypes
312 { _requestExamples :: !ShowContentTypes
313+ -- ^ How many content types to display for request body examples?
308 , _responseExamples :: !ShowContentTypes
314 , _responseExamples :: !ShowContentTypes
315+ -- ^ How many content types to display for response body examples?
309 } deriving (Show)
316 } deriving (Show)
311-- | Default API generation options.
318-- | Default API generation options.
320+-- All content types are shown for both 'requestExamples' and
321+-- 'responseExamples'.
312defRenderingOptions :: RenderingOptions
324defRenderingOptions :: RenderingOptions
313defRenderingOptions = RenderingOptions
325defRenderingOptions = RenderingOptions
314 { _requestExamples = AllContentTypes
326 { _requestExamples = AllContentTypes
@@ -542,9 +554,32 @@ class ToAuthInfo a where
543-- | Generate documentation in Markdown format for
555-- | Generate documentation in Markdown format for
544-- the given 'API'.
556-- the given 'API'.
558+-- This is equivalent to @'markdownWith' 'defRenderingOptions'@.
545markdown :: API -> String
559markdown :: API -> String
546markdown = markdownWith defRenderingOptions
560markdown = markdownWith defRenderingOptions
562+-- | Generate documentation in Markdown format for
563+-- the given 'API' using the specified options.
565+-- These options allow you to customise aspects such as:
567+-- * Choose how many content-types for each request body example are
568+-- shown with 'requestExamples'.
570+-- * Choose how many content-types for each response body example
571+-- are shown with 'responseExamples'.
573+-- For example, to only show the first content-type of each example:
576+-- markdownWith ('defRenderingOptions'
577+-- & 'requestExamples' '.~' 'FirstContentType'
578+-- & 'responseExamples' '.~' 'FirstContentType' )
548markdownWith :: RenderingOptions -> API -> String
583markdownWith :: RenderingOptions -> API -> String
549markdownWith RenderingOptions{..} api = unlines $
584markdownWith RenderingOptions{..} api = unlines $
550 introsStr (api ^. apiIntros)
585 introsStr (api ^. apiIntros)