2014-11-27 18:28:01 +01:00
|
|
|
-------------------------------------------------------------------------------
|
2015-04-08 16:27:38 +02:00
|
|
|
-- | This module lets you get API docs for free. It lets you generate
|
2014-11-27 18:28:01 +01:00
|
|
|
-- an 'API' from the type that represents your API using 'docs':
|
|
|
|
--
|
|
|
|
-- @docs :: 'HasDocs' api => 'Proxy' api -> 'API'@
|
|
|
|
--
|
2015-04-08 16:27:38 +02:00
|
|
|
-- Alternatively, if you wish to add one or more introductions to your
|
2015-01-30 05:45:00 +01:00
|
|
|
-- documentation, use 'docsWithIntros':
|
|
|
|
--
|
2015-04-08 16:27:38 +02:00
|
|
|
-- @'docsWithIntros' :: 'HasDocs' api => [DocIntro] -> 'Proxy' api -> 'API'@
|
2015-01-30 05:45:00 +01:00
|
|
|
--
|
|
|
|
-- You can then call 'markdown' on the 'API' value:
|
2014-11-27 18:28:01 +01:00
|
|
|
--
|
2015-04-08 16:27:38 +02:00
|
|
|
-- @'markdown' :: 'API' -> String@
|
2014-11-27 18:28:01 +01:00
|
|
|
--
|
|
|
|
-- or define a custom pretty printer:
|
|
|
|
--
|
|
|
|
-- @yourPrettyDocs :: 'API' -> String -- or blaze-html's HTML, or ...@
|
|
|
|
--
|
|
|
|
-- The only thing you'll need to do will be to implement some classes
|
|
|
|
-- for your captures, get parameters and request or response bodies.
|
|
|
|
--
|
2015-10-08 23:33:32 +02:00
|
|
|
-- See example/greet.hs for an example.
|
2014-11-27 18:28:01 +01:00
|
|
|
module Servant.Docs
|
|
|
|
( -- * 'HasDocs' class and key functions
|
2015-12-10 03:04:47 +01:00
|
|
|
HasDocs(..), docs, pretty, markdown
|
2015-02-07 05:17:39 +01:00
|
|
|
-- * Generating docs with extra information
|
2015-09-21 12:36:57 +02:00
|
|
|
, docsWith, docsWithIntros, docsWithOptions
|
|
|
|
, ExtraInfo(..), extraInfo
|
|
|
|
, DocOptions(..) , defaultDocOptions, maxSamples
|
2014-11-27 18:28:01 +01:00
|
|
|
|
|
|
|
, -- * Classes you need to implement for your types
|
|
|
|
ToSample(..)
|
2015-09-19 01:27:51 +02:00
|
|
|
, toSample
|
|
|
|
, noSamples
|
|
|
|
, singleSample
|
2015-09-21 11:51:00 +02:00
|
|
|
, samples
|
2014-11-27 18:28:01 +01:00
|
|
|
, sampleByteString
|
2015-01-04 16:38:50 +01:00
|
|
|
, sampleByteStrings
|
2014-11-27 18:28:01 +01:00
|
|
|
, ToParam(..)
|
|
|
|
, ToCapture(..)
|
|
|
|
|
|
|
|
, -- * ADTs to represent an 'API'
|
|
|
|
Method(..)
|
|
|
|
, Endpoint, path, method, defEndpoint
|
2015-05-09 16:06:11 +02:00
|
|
|
, API, apiIntros, apiEndpoints, emptyAPI
|
2014-11-27 18:28:01 +01:00
|
|
|
, DocCapture(..), capSymbol, capDesc
|
|
|
|
, DocQueryParam(..), ParamKind(..), paramName, paramValues, paramDesc, paramKind
|
2015-01-23 02:19:37 +01:00
|
|
|
, DocNote(..), noteTitle, noteBody
|
2015-05-09 16:06:11 +02:00
|
|
|
, DocIntro(..), introTitle, introBody
|
2015-04-08 16:27:38 +02:00
|
|
|
, Response(..), respStatus, respTypes, respBody, defResponse
|
2015-02-19 05:29:04 +01:00
|
|
|
, Action, captures, headers, notes, params, rqtypes, rqbody, response, defAction
|
2014-11-27 18:28:01 +01:00
|
|
|
, single
|
|
|
|
) where
|
|
|
|
|
2015-12-10 21:27:15 +01:00
|
|
|
import Servant.Docs.Internal
|
|
|
|
import Servant.Docs.Internal.Pretty
|