From d8450a233a8e9e0fabcd34e9daf53c82db4dd3bd Mon Sep 17 00:00:00 2001 From: simonmar Date: Wed, 2 Feb 2005 16:23:04 +0000 Subject: [haddock @ 2005-02-02 16:23:00 by simonmar] Revamp the linking strategy in Haddock. Now name resolution is done in two phases: - first resolve everything to original names, like a Haskell compiler would. - then, figure out the "home" location for every entity, and point all the links to there. The home location is the lowest non-hidden module in the import hierarchy that documents the entity. If there are multiple candidates, one is chosen at random. Also: - Haddock should not generate any HTML with dangling links any more. Unlinked references are just rendered as plain text. - Error reporting is better: if we can't find a link destination for an entity reference, we now emit a warning. --- src/HaddockDevHelp.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/HaddockDevHelp.hs') diff --git a/src/HaddockDevHelp.hs b/src/HaddockDevHelp.hs index 51e96ea0..390fb6f3 100644 --- a/src/HaddockDevHelp.hs +++ b/src/HaddockDevHelp.hs @@ -10,11 +10,13 @@ import Data.Maybe ( fromMaybe ) import Text.PrettyPrint -ppDevHelpFile :: FilePath -> String -> Maybe String -> [(Module,Interface)] -> IO () +ppDevHelpFile :: FilePath -> String -> Maybe String -> [Interface] -> IO () ppDevHelpFile odir doctitle maybe_package ifaces = do let devHelpFile = package++".devhelp" - tree = mkModuleTree [ (mod, iface_package iface, toDescription iface) - | (mod, iface) <- ifaces ] + tree = mkModuleTree [ (iface_module iface, + iface_package iface, + toDescription iface) + | iface <- ifaces ] doc = text "" $$ (text "text doctitle<> @@ -56,9 +58,10 @@ ppDevHelpFile odir doctitle maybe_package ifaces = do index :: [(HsName, [Module])] index = Map.toAscList (foldr getIfaceIndex Map.empty ifaces) - getIfaceIndex (mdl,iface) fm = + getIfaceIndex iface fm = Map.unionWith (++) (Map.fromListWith (flip (++)) [(name, [mdl]) | (name, Qual mdl' _) <- Map.toAscList (iface_env iface), mdl == mdl']) fm - + where mdl = iface_module iface + ppList [] = empty ppList ((name,refs):mdls) = ppReference name refs $$ -- cgit v1.2.3