Document the type of endpoint a parameter belongs to

Closes #760
This commit is contained in:
Ivan Lazar Miljenovic 2017-07-28 16:31:55 +10:00
parent 213620e56a
commit 89e0a98ac5

View file

@ -529,14 +529,16 @@ markdown api = unlines $
authStr (action ^. authInfo) ++ authStr (action ^. authInfo) ++
capturesStr (action ^. captures) ++ capturesStr (action ^. captures) ++
headersStr (action ^. headers) ++ headersStr (action ^. headers) ++
paramsStr (action ^. params) ++ paramsStr meth (action ^. params) ++
rqbodyStr (action ^. rqtypes) (action ^. rqbody) ++ rqbodyStr (action ^. rqtypes) (action ^. rqbody) ++
responseStr (action ^. response) ++ responseStr (action ^. response) ++
[] []
where str = "## " ++ BSC.unpack (endpoint^.method) where str = "## " ++ BSC.unpack meth
++ " " ++ showPath (endpoint^.path) ++ " " ++ showPath (endpoint^.path)
meth = endpoint ^. method
introsStr :: [DocIntro] -> [String] introsStr :: [DocIntro] -> [String]
introsStr = concatMap introStr introsStr = concatMap introStr
@ -593,23 +595,23 @@ markdown api = unlines $
where headerStr hname = "- This endpoint is sensitive to the value of the **" where headerStr hname = "- This endpoint is sensitive to the value of the **"
++ unpack hname ++ "** HTTP header." ++ unpack hname ++ "** HTTP header."
paramsStr :: [DocQueryParam] -> [String] paramsStr :: HTTP.Method -> [DocQueryParam] -> [String]
paramsStr [] = [] paramsStr _ [] = []
paramsStr l = paramsStr m l =
"#### GET Parameters:" : ("#### " ++ cs m ++ " Parameters:") :
"" : "" :
map paramStr l ++ map (paramStr m) l ++
"" : "" :
[] []
paramStr param = unlines $ paramStr m param = unlines $
("- " ++ param ^. paramName) : ("- " ++ param ^. paramName) :
(if (not (null values) || param ^. paramKind /= Flag) (if (not (null values) || param ^. paramKind /= Flag)
then [" - **Values**: *" ++ intercalate ", " values ++ "*"] then [" - **Values**: *" ++ intercalate ", " values ++ "*"]
else []) ++ else []) ++
(" - **Description**: " ++ param ^. paramDesc) : (" - **Description**: " ++ param ^. paramDesc) :
(if (param ^. paramKind == List) (if (param ^. paramKind == List)
then [" - This parameter is a **list**. All GET parameters with the name " then [" - This parameter is a **list**. All " ++ cs m ++ " parameters with the name "
++ param ^. paramName ++ "[] will forward their values in a list to the handler."] ++ param ^. paramName ++ "[] will forward their values in a list to the handler."]
else []) ++ else []) ++
(if (param ^. paramKind == Flag) (if (param ^. paramKind == Flag)