Change HasDocs instances for Summary and Description

- if a description follows a summary, the summary is used as a title and the
lines of description form a body.

- if a description occurs without a preceding summary, it's first line is used
  as a title, and the remainder are used as a body.
This commit is contained in:
Tim Emiola 2018-08-25 10:02:14 +09:00
parent e50dcbaa63
commit 73e11a5e6c

View file

@ -930,6 +930,17 @@ instance HasDocs Raw where
docsFor _proxy (endpoint, action) _ =
single endpoint action
instance (KnownSymbol summ, KnownSymbol desc, HasDocs api)
=> HasDocs (Summary summ :> Description desc :> api) where
docsFor Proxy (endpoint, action) =
docsFor subApiP (endpoint, action')
where subApiP = Proxy :: Proxy api
action' = over notes (|> note) action
note = DocNote title body
title = symbolVal (Proxy :: Proxy summ)
body = lines $ symbolVal (Proxy :: Proxy desc)
instance (KnownSymbol desc, HasDocs api)
=> HasDocs (Description desc :> api) where
@ -939,17 +950,20 @@ instance (KnownSymbol desc, HasDocs api)
where subApiP = Proxy :: Proxy api
action' = over notes (|> note) action
note = DocNote (symbolVal (Proxy :: Proxy desc)) []
description = symbolVal (Proxy :: Proxy desc)
note = mkNote $ lines $ description
mkNote (x:xs) = DocNote x xs
mkNote [] = DocNote description []
instance (KnownSymbol desc, HasDocs api)
=> HasDocs (Summary desc :> api) where
instance (KnownSymbol summ, HasDocs api)
=> HasDocs (Summary summ :> api) where
docsFor Proxy (endpoint, action) =
docsFor subApiP (endpoint, action')
where subApiP = Proxy :: Proxy api
action' = over notes (|> note) action
note = DocNote (symbolVal (Proxy :: Proxy desc)) []
note = DocNote (symbolVal (Proxy :: Proxy summ)) []
-- TODO: We use 'AllMimeRender' here because we need to be able to show the
-- example data. However, there's no reason to believe that the instances of