aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2018-03-21 01:16:57 -0700
committerAlexander Biehl <alexbiehl@gmail.com>2018-03-21 09:16:57 +0100
commitb7a74c6702f087fde99f44f12d99c66afcf5790d (patch)
tree9f751803eb5c13adfef9e991469a2a9bf1bbb2c6 /haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
parente787b5712157bb0acbb8d886ef793cda5dc1b821 (diff)
Show where instances are defined (#748)
* Indicate source module of instances Above instance, we now also display a link to the module where the instance was defined. This is sometimes helpful in figuring out what to import. * Source module for type/data families too * Remove parens * Accept tests
Diffstat (limited to 'haddock-api/src/Haddock/Backends/Xhtml/Decl.hs')
-rw-r--r--haddock-api/src/Haddock/Backends/Xhtml/Decl.hs18
1 files changed, 10 insertions, 8 deletions
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
index 6e733373..d92bdd3a 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
@@ -566,8 +566,8 @@ ppInstances links origin instances splice unicode qual
where
instName = getOccString origin
instDecl :: Int -> DocInstance DocNameI -> (SubDecl,Located DocName)
- instDecl no (inst, mdoc, loc) =
- ((ppInstHead links splice unicode qual mdoc origin False no inst), loc)
+ instDecl no (inst, mdoc, loc, mdl) =
+ ((ppInstHead links splice unicode qual mdoc origin False no inst mdl), loc)
ppOrphanInstances :: LinksInfo
@@ -581,8 +581,8 @@ ppOrphanInstances links instances splice unicode qual
instOrigin inst = OriginClass (ihdClsName inst)
instDecl :: Int -> DocInstance DocNameI -> (SubDecl,Located DocName)
- instDecl no (inst, mdoc, loc) =
- ((ppInstHead links splice unicode qual mdoc (instOrigin inst) True no inst), loc)
+ instDecl no (inst, mdoc, loc, mdl) =
+ ((ppInstHead links splice unicode qual mdoc (instOrigin inst) True no inst mdl), loc)
ppInstHead :: LinksInfo -> Splice -> Unicode -> Qualification
@@ -591,13 +591,14 @@ ppInstHead :: LinksInfo -> Splice -> Unicode -> Qualification
-> Bool -- ^ Is instance orphan
-> Int -- ^ Normal
-> InstHead DocNameI
+ -> Maybe Module
-> SubDecl
-ppInstHead links splice unicode qual mdoc origin orphan no ihd@(InstHead {..}) =
+ppInstHead links splice unicode qual mdoc origin orphan no ihd@(InstHead {..}) mdl =
case ihdInstType of
ClassInst { .. } ->
( subInstHead iid $ ppContextNoLocs clsiCtx unicode qual HideEmptyContexts <+> typ
, mdoc
- , [subInstDetails iid ats sigs]
+ , [subInstDetails iid ats sigs mname]
)
where
sigs = ppInstanceSigs links splice unicode qual clsiSigs
@@ -605,7 +606,7 @@ ppInstHead links splice unicode qual mdoc origin orphan no ihd@(InstHead {..}) =
TypeInst rhs ->
( subInstHead iid ptype
, mdoc
- , [subFamInstDetails iid prhs]
+ , [subFamInstDetails iid prhs mname]
)
where
ptype = keyword "type" <+> typ
@@ -614,11 +615,12 @@ ppInstHead links splice unicode qual mdoc origin orphan no ihd@(InstHead {..}) =
DataInst dd ->
( subInstHead iid pdata
, mdoc
- , [subFamInstDetails iid pdecl])
+ , [subFamInstDetails iid pdecl mname])
where
pdata = keyword "data" <+> typ
pdecl = pdata <+> ppShortDataDecl False True dd [] unicode qual
where
+ mname = maybe noHtml (\m -> toHtml "Defined in" <+> ppModule m) mdl
iid = instanceId origin no orphan ihd
typ = ppAppNameTypes ihdClsName ihdTypes unicode qual