From 6554de2b6751212fdc14e5d814d9f61dfe9eadb5 Mon Sep 17 00:00:00 2001 From: Mark Lentczner Date: Mon, 12 Apr 2010 04:56:27 +0000 Subject: removed declWithDoc and cleaned up data decls in summary --- src/Haddock/Backends/Xhtml/Decl.hs | 43 ++++++++++++++---------------------- src/Haddock/Backends/Xhtml/Layout.hs | 11 --------- 2 files changed, 17 insertions(+), 37 deletions(-) (limited to 'src/Haddock/Backends/Xhtml') diff --git a/src/Haddock/Backends/Xhtml/Decl.hs b/src/Haddock/Backends/Xhtml/Decl.hs index eecbe3b0..d7b463df 100644 --- a/src/Haddock/Backends/Xhtml/Decl.hs +++ b/src/Haddock/Backends/Xhtml/Decl.hs @@ -60,7 +60,8 @@ ppFunSig summary links loc doc docname typ unicode = ppTypeOrFunSig :: Bool -> LinksInfo -> SrcSpan -> DocName -> HsType DocName -> DocForDecl DocName -> (Html, Html, Html) -> Bool -> Html ppTypeOrFunSig summary links loc docname typ (doc, argDocs) (pref1, pref2, sep) unicode - | summary || Map.null argDocs = declWithDoc summary links loc docname doc pref1 + | summary = declElem pref1 + | Map.null argDocs = topDeclElem links loc docname pref1 +++ maybeDocToHtml doc | otherwise = topDeclElem links loc docname pref2 +++ (vanillaTable << ( do_args 0 sep typ @@ -162,8 +163,7 @@ ppTyFam :: Bool -> Bool -> LinksInfo -> SrcSpan -> Maybe (Doc DocName) -> TyClDecl DocName -> Bool -> Html ppTyFam summary associated links loc mbDoc decl unicode - | summary = declWithDoc summary links loc docname mbDoc - (ppTyFamHeader True associated decl unicode) + | summary = declElem (ppTyFamHeader True associated decl unicode) | otherwise = header_ +++ maybeDocToHtml mbDoc +++ instancesBit where @@ -215,8 +215,7 @@ ppTyInst :: Bool -> Bool -> LinksInfo -> SrcSpan -> Maybe (Doc DocName) -> TyClDecl DocName -> Bool -> Html ppTyInst summary associated links loc mbDoc decl unicode - | summary = declWithDoc summary links loc docname mbDoc - (ppTyInstHeader True associated decl unicode) + | summary = declElem(ppTyInstHeader True associated decl unicode) | otherwise = header_ +++ maybeDocToHtml mbDoc where @@ -425,29 +424,24 @@ lookupAnySubdoc n subdocs = case lookup n subdocs of -- TODO: print contexts ppShortDataDecl :: Bool -> LinksInfo -> SrcSpan -> TyClDecl DocName -> Bool -> Html -ppShortDataDecl summary links loc dataDecl unicode +ppShortDataDecl summary _links _loc dataDecl unicode - | [lcon] <- cons, ResTyH98 <- resTy = - ppDataHeader summary dataDecl unicode - <+> equals <+> ppShortConstr summary (unLoc lcon) unicode + | [] <- cons = declElem dataHeader - | [] <- cons = ppDataHeader summary dataDecl unicode + | [lcon] <- cons, ResTyH98 <- resTy = declElem $ + dataHeader <+> equals <+> ppShortConstr summary (unLoc lcon) unicode - | otherwise = foldl (+++) dataHeader $ - case resTy of - ResTyH98 -> zipWith doConstr ('=':repeat '|') cons - ResTyGADT _ -> map doGADTConstr cons - - where - dataHeader = - (if summary then declElem else topDeclElem links loc docname) - ((ppDataHeader summary dataDecl unicode) <+> - case resTy of ResTyGADT _ -> keyword "where"; _ -> empty) + | ResTyH98 <- resTy = declElem dataHeader + +++ unordList (zipWith doConstr ('=':repeat '|') cons) + | otherwise = declElem (dataHeader <+> keyword "where") + +++ unordList (map doGADTConstr cons) + + where + dataHeader = ppDataHeader summary dataDecl unicode doConstr c con = declElem (toHtml [c] <+> ppShortConstr summary (unLoc con) unicode) doGADTConstr con = declElem (ppShortConstr summary (unLoc con) unicode) - docname = unLoc . tcdLName $ dataDecl cons = tcdCons dataDecl resTy = (con_res . unLoc . head) cons @@ -456,11 +450,8 @@ ppDataDecl :: Bool -> LinksInfo -> [DocInstance DocName] -> SrcSpan -> Maybe (Doc DocName) -> TyClDecl DocName -> Bool -> Html ppDataDecl summary links instances subdocs loc mbDoc dataDecl unicode - | summary = declWithDoc summary links loc docname mbDoc - (ppShortDataDecl summary links loc dataDecl unicode) - - | otherwise - = header_ +++ datadoc +++ constrBit +++ instancesBit + | summary = ppShortDataDecl summary links loc dataDecl unicode + | otherwise = header_ +++ datadoc +++ constrBit +++ instancesBit where docname = unLoc . tcdLName $ dataDecl diff --git a/src/Haddock/Backends/Xhtml/Layout.hs b/src/Haddock/Backends/Xhtml/Layout.hs index 93ce0987..124d6150 100644 --- a/src/Haddock/Backends/Xhtml/Layout.hs +++ b/src/Haddock/Backends/Xhtml/Layout.hs @@ -24,17 +24,6 @@ import FastString ( unpackFS ) import GHC -declWithDoc :: Bool -> LinksInfo -> SrcSpan -> DocName -> Maybe (Doc DocName) -> Html -> Html -declWithDoc True _ _ _ _ html_decl = declElem html_decl -declWithDoc False links loc nm doc html_decl = - topDeclElem links loc nm html_decl +++ maybeDocToHtml doc - - -{- -text :: Html -text = strAttr "TEXT" --} - -- a box for displaying code declElem :: Html -> Html declElem = paragraph ! [theclass "decl"] -- cgit v1.2.3