on master help sign in
adapt to the servant/servant-server split
commit2d2c46ea121d46d71df64fc623fa6880b25123d2 authorAlp Mestanogullari <alpmestan@gmail.com> dateWed 10 Dec 2014, 16:43 (12 years ago) parentd831cf9
5 files changed+60−59
Setup.hs+2 docs.sh+52 example/greet.hs+2−1 servant-docs.cabal+3−57 src/Servant/Docs.hs+1−1
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 @@
44{-# LANGUAGE FlexibleInstances #-}
55{-# LANGUAGE OverloadedStrings #-}
66import Data.Aeson
7+import Data.Proxy
78import Data.Text
89import GHC.Generics
9−import Servant
10+import Servant.API
1011import Servant.Docs
1112
1213-- * Example
servant-docs.cabal+3−57
@@ -1,64 +1,10 @@
11name: servant-docs
2−version: 0.2
2+version: 0.2.1
33synopsis: generate API docs for your servant webservice
44description:
55 Library for generating API docs from a servant API definition.
66 .
7− Runnable example below that prints API docs in markdown.
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
7+ Runnable example <https://github.com/haskell-servant/servant-docs/blob/master/example/greet.hs here>.
628license: BSD3
639license-file: LICENSE
6410author: Alp Mestanogullari, Sönke Hahn, Julian K. Arni
@@ -83,7 +29,7 @@ library
8329 , bytestring
8430 , hashable
8531 , lens
86− , servant >= 0.2
32+ , servant >= 0.2.1
8733 , string-conversions
8834 , system-filepath
8935 , text
src/Servant/Docs.hs+1−1
@@ -119,7 +119,7 @@ import Data.Text (Text, pack, unpack)
119119import Data.String.Conversions
120120import GHC.Generics
121121import GHC.TypeLits
122−import Servant
122+import Servant.API
123123
124124import qualified Data.HashMap.Strict as HM
125125