From 02e633a6f9b7ccb53a92a838c1b717ef9f3737fc Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Sun, 27 Sep 2015 20:50:15 +0300 Subject: Generate docs for orphan instances --- haddock-api/src/Haddock/Backends/Xhtml/Decl.hs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'haddock-api/src/Haddock/Backends/Xhtml/Decl.hs') diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs index e536ae4b..031b40e5 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs @@ -16,7 +16,7 @@ module Haddock.Backends.Xhtml.Decl ( ppDecl, - ppTyName, ppTyFamHeader, ppTypeApp, + ppTyName, ppTyFamHeader, ppTypeApp, ppOrphanInstances, tyvarNames ) where @@ -548,6 +548,21 @@ ppInstances links origin instances splice unicode qual ((ppInstHead links splice unicode qual mdoc origin no inst), loc) +ppOrphanInstances :: LinksInfo + -> [DocInstance DocName] + -> Splice -> Unicode -> Qualification + -> Html +ppOrphanInstances links instances splice unicode qual + = subOrphanInstances qual links True (zipWith instDecl [1..] instances) + where + instOrigin :: InstHead name -> InstOrigin name + instOrigin inst = OriginClass (ihdClsName inst) + + instDecl :: Int -> DocInstance DocName -> (SubDecl,Located DocName) + instDecl no (inst, mdoc, loc) = + ((ppInstHead links splice unicode qual mdoc (instOrigin inst) no inst), loc) + + ppInstHead :: LinksInfo -> Splice -> Unicode -> Qualification -> Maybe (MDoc DocName) -> InstOrigin DocName -> Int -> InstHead DocName -- cgit v1.2.3 From 52bc03a00cf57764cdab5124ee2b12acd5ad3780 Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Mon, 28 Sep 2015 16:37:44 +0300 Subject: Fix orphan instance collapsing --- haddock-api/src/Haddock/Backends/Xhtml/Decl.hs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'haddock-api/src/Haddock/Backends/Xhtml/Decl.hs') diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs index 031b40e5..6fed2e1d 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs @@ -545,7 +545,7 @@ ppInstances links origin instances splice unicode qual instName = getOccString origin instDecl :: Int -> DocInstance DocName -> (SubDecl,Located DocName) instDecl no (inst, mdoc, loc) = - ((ppInstHead links splice unicode qual mdoc origin no inst), loc) + ((ppInstHead links splice unicode qual mdoc origin False no inst), loc) ppOrphanInstances :: LinksInfo @@ -560,14 +560,17 @@ ppOrphanInstances links instances splice unicode qual instDecl :: Int -> DocInstance DocName -> (SubDecl,Located DocName) instDecl no (inst, mdoc, loc) = - ((ppInstHead links splice unicode qual mdoc (instOrigin inst) no inst), loc) + ((ppInstHead links splice unicode qual mdoc (instOrigin inst) True no inst), loc) ppInstHead :: LinksInfo -> Splice -> Unicode -> Qualification -> Maybe (MDoc DocName) - -> InstOrigin DocName -> Int -> InstHead DocName + -> InstOrigin DocName + -> Bool -- ^ Is instance orphan + -> Int -- ^ Normal + -> InstHead DocName -> SubDecl -ppInstHead links splice unicode qual mdoc origin no ihd@(InstHead {..}) = +ppInstHead links splice unicode qual mdoc origin orphan no ihd@(InstHead {..}) = case ihdInstType of ClassInst { .. } -> ( subInstHead iid $ ppContextNoLocs clsiCtx unicode qual <+> typ @@ -575,7 +578,7 @@ ppInstHead links splice unicode qual mdoc origin no ihd@(InstHead {..}) = , [subInstDetails iid ats sigs] ) where - iid = instanceId origin no ihd + iid = instanceId origin no orphan ihd sigs = ppInstanceSigs links splice unicode qual clsiSigs ats = ppInstanceAssocTys links splice unicode qual clsiAssocTys TypeInst rhs -> @@ -614,8 +617,9 @@ lookupAnySubdoc :: Eq id1 => id1 -> [(id1, DocForDecl id2)] -> DocForDecl id2 lookupAnySubdoc n = fromMaybe noDocForDecl . lookup n -instanceId :: InstOrigin DocName -> Int -> InstHead DocName -> String -instanceId origin no ihd = concat +instanceId :: InstOrigin DocName -> Int -> Bool -> InstHead DocName -> String +instanceId origin no orphan ihd = concat $ + [ "o:" | orphan ] ++ [ qual origin , ":" ++ getOccString origin , ":" ++ (occNameString . getOccName . ihdClsName) ihd -- cgit v1.2.3