From 88df578a8573908d665d4597c4c619c29055a277 Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Tue, 28 Jul 2015 23:58:13 +0200 Subject: Rearrange layout of instance methods in generated documentation. --- haddock-api/src/Haddock/Backends/Xhtml/Decl.hs | 39 ++++++++++++++++-------- haddock-api/src/Haddock/Backends/Xhtml/Layout.hs | 2 +- 2 files changed, 27 insertions(+), 14 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 a9f38c14..abcf3eaf 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs @@ -525,26 +525,39 @@ ppInstances links origin instances baseName splice unicode qual where instName = getOccString $ getName baseName instDecl :: Int -> DocInstance DocName -> (SubDecl,Located DocName) - instDecl no (inst, maybeDoc,l) = - ((ppInstHead links splice unicode qual origin no inst, maybeDoc, []),l) + instDecl no (inst, mdoc, loc) = + ((ppInstHead links splice unicode qual mdoc origin no inst), loc) ppInstHead :: LinksInfo -> Splice -> Unicode -> Qualification - -> InstOrigin -> Int -> InstHead DocName - -> Html -ppInstHead links splice unicode qual origin no (InstHead {..}) = + -> Maybe (MDoc DocName) -> InstOrigin -> Int -> InstHead DocName + -> SubDecl +ppInstHead links splice unicode qual mdoc origin no (InstHead {..}) = case ihdInstType of ClassInst { .. } -> - subClsInstance iid hdr mets + ( subInstHead iid $ ppContextNoLocs clsiCtx unicode qual <+> typ + , mdoc + , [subInstMethods iid sigs] + ) where - hdr = ppContextNoLocs clsiCtx unicode qual <+> typ - mets = ppInstanceSigs links splice unicode qual - clsiTyVars ihdTypes clsiSigs iid = instanceId origin no ihdClsName - TypeInst rhs -> keyword "type" <+> typ - <+> maybe noHtml (\t -> equals <+> ppType unicode qual t) rhs - DataInst dd -> keyword "data" <+> typ - <+> ppShortDataDecl False True dd unicode qual + sigs = ppInstanceSigs links splice unicode qual + clsiTyVars ihdTypes clsiSigs + TypeInst rhs -> + (ptype, mdoc, []) + where + ptype = mconcat + [ keyword "type" + , typ + , maybe noHtml (\t -> equals <+> ppType unicode qual t) rhs + ] + DataInst dd -> + (pdata, mdoc, []) + where + pdata = mconcat + [ keyword "data" <+> typ + , ppShortDataDecl False True dd unicode qual + ] where 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 da03985e..0b09e220 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Layout.hs @@ -31,7 +31,7 @@ module Haddock.Backends.Xhtml.Layout ( subConstructors, subEquations, subFields, - subInstances, subClsInstance, + subInstances, subClsInstance, subInstHead, subInstMethods, subMethods, subMinimal, -- cgit v1.2.3