@@ -16,13 +16,13 @@
17-- @docs :: 'HasDocs' api => 'Proxy' api -> 'API'@
17-- @docs :: 'HasDocs' api => 'Proxy' api -> 'API'@
19−-- You can then call 'printMarkdown' on it:
19+-- You can then call 'markdown' on it:
21−-- @printMarkdown :: 'API' -> IO ()@
21+-- @printMarkdown :: 'API' -> String@
23-- or define a custom pretty printer:
23-- or define a custom pretty printer:
25−-- @yourPrettyDocs :: 'API' -> IO () -- or blaze-html's HTML, or ...@
25+-- @yourPrettyDocs :: 'API' -> String -- or blaze-html's HTML, or ...@
27-- The only thing you'll need to do will be to implement some classes
27-- The only thing you'll need to do will be to implement some classes
28-- for your captures, get parameters and request or response bodies.
28-- for your captures, get parameters and request or response bodies.
@@ -70,7 +70,7 @@
70-- > toCapture _ = DocCapture "greetid" "identifier of the greet msg to remove"
70-- > toCapture _ = DocCapture "greetid" "identifier of the greet msg to remove"
72-- > -- API specification
72-- > -- API specification
73−-- > type TestApi =
73+-- > type TestApi =
74-- > "hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get Greet
74-- > "hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get Greet
75-- > :<|> "greet" :> RQBody Greet :> Post Greet
75-- > :<|> "greet" :> RQBody Greet :> Post Greet
76-- > :<|> "delete" :> Capture "greetid" Text :> Delete
76-- > :<|> "delete" :> Capture "greetid" Text :> Delete
@@ -83,10 +83,10 @@
83-- > greetDocs = docs testApi
83-- > greetDocs = docs testApi
85-- > main :: IO ()
85-- > main :: IO ()
86−-- > main = printMarkdown greetDocs
86+-- > main = putStrLn $ markdown greetDocs
87module Servant.Docs
87module Servant.Docs
88 ( -- * 'HasDocs' class and key functions
88 ( -- * 'HasDocs' class and key functions
89− HasDocs(..), docs, markdown, printMarkdown
89+ HasDocs(..), docs, markdown
91 , -- * Classes you need to implement for your types
91 , -- * Classes you need to implement for your types
92 ToSample(..)
92 ToSample(..)
@@ -355,11 +355,8 @@ class ToParam t where
355class ToCapture c where
355class ToCapture c where
356 toCapture :: Proxy c -> DocCapture
356 toCapture :: Proxy c -> DocCapture
358−-- | Print documentation in Markdown format for
358+-- | Generate documentation in Markdown format for
359−-- the given 'API', on standard output.
359+-- the given 'API'.
360−printMarkdown :: API -> IO ()
361−printMarkdown = print . markdown
363markdown :: API -> String
360markdown :: API -> String
364markdown = unlines . concat . map (uncurry printEndpoint) . HM.toList
361markdown = unlines . concat . map (uncurry printEndpoint) . HM.toList