on master help sign in
adapt to the servant/servant-server split
2d2c46eAlp Mestanogullari
Setup.hsnew file+2
@@ -0,0 +1,2 @@
1+import Distribution.Simple
2+main = defaultMain
docs.shnew file+52
@@ -0,0 +1,52 @@
1+SERVANT_DIR=/tmp/servant-docs-gh-pages
2+
3+# Make a temporary clone
4+
5+rm -rf $SERVANT_DIR
6+
7+git clone . $SERVANT_DIR
8+
9+cd $SERVANT_DIR
10+
11+# Make sure to pull the latest
12+
13+git remote add haskell-servant git@github.com:haskell-servant/servant-docs.git
14+
15+git fetch haskell-servant
16+
17+git reset --hard haskell-servant/gh-pages
18+
19+# Clear everything away
20+
21+git rm -rf $SERVANT_DIR/*
22+
23+# Switch back and build the haddocks
24+
25+cd -
26+
27+cabal configure --builddir=$SERVANT_DIR
28+
29+cabal haddock --hoogle --hyperlink-source --html-location='https://hackage.haskell.org/package/$pkg-$version/docs' --builddir=$SERVANT_DIR
30+
31+commit_hash=$(git rev-parse HEAD)
32+
33+# Move the HTML docs to the root
34+
35+cd $SERVANT_DIR
36+
37+rm *
38+rm -rf build
39+mv doc/html/servant-docs/* .
40+rm -r doc/
41+
42+# Add everything
43+
44+git add .
45+
46+git commit -m "Built from $commit_hash"
47+
48+# Push to update the pages
49+
50+git push haskell-servant HEAD:gh-pages
51+
52+rm -rf $SERVANT_DIR
example/greet.hs+2−1
@@ -4,9 +4,10 @@
4{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE OverloadedStrings #-}
5{-# LANGUAGE OverloadedStrings #-}
6import Data.Aeson
6import Data.Aeson
7+import Data.Proxy
7import Data.Text
8import Data.Text
8import GHC.Generics
9import GHC.Generics
9−import Servant
10+import Servant.API
10import Servant.Docs
11import Servant.Docs
11
12
12-- * Example
13-- * Example
servant-docs.cabal+3−57
@@ -1,64 +1,10 @@
1name: servant-docs
1name: servant-docs
2−version: 0.2
2+version: 0.2.1
3synopsis: generate API docs for your servant webservice
3synopsis: generate API docs for your servant webservice
4description:
4description:
5 Library for generating API docs from a servant API definition.
5 Library for generating API docs from a servant API definition.
6 .
6 .
7− Runnable example below that prints API docs in markdown.
7+ Runnable example <https://github.com/haskell-servant/servant-docs/blob/master/example/greet.hs here>.
8− .
9− > {-# LANGUAGE DataKinds #-}
10− > {-# LANGUAGE PolyKinds #-}
11− > {-# LANGUAGE TypeFamilies #-}
12− > {-# LANGUAGE DeriveGeneric #-}
13− > {-# LANGUAGE TypeOperators #-}
14− > {-# LANGUAGE FlexibleInstances #-}
15− > {-# LANGUAGE OverloadedStrings #-}
16− >
17− > import Data.Proxy
18− > import Data.Text
19− > import Servant
20− >
21− > -- our type for a Greeting message
22− > data Greet = Greet { _msg :: Text }
23− > deriving (Generic, Show)
24− >
25− > -- we get our JSON serialization for free
26− > instance FromJSON Greet
27− > instance ToJSON Greet
28− >
29− > -- we provide a sample value for the 'Greet' type
30− > instance ToSample Greet where
31− > toSample = Just g
32− >
33− > where g = Greet "Hello, haskeller!"
34− >
35− > instance ToParam (QueryParam "capital" Bool) where
36− > toParam _ =
37− > DocQueryParam "capital"
38− > ["true", "false"]
39− > "Get the greeting message in uppercase (true) or not (false). Default is false."
40− >
41− > instance ToCapture (Capture "name" Text) where
42− > toCapture _ = DocCapture "name" "name of the person to greet"
43− >
44− > instance ToCapture (Capture "greetid" Text) where
45− > toCapture _ = DocCapture "greetid" "identifier of the greet msg to remove"
46− >
47− > -- API specification
48− > type TestApi =
49− > "hello" :> Capture "name" Text :> QueryParam "capital" Bool :> Get Greet
50− > :<|> "greet" :> RQBody Greet :> Post Greet
51− > :<|> "delete" :> Capture "greetid" Text :> Delete
52− >
53− > testApi :: Proxy TestApi
54− > testApi = Proxy
55− >
56− > -- Generate the Documentation's ADT
57− > greetDocs :: API
58− > greetDocs = docs testApi
59− >
60− > main :: IO ()
61− > main = putStrLn $ markdown greetDocs
62license: BSD3
8license: BSD3
63license-file: LICENSE
9license-file: LICENSE
64author: Alp Mestanogullari, Sönke Hahn, Julian K. Arni
10author: Alp Mestanogullari, Sönke Hahn, Julian K. Arni
@@ -83,7 +29,7 @@ library
83 , bytestring
29 , bytestring
84 , hashable
30 , hashable
85 , lens
31 , lens
86− , servant >= 0.2
32+ , servant >= 0.2.1
87 , string-conversions
33 , string-conversions
88 , system-filepath
34 , system-filepath
89 , text
35 , text
src/Servant/Docs.hs+1−1
@@ -119,7 +119,7 @@ import Data.Text (Text, pack, unpack)
119import Data.String.Conversions
119import Data.String.Conversions
120import GHC.Generics
120import GHC.Generics
121import GHC.TypeLits
121import GHC.TypeLits
122−import Servant
122+import Servant.API
123
123
124import qualified Data.HashMap.Strict as HM
124import qualified Data.HashMap.Strict as HM
125
125