aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock/Backends
diff options
context:
space:
mode:
authorDavid Waern <david.waern@gmail.com>2008-10-16 20:58:42 +0000
committerDavid Waern <david.waern@gmail.com>2008-10-16 20:58:42 +0000
commit6319cccbd95ba15db6f34101577034233cdc8f88 (patch)
treefd67a34a0d8543d73359203bee48832690fcb3f8 /src/Haddock/Backends
parent9a0be441073e25b03aa5fd96d76e15454c8cc76f (diff)
Fix #61
We were not getting docs for re-exported class methods. This was because we were looking up the docs in a map made from the declarations in the current module being rendered. Obviously, re-exported class methods come from another module. Class methods and ATs were the only thing we were looking up using the doc map, everything else we found in the ExporItems. So now I've put subordinate docs in the ExportItem's directly, to make things a bit more consistent. To do this, I added subordinates to the the declarations in the declaration map. This was easy since we were computing subordinates anyway, to store stand-alone in the map. I added a new type synonym 'DeclInfo', which is what we call what is now stored in the map. This little refactoring removes duplicate code to retrieve subordinates and documentation from the HsGroup.
Diffstat (limited to 'src/Haddock/Backends')
-rw-r--r--src/Haddock/Backends/Hoogle.hs2
-rw-r--r--src/Haddock/Backends/Html.hs42
2 files changed, 22 insertions, 22 deletions
diff --git a/src/Haddock/Backends/Hoogle.hs b/src/Haddock/Backends/Hoogle.hs
index 684d4294..dfd72758 100644
--- a/src/Haddock/Backends/Hoogle.hs
+++ b/src/Haddock/Backends/Hoogle.hs
@@ -81,7 +81,7 @@ operator x = x
-- How to print each export
ppExport :: ExportItem Name -> [String]
-ppExport (ExportDecl decl dc _) = doc dc ++ f (unL decl)
+ppExport (ExportDecl decl dc _ _) = doc dc ++ f (unL decl)
where
f (TyClD d@TyData{}) = ppData d
f (TyClD d@ClassDecl{}) = ppClass d
diff --git a/src/Haddock/Backends/Html.hs b/src/Haddock/Backends/Html.hs
index 1f685c3d..579d7896 100644
--- a/src/Haddock/Backends/Html.hs
+++ b/src/Haddock/Backends/Html.hs
@@ -553,7 +553,7 @@ ifaceToHtml maybe_source_url maybe_wiki_url iface
exports = numberSectionHeadings (ifaceRnExportItems iface)
- has_doc (ExportDecl _ doc _) = isJust doc
+ has_doc (ExportDecl _ doc _ _) = isJust doc
has_doc (ExportNoDecl _ _ _) = False
has_doc (ExportModule _) = False
has_doc _ = True
@@ -630,8 +630,8 @@ numberSectionHeadings exports = go 1 exports
processExport :: Bool -> LinksInfo -> DocMap -> (ExportItem DocName) -> HtmlTable
processExport _ _ _ (ExportGroup lev id0 doc)
= ppDocGroup lev (namedAnchor id0 << docToHtml doc)
-processExport summary links docMap (ExportDecl decl doc insts)
- = ppDecl summary links decl doc insts docMap
+processExport summary links docMap (ExportDecl decl doc subdocs insts)
+ = ppDecl summary links decl doc insts docMap subdocs
processExport summmary _ _ (ExportNoDecl _ y [])
= declBox (ppDocName y)
processExport summmary _ _ (ExportNoDecl _ y subs)
@@ -660,9 +660,10 @@ declWithDoc False links loc nm (Just doc) html_decl =
topDeclBox links loc nm html_decl </> docBox (docToHtml doc)
+-- TODO: use DeclInfo DocName or something
ppDecl :: Bool -> LinksInfo -> LHsDecl DocName ->
- Maybe (HsDoc DocName) -> [InstHead DocName] -> DocMap -> HtmlTable
-ppDecl summ links (L loc decl) mbDoc instances docMap = case decl of
+ Maybe (HsDoc DocName) -> [InstHead DocName] -> DocMap -> [(DocName, HsDoc DocName)] -> HtmlTable
+ppDecl summ links (L loc decl) mbDoc instances docMap subdocs = case decl of
TyClD d@(TyFamily {}) -> ppTyFam summ False links loc mbDoc d
TyClD d@(TyData {})
| Nothing <- tcdTyPats d -> ppDataDecl summ links instances loc mbDoc d
@@ -670,7 +671,7 @@ ppDecl summ links (L loc decl) mbDoc instances docMap = case decl of
TyClD d@(TySynonym {})
| Nothing <- tcdTyPats d -> ppTySyn summ links loc mbDoc d
| Just _ <- tcdTyPats d -> ppTyInst summ False links loc mbDoc d
- TyClD d@(ClassDecl {}) -> ppClassDecl summ links instances loc mbDoc docMap d
+ TyClD d@(ClassDecl {}) -> ppClassDecl summ links instances loc mbDoc docMap subdocs d
SigD (TypeSig (L _ n) (L _ t)) -> ppFunSig summ links loc mbDoc n t
ForD d -> ppFor summ links loc mbDoc d
InstD d -> Html.emptyTable
@@ -872,13 +873,11 @@ ppTyInstHeader summary associated decl =
--------------------------------------------------------------------------------
-ppAssocType :: Bool -> LinksInfo -> DocMap -> LTyClDecl DocName -> HtmlTable
-ppAssocType summ links docMap (L loc decl) =
+ppAssocType :: Bool -> LinksInfo -> Maybe (HsDoc DocName) -> LTyClDecl DocName -> HtmlTable
+ppAssocType summ links doc (L loc decl) =
case decl of
TyFamily {} -> ppTyFam summ True links loc doc decl
TySynonym {} -> ppTySyn summ links loc doc decl
- where
- doc = Map.lookup (docNameOrig $ tcdName decl) docMap
--------------------------------------------------------------------------------
@@ -970,8 +969,8 @@ ppFds fds =
fundep (vars1,vars2) = hsep (map ppDocName vars1) <+> toHtml "->" <+>
hsep (map ppDocName vars2)
-ppShortClassDecl :: Bool -> LinksInfo -> TyClDecl DocName -> SrcSpan -> DocMap -> HtmlTable
-ppShortClassDecl summary links (ClassDecl lctxt lname tvs fds sigs _ ats _) loc docMap =
+ppShortClassDecl :: Bool -> LinksInfo -> TyClDecl DocName -> SrcSpan -> [(DocName, HsDoc DocName)] -> HtmlTable
+ppShortClassDecl summary links (ClassDecl lctxt lname tvs fds sigs _ ats _) loc subdocs =
if null sigs && null ats
then (if summary then declBox else topDeclBox links loc nm) hdr
else (if summary then declBox else topDeclBox links loc nm) (hdr <+> keyword "where")
@@ -980,12 +979,12 @@ ppShortClassDecl summary links (ClassDecl lctxt lname tvs fds sigs _ ats _) loc
bodyBox <<
aboves
(
- map (ppAssocType summary links docMap) ats ++
+ [ ppAssocType summary links doc at | at <- ats
+ , let doc = lookup (tcdName $ unL at) subdocs ] ++
- [ ppFunSig summary links loc mbDoc n typ
+ [ ppFunSig summary links loc doc n typ
| L _ (TypeSig (L _ n) (L _ typ)) <- sigs
- , let mbDoc = Map.lookup (docNameOrig n) docMap ]
-
+ , let doc = lookup n subdocs ]
)
)
where
@@ -995,11 +994,11 @@ ppShortClassDecl summary links (ClassDecl lctxt lname tvs fds sigs _ ats _) loc
ppClassDecl :: Bool -> LinksInfo -> [InstHead DocName] -> SrcSpan ->
- Maybe (HsDoc DocName) -> DocMap -> TyClDecl DocName ->
+ Maybe (HsDoc DocName) -> DocMap -> [(DocName, HsDoc DocName)] -> TyClDecl DocName ->
HtmlTable
-ppClassDecl summary links instances loc mbDoc docMap
+ppClassDecl summary links instances loc mbDoc docMap subdocs
decl@(ClassDecl lctxt lname ltyvars lfds lsigs _ ats _)
- | summary = ppShortClassDecl summary links decl loc docMap
+ | summary = ppShortClassDecl summary links decl loc subdocs
| otherwise = classheader </> bodyBox << (classdoc </> body </> instancesBit)
where
classheader
@@ -1024,9 +1023,10 @@ ppClassDecl summary links instances loc mbDoc docMap
methodTable =
abovesSep s8 [ ppFunSig summary links loc doc n typ
| L _ (TypeSig (L _ n) (L _ typ)) <- lsigs
- , let doc = Map.lookup (docNameOrig n) docMap ]
+ , let doc = lookup n subdocs ]
- atTable = abovesSep s8 $ map (ppAssocType summary links docMap) ats
+ atTable = abovesSep s8 $ [ ppAssocType summary links doc at | at <- ats
+ , let doc = lookup (tcdName $ unL at) subdocs ]
instId = collapseId (docNameOrig nm)
instancesBit