@@ -163,7 +163,7 @@ data DocNote = DocNote
164-- These are intended to be built using extraInfo.
164-- These are intended to be built using extraInfo.
165-- Multiple ExtraInfo may be combined with the monoid instance.
165-- Multiple ExtraInfo may be combined with the monoid instance.
166−newtype ExtraInfo layout = ExtraInfo (HashMap Endpoint Action)
166+newtype ExtraInfo api = ExtraInfo (HashMap Endpoint Action)
167instance Monoid (ExtraInfo a) where
167instance Monoid (ExtraInfo a) where
168 mempty = ExtraInfo mempty
168 mempty = ExtraInfo mempty
169 ExtraInfo a `mappend` ExtraInfo b =
169 ExtraInfo a `mappend` ExtraInfo b =
@@ -300,11 +300,11 @@ makeLenses ''Action
300-- default way to create documentation.
300-- default way to create documentation.
302-- prop> docs == docsWithOptions defaultDocOptions
302-- prop> docs == docsWithOptions defaultDocOptions
303−docs :: HasDocs layout => Proxy layout -> API
303+docs :: HasDocs api => Proxy api -> API
304docs p = docsWithOptions p defaultDocOptions
304docs p = docsWithOptions p defaultDocOptions
306-- | Generate the docs for a given API that implements 'HasDocs'.
306-- | Generate the docs for a given API that implements 'HasDocs'.
307−docsWithOptions :: HasDocs layout => Proxy layout -> DocOptions -> API
307+docsWithOptions :: HasDocs api => Proxy api -> DocOptions -> API
308docsWithOptions p = docsFor p (defEndpoint, defAction)
308docsWithOptions p = docsFor p (defEndpoint, defAction)
310-- | Closed type family, check if endpoint is exactly within API.
310-- | Closed type family, check if endpoint is exactly within API.
@@ -316,7 +316,7 @@ type family IsIn (endpoint :: *) (api :: *) :: Constraint where
316 IsIn (e :> sa) (e :> sb) = IsIn sa sb
316 IsIn (e :> sa) (e :> sb) = IsIn sa sb
317 IsIn e e = ()
317 IsIn e e = ()
319−-- | Create an 'ExtraInfo' that is garunteed to be within the given API layout.
319+-- | Create an 'ExtraInfo' that is guaranteed to be within the given API layout.
321-- The safety here is to ensure that you only add custom documentation to an
321-- The safety here is to ensure that you only add custom documentation to an
322-- endpoint that actually exists within your API.
322-- endpoint that actually exists within your API.
@@ -329,8 +329,8 @@ type family IsIn (endpoint :: *) (api :: *) :: Constraint where
329-- > , DocNote "Second secton" ["And some more"]
329-- > , DocNote "Second secton" ["And some more"]
332−extraInfo :: (IsIn endpoint layout, HasLink endpoint, HasDocs endpoint)
332+extraInfo :: (IsIn endpoint api, HasLink endpoint, HasDocs endpoint)
333− => Proxy endpoint -> Action -> ExtraInfo layout
333+ => Proxy endpoint -> Action -> ExtraInfo api
334extraInfo p action =
334extraInfo p action =
335 let api = docsFor p (defEndpoint, defAction) defaultDocOptions
335 let api = docsFor p (defEndpoint, defAction) defaultDocOptions
336 -- Assume one endpoint, HasLink constraint means that we should only ever
336 -- Assume one endpoint, HasLink constraint means that we should only ever
@@ -349,7 +349,7 @@ extraInfo p action =
349-- 'extraInfo'.
349-- 'extraInfo'.
351-- If you only want to add an introduction, use 'docsWithIntros'.
351-- If you only want to add an introduction, use 'docsWithIntros'.
352−docsWith :: HasDocs layout => DocOptions -> [DocIntro] -> ExtraInfo layout -> Proxy layout -> API
352+docsWith :: HasDocs api => DocOptions -> [DocIntro] -> ExtraInfo api -> Proxy api -> API
353docsWith opts intros (ExtraInfo endpoints) p =
353docsWith opts intros (ExtraInfo endpoints) p =
354 docsWithOptions p opts
354 docsWithOptions p opts
355 & apiIntros <>~ intros
355 & apiIntros <>~ intros
@@ -358,13 +358,13 @@ docsWith opts intros (ExtraInfo endpoints) p =
359-- | Generate the docs for a given API that implements 'HasDocs' with with any
359-- | Generate the docs for a given API that implements 'HasDocs' with with any
360-- number of introduction(s)
360-- number of introduction(s)
361−docsWithIntros :: HasDocs layout => [DocIntro] -> Proxy layout -> API
361+docsWithIntros :: HasDocs api => [DocIntro] -> Proxy api -> API
362docsWithIntros intros = docsWith defaultDocOptions intros mempty
362docsWithIntros intros = docsWith defaultDocOptions intros mempty
364-- | The class that abstracts away the impact of API combinators
364-- | The class that abstracts away the impact of API combinators
365-- on documentation generation.
365-- on documentation generation.
366−class HasDocs layout where
366+class HasDocs api where
367− docsFor :: Proxy layout -> (Endpoint, Action) -> DocOptions -> API
367+ docsFor :: Proxy api -> (Endpoint, Action) -> DocOptions -> API
369-- | The class that lets us display a sample input or output in the supported
369-- | The class that lets us display a sample input or output in the supported
370-- content-types when generating documentation for endpoints that either:
370-- content-types when generating documentation for endpoints that either:
@@ -675,26 +675,26 @@ markdown api = unlines $
675-- | The generated docs for @a ':<|>' b@ just appends the docs
675-- | The generated docs for @a ':<|>' b@ just appends the docs
676-- for @a@ with the docs for @b@.
676-- for @a@ with the docs for @b@.
677instance OVERLAPPABLE_
677instance OVERLAPPABLE_
678− (HasDocs layout1, HasDocs layout2)
678+ (HasDocs a, HasDocs b)
679− => HasDocs (layout1 :<|> layout2) where
679+ => HasDocs (a :<|> b) where
681 docsFor Proxy (ep, action) = docsFor p1 (ep, action) <> docsFor p2 (ep, action)
681 docsFor Proxy (ep, action) = docsFor p1 (ep, action) <> docsFor p2 (ep, action)
683− where p1 :: Proxy layout1
683+ where p1 :: Proxy a
684 p1 = Proxy
684 p1 = Proxy
686− p2 :: Proxy layout2
686+ p2 :: Proxy b
687 p2 = Proxy
687 p2 = Proxy
689-- | @"books" :> 'Capture' "isbn" Text@ will appear as
689-- | @"books" :> 'Capture' "isbn" Text@ will appear as
690-- @/books/:isbn@ in the docs.
690-- @/books/:isbn@ in the docs.
691−instance (KnownSymbol sym, ToCapture (Capture sym a), HasDocs sublayout)
691+instance (KnownSymbol sym, ToCapture (Capture sym a), HasDocs api)
692− => HasDocs (Capture sym a :> sublayout) where
692+ => HasDocs (Capture sym a :> api) where
694 docsFor Proxy (endpoint, action) =
694 docsFor Proxy (endpoint, action) =
695− docsFor sublayoutP (endpoint', action')
695+ docsFor subApiP (endpoint', action')
697− where sublayoutP = Proxy :: Proxy sublayout
697+ where subApiP = Proxy :: Proxy api
698 captureP = Proxy :: Proxy (Capture sym a)
698 captureP = Proxy :: Proxy (Capture sym a)
700 action' = over captures (|> toCapture captureP) action
700 action' = over captures (|> toCapture captureP) action
@@ -736,43 +736,43 @@ instance OVERLAPPING_
736 status = fromInteger $ natVal (Proxy :: Proxy status)
736 status = fromInteger $ natVal (Proxy :: Proxy status)
737 p = Proxy :: Proxy a
737 p = Proxy :: Proxy a
739−instance (KnownSymbol sym, HasDocs sublayout)
739+instance (KnownSymbol sym, HasDocs api)
740− => HasDocs (Header sym a :> sublayout) where
740+ => HasDocs (Header sym a :> api) where
741 docsFor Proxy (endpoint, action) =
741 docsFor Proxy (endpoint, action) =
742− docsFor sublayoutP (endpoint, action')
742+ docsFor subApiP (endpoint, action')
744− where sublayoutP = Proxy :: Proxy sublayout
744+ where subApiP = Proxy :: Proxy api
745 action' = over headers (|> headername) action
745 action' = over headers (|> headername) action
746 headername = T.pack $ symbolVal (Proxy :: Proxy sym)
746 headername = T.pack $ symbolVal (Proxy :: Proxy sym)
748−instance (KnownSymbol sym, ToParam (QueryParam sym a), HasDocs sublayout)
748+instance (KnownSymbol sym, ToParam (QueryParam sym a), HasDocs api)
749− => HasDocs (QueryParam sym a :> sublayout) where
749+ => HasDocs (QueryParam sym a :> api) where
751 docsFor Proxy (endpoint, action) =
751 docsFor Proxy (endpoint, action) =
752− docsFor sublayoutP (endpoint, action')
752+ docsFor subApiP (endpoint, action')
754− where sublayoutP = Proxy :: Proxy sublayout
754+ where subApiP = Proxy :: Proxy api
755 paramP = Proxy :: Proxy (QueryParam sym a)
755 paramP = Proxy :: Proxy (QueryParam sym a)
756 action' = over params (|> toParam paramP) action
756 action' = over params (|> toParam paramP) action
758−instance (KnownSymbol sym, ToParam (QueryParams sym a), HasDocs sublayout)
758+instance (KnownSymbol sym, ToParam (QueryParams sym a), HasDocs api)
759− => HasDocs (QueryParams sym a :> sublayout) where
759+ => HasDocs (QueryParams sym a :> api) where
761 docsFor Proxy (endpoint, action) =
761 docsFor Proxy (endpoint, action) =
762− docsFor sublayoutP (endpoint, action')
762+ docsFor subApiP (endpoint, action')
764− where sublayoutP = Proxy :: Proxy sublayout
764+ where subApiP = Proxy :: Proxy api
765 paramP = Proxy :: Proxy (QueryParams sym a)
765 paramP = Proxy :: Proxy (QueryParams sym a)
766 action' = over params (|> toParam paramP) action
766 action' = over params (|> toParam paramP) action
769−instance (KnownSymbol sym, ToParam (QueryFlag sym), HasDocs sublayout)
769+instance (KnownSymbol sym, ToParam (QueryFlag sym), HasDocs api)
770− => HasDocs (QueryFlag sym :> sublayout) where
770+ => HasDocs (QueryFlag sym :> api) where
772 docsFor Proxy (endpoint, action) =
772 docsFor Proxy (endpoint, action) =
773− docsFor sublayoutP (endpoint, action')
773+ docsFor subApiP (endpoint, action')
775− where sublayoutP = Proxy :: Proxy sublayout
775+ where subApiP = Proxy :: Proxy api
776 paramP = Proxy :: Proxy (QueryFlag sym)
776 paramP = Proxy :: Proxy (QueryFlag sym)
777 action' = over params (|> toParam paramP) action
777 action' = over params (|> toParam paramP) action
@@ -785,49 +785,49 @@ instance HasDocs Raw where
785-- example data. However, there's no reason to believe that the instances of
785-- example data. However, there's no reason to believe that the instances of
786-- 'AllMimeUnrender' and 'AllMimeRender' actually agree (or to suppose that
786-- 'AllMimeUnrender' and 'AllMimeRender' actually agree (or to suppose that
787-- both are even defined) for any particular type.
787-- both are even defined) for any particular type.
788−instance (ToSample a, AllMimeRender (ct ': cts) a, HasDocs sublayout)
788+instance (ToSample a, AllMimeRender (ct ': cts) a, HasDocs api)
789− => HasDocs (ReqBody (ct ': cts) a :> sublayout) where
789+ => HasDocs (ReqBody (ct ': cts) a :> api) where
791 docsFor Proxy (endpoint, action) =
791 docsFor Proxy (endpoint, action) =
792− docsFor sublayoutP (endpoint, action')
792+ docsFor subApiP (endpoint, action')
794− where sublayoutP = Proxy :: Proxy sublayout
794+ where subApiP = Proxy :: Proxy api
795 action' = action & rqbody .~ sampleByteString t p
795 action' = action & rqbody .~ sampleByteString t p
796 & rqtypes .~ allMime t
796 & rqtypes .~ allMime t
797 t = Proxy :: Proxy (ct ': cts)
797 t = Proxy :: Proxy (ct ': cts)
798 p = Proxy :: Proxy a
798 p = Proxy :: Proxy a
800−instance (KnownSymbol path, HasDocs sublayout) => HasDocs (path :> sublayout) where
800+instance (KnownSymbol path, HasDocs api) => HasDocs (path :> api) where
802 docsFor Proxy (endpoint, action) =
802 docsFor Proxy (endpoint, action) =
803− docsFor sublayoutP (endpoint', action)
803+ docsFor subApiP (endpoint', action)
805− where sublayoutP = Proxy :: Proxy sublayout
805+ where subApiP = Proxy :: Proxy api
806 endpoint' = endpoint & path <>~ [symbolVal pa]
806 endpoint' = endpoint & path <>~ [symbolVal pa]
807 pa = Proxy :: Proxy path
807 pa = Proxy :: Proxy path
809−instance HasDocs sublayout => HasDocs (RemoteHost :> sublayout) where
809+instance HasDocs api => HasDocs (RemoteHost :> api) where
810 docsFor Proxy ep =
810 docsFor Proxy ep =
811− docsFor (Proxy :: Proxy sublayout) ep
811+ docsFor (Proxy :: Proxy api) ep
813−instance HasDocs sublayout => HasDocs (IsSecure :> sublayout) where
813+instance HasDocs api => HasDocs (IsSecure :> api) where
814 docsFor Proxy ep =
814 docsFor Proxy ep =
815− docsFor (Proxy :: Proxy sublayout) ep
815+ docsFor (Proxy :: Proxy api) ep
817−instance HasDocs sublayout => HasDocs (HttpVersion :> sublayout) where
817+instance HasDocs api => HasDocs (HttpVersion :> api) where
818 docsFor Proxy ep =
818 docsFor Proxy ep =
819− docsFor (Proxy :: Proxy sublayout) ep
819+ docsFor (Proxy :: Proxy api) ep
821−instance HasDocs sublayout => HasDocs (Vault :> sublayout) where
821+instance HasDocs api => HasDocs (Vault :> api) where
822 docsFor Proxy ep =
822 docsFor Proxy ep =
823− docsFor (Proxy :: Proxy sublayout) ep
823+ docsFor (Proxy :: Proxy api) ep
825−instance HasDocs sublayout => HasDocs (WithNamedContext name context sublayout) where
825+instance HasDocs api => HasDocs (WithNamedContext name context api) where
826− docsFor Proxy = docsFor (Proxy :: Proxy sublayout)
826+ docsFor Proxy = docsFor (Proxy :: Proxy api)
828−instance (ToAuthInfo (BasicAuth realm usr), HasDocs sublayout) => HasDocs (BasicAuth realm usr :> sublayout) where
828+instance (ToAuthInfo (BasicAuth realm usr), HasDocs api) => HasDocs (BasicAuth realm usr :> api) where
829 docsFor Proxy (endpoint, action) =
829 docsFor Proxy (endpoint, action) =
830− docsFor (Proxy :: Proxy sublayout) (endpoint, action')
830+ docsFor (Proxy :: Proxy api) (endpoint, action')
832 authProxy = Proxy :: Proxy (BasicAuth realm usr)
832 authProxy = Proxy :: Proxy (BasicAuth realm usr)
833 action' = over authInfo (|> toAuthInfo authProxy) action
833 action' = over authInfo (|> toAuthInfo authProxy) action