diff options
author | simonmar <unknown> | 2005-02-02 16:23:04 +0000 |
---|---|---|
committer | simonmar <unknown> | 2005-02-02 16:23:04 +0000 |
commit | d8450a233a8e9e0fabcd34e9daf53c82db4dd3bd (patch) | |
tree | 4d05856cf7d2181061b6deb5931a34756dec57c4 /src/HaddockHtml.hs | |
parent | a8c82f239a7fa8940abb35c32b82b4ebec9f6761 (diff) |
[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.
Diffstat (limited to 'src/HaddockHtml.hs')
-rw-r--r-- | src/HaddockHtml.hs | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/HaddockHtml.hs b/src/HaddockHtml.hs index ced6e351..b02caf5b 100644 --- a/src/HaddockHtml.hs +++ b/src/HaddockHtml.hs @@ -40,7 +40,7 @@ import System.IO ( IOMode(..), hClose, hGetBuf, hPutBuf ) ppHtml :: String -> Maybe String -- package -> Maybe String - -> [(Module, Interface)] + -> [Interface] -> FilePath -- destination directory -> Maybe Doc -- prologue text, maybe -> Maybe String -- the Html Help format (--html-help) @@ -52,11 +52,11 @@ ppHtml doctitle maybe_package source_url ifaces odir prologue maybe_html_help_fo maybe_contents_url maybe_index_url = do let visible_ifaces = filter visible ifaces - visible (_, i) = OptHide `notElem` iface_options i + visible i = OptHide `notElem` iface_options i when (not (isJust maybe_contents_url)) $ ppHtmlContents odir doctitle maybe_package maybe_html_help_format maybe_index_url - [ (m,iface{iface_package=Nothing}) | (m,iface) <- visible_ifaces ] + [ iface{iface_package=Nothing} | iface <- visible_ifaces ] -- we don't want to display the packages in a single-package contents prologue @@ -72,7 +72,7 @@ ppHtml doctitle maybe_package source_url ifaces odir prologue maybe_html_help_fo ppHtmlHelpFiles :: String -- doctitle -> Maybe String -- package - -> [(Module, Interface)] + -> [Interface] -> FilePath -- destination directory -> Maybe String -- the Html Help format (--html-help) -> [FilePath] -- external packages paths @@ -80,7 +80,7 @@ ppHtmlHelpFiles ppHtmlHelpFiles doctitle maybe_package ifaces odir maybe_html_help_format pkg_paths = do let visible_ifaces = filter visible ifaces - visible (_, i) = OptHide `notElem` iface_options i + visible i = OptHide `notElem` iface_options i -- Generate index and contents page for Html Help if requested case maybe_html_help_format of @@ -217,12 +217,14 @@ ppHtmlContents -> Maybe String -> Maybe String -> Maybe String - -> [(Module,Interface)] -> Maybe Doc + -> [Interface] -> Maybe Doc -> IO () ppHtmlContents odir doctitle maybe_package maybe_html_help_format maybe_index_url mdls prologue = do let tree = mkModuleTree - [(mod,iface_package iface,toDescription iface) | (mod,iface) <- mdls] + [(iface_module iface, + iface_package iface, + toDescription iface) | iface <- mdls] html = header (documentCharacterEncoding +++ @@ -313,7 +315,7 @@ ppHtmlIndex :: FilePath -> Maybe String -> Maybe String -> Maybe String - -> [(Module,Interface)] + -> [Interface] -> IO () ppHtmlIndex odir doctitle maybe_package maybe_html_help_format maybe_contents_url ifaces = do let html = @@ -386,10 +388,11 @@ ppHtmlIndex odir doctitle maybe_package maybe_html_help_format maybe_contents_ur full_index = Map.fromListWith (flip (Map.unionWith (++))) (concat (map getIfaceIndex ifaces)) - getIfaceIndex (mdl,iface) = + getIfaceIndex iface = [ (hsNameStr nm, - Map.fromList [(orig, [(mdl, not (nm `Map.member` iface_reexported iface))])]) + Map.fromList [(orig, [(mdl, not (nm `elem` iface_reexported iface))])]) | (nm, orig) <- Map.toAscList (iface_env iface) ] + where mdl = iface_module iface indexElt :: (String, Map HsQName [(Module,Bool)]) -> HtmlTable indexElt (str, entities) = @@ -433,10 +436,12 @@ ppHtmlIndex odir doctitle maybe_package maybe_html_help_format maybe_contents_ur ppHtmlModule :: FilePath -> String -> Maybe String -> Maybe String -> Maybe String - -> (Module,Interface) -> IO () + -> Interface -> IO () ppHtmlModule odir doctitle source_url - maybe_contents_url maybe_index_url (Module mdl,iface) = do - let html = + maybe_contents_url maybe_index_url iface = do + let + Module mdl = iface_module iface + html = header (documentCharacterEncoding +++ thetitle (toHtml mdl) +++ styleSheet +++ |