on develop help sign in
Adding resource method documentation
commitdb2389457969dd684d6c7a3d404d3147dfbbef4b authorBrendan Hay <brendan.g.hay@gmail.com> dateSat 26 Sep 2015, 15:07 (11 years ago) parent846d081
4 files changed+17−17
gen/src/Gen/AST.hs+6−3 gen/src/Gen/Types.hs+3−2 gen/src/Gen/Types/Id.hs+2−4 gen/template/toc.ede+6−8
gen/src/Gen/AST.hs+6−3
@@ -106,18 +106,21 @@ render svc = do
106106 sub l = \case
107107 t@(Top rs) -> do
108108 let k = nname l
109− t <- Action k <$> pp Print (apiAlias k (nouns t))
109+ t <- Action k Nothing
110+ <$> pp Print (apiAlias k (nouns t))
110111 as <- traverse (uncurry sub) (Map.toList rs) <&> concat
111112 return (t : as)
112113
113114 Sub ms -> do
114115 let k = nname l
115− t <- Action k <$> pp Print (apiAlias k (map (vname l) $ Map.keys ms))
116+ t <- Action k Nothing
117+ <$> pp Print (apiAlias k (map (vname l) $ Map.keys ms))
116118 as <- traverse (uncurry (verb l)) (Map.toList ms)
117119 return (t : as)
118120
119121 verb :: Local -> Local -> Method -> AST Action
120− verb p l m = Action (vname p l) <$> pp Print (verbDecl svc p l m)
122+ verb p l m = Action (vname p l) (_mDescription m)
123+ <$> pp Print (verbDecl svc p l m)
121124
122125flatten :: Service (Fix Schema) Resource -> Service (Schema Id) Resource
123126flatten svc = svc { _svcSchemas = execState run mempty }
gen/src/Gen/Types.hs+3−2
@@ -326,11 +326,12 @@ instance ToJSON Data where
326326 , "lenses" .= ls
327327 ]
328328
329−data Action = Action Name Rendered
329+data Action = Action Name (Maybe Help) Rendered
330330
331331instance ToJSON Action where
332− toJSON (Action n d) = object
332+ toJSON (Action n h d) = object
333333 [ "name" .= Syn n
334+ , "help" .= h
334335 , "decl" .= d
335336 ]
336337
gen/src/Gen/Types/Id.hs+2−4
@@ -2,6 +2,7 @@
22{-# LANGUAGE FlexibleInstances #-}
33{-# LANGUAGE GeneralizedNewtypeDeriving #-}
44{-# LANGUAGE LambdaCase #-}
5+{-# LANGUAGE OverloadedStrings #-}
56
67-- Module : Gen.Types.Id
78-- Copyright : (c) 2015 Brendan Hay
@@ -41,11 +42,8 @@ import Language.Haskell.Exts.Build
4142import Language.Haskell.Exts.Pretty (prettyPrint)
4243import Language.Haskell.Exts.Syntax (Name)
4344
44−aname :: Id -> Name
45−aname = name . Text.unpack . upperHead . idToText
46−
4745nname :: Local -> Name
48−nname = name . Text.unpack . upperHead . local
46+nname = name . Text.unpack . (<> "API") . upperHead . local
4947
5048vname :: Local -> Local -> Name
5149vname p l = name (f p <> f l)
gen/template/toc.ede+6−8
@@ -7,14 +7,9 @@ module {{ moduleName }}
77 (
88 -- * Resources
99 {{ api.name }}
10− {# {% for act in api.actions %} #}
11−
12− {# -- ** {{ act.value.name }} #}
13− {# , {{ act.value.name }} #}
14− {# {% for nv in act.value.actions %} #}
15− {# , {{ nv.value.name }} #}
16− {# {% endfor %} #}
17− {# {% endfor %} #}
10+ {% for action in api.actions %}
11+ , {{ action.value.name }}
12+ {% endfor %}
1813
1914 -- * Types
2015 {% for schema in schemas %}
@@ -48,5 +43,8 @@ TODO
4843{{ api.decl }}
4944{% for action in api.actions %}
5045
46+{% if action.value.help %}
47+{{ action.value.help }}
48+{% endif %}
5149{{ action.value.decl }}
5250{% endfor %}