From 2da130a8db8f995c119b544fad807533236cf088 Mon Sep 17 00:00:00 2001 From: RyanGlScott Date: Thu, 11 Feb 2016 15:42:42 -0500 Subject: Collapse type/data family instances by default --- haddock-api/src/Haddock/Backends/Xhtml/Decl.hs | 15 ++++++++++----- haddock-api/src/Haddock/Backends/Xhtml/Layout.hs | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 10 deletions(-) (limited to 'haddock-api') diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs index cb6b8cf2..151589ff 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs @@ -594,20 +594,25 @@ ppInstHead links splice unicode qual mdoc origin orphan no ihd@(InstHead {..}) = , [subInstDetails iid ats sigs] ) where - iid = instanceId origin no orphan ihd sigs = ppInstanceSigs links splice unicode qual clsiSigs ats = ppInstanceAssocTys links splice unicode qual clsiAssocTys TypeInst rhs -> - (ptype, mdoc, []) + ( subInstHead iid ptype + , mdoc + , [subFamInstDetails iid prhs] + ) where - ptype = keyword "type" <+> typ <+> prhs + ptype = keyword "type" <+> typ prhs = maybe noHtml (\t -> equals <+> ppType unicode qual t) rhs DataInst dd -> - (pdata, mdoc, []) + ( subInstHead iid pdata + , mdoc + , [subFamInstDetails iid pdecl]) where - pdata = keyword "data" <+> typ <+> pdecl + pdata = keyword "data" <+> typ pdecl = ppShortDataDecl False True dd unicode qual where + iid = instanceId origin no orphan ihd typ = ppAppNameTypes ihdClsName ihdKinds ihdTypes unicode qual diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs b/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs index 98df09fe..367eec4d 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs @@ -31,7 +31,8 @@ module Haddock.Backends.Xhtml.Layout ( subConstructors, subEquations, subFields, - subInstances, subOrphanInstances, subInstHead, subInstDetails, + subInstances, subOrphanInstances, + subInstHead, subInstDetails, subFamInstDetails, subMethods, subMinimal, @@ -178,7 +179,6 @@ subAssociatedTypes = divSubDecls "associated-types" "Associated Types" . subBloc subConstructors :: Qualification -> [SubDecl] -> Html subConstructors qual = divSubDecls "constructors" "Constructors" . subTable qual - subFields :: Qualification -> [SubDecl] -> Html subFields qual = divSubDecls "fields" "Fields" . subDlist qual @@ -225,10 +225,18 @@ subInstDetails :: String -- ^ Instance unique id (for anchor generation) -> [Html] -- ^ Method contents (pretty-printed signatures) -> Html subInstDetails iid ats mets = - section << (subAssociatedTypes ats <+> subMethods mets) - where - section = thediv ! collapseSection (instAnchorId iid) False "inst-details" + subInstSection iid << (subAssociatedTypes ats <+> subMethods mets) + +subFamInstDetails :: String -- ^ Instance unique id (for anchor generation) + -> Html -- ^ Type or data family instance + -> Html +subFamInstDetails iid fi = + subInstSection iid << declElem fi +subInstSection :: String -- ^ Instance unique id (for anchor generation) + -> Html + -> Html +subInstSection iid = thediv ! collapseSection (instAnchorId iid) False "inst-details" instAnchorId :: String -> String instAnchorId iid = makeAnchorId $ "i:" ++ iid -- cgit v1.2.3 From 1338b5d7c32939de6bbc31af0049477e4f847103 Mon Sep 17 00:00:00 2001 From: RyanGlScott Date: Thu, 11 Feb 2016 20:17:09 -0500 Subject: Ensure expanded family instances render correctly --- haddock-api/src/Haddock/Backends/Xhtml/Decl.hs | 5 +++-- haddock-api/src/Haddock/Backends/Xhtml/Layout.hs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'haddock-api') diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs index 151589ff..66bb21da 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs @@ -603,14 +603,15 @@ ppInstHead links splice unicode qual mdoc origin orphan no ihd@(InstHead {..}) = ) where ptype = keyword "type" <+> typ - prhs = maybe noHtml (\t -> equals <+> ppType unicode qual t) rhs + prhs = ptype <+> maybe noHtml + (\t -> equals <+> ppType unicode qual t) rhs DataInst dd -> ( subInstHead iid pdata , mdoc , [subFamInstDetails iid pdecl]) where pdata = keyword "data" <+> typ - pdecl = ppShortDataDecl False True dd unicode qual + pdecl = pdata <+> ppShortDataDecl False True dd unicode qual where iid = instanceId origin no orphan ihd typ = ppAppNameTypes ihdClsName ihdKinds ihdTypes unicode qual diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs b/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs index 367eec4d..7fab3fea 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs @@ -231,7 +231,7 @@ subFamInstDetails :: String -- ^ Instance unique id (for anchor generation) -> Html -- ^ Type or data family instance -> Html subFamInstDetails iid fi = - subInstSection iid << declElem fi + subInstSection iid << thediv ! [theclass "src"] << fi subInstSection :: String -- ^ Instance unique id (for anchor generation) -> Html -- cgit v1.2.3