aboutsummaryrefslogtreecommitdiff
path: root/src/HaddockDevHelp.hs
diff options
context:
space:
mode:
authordavve <davve@dtek.chalmers.se>2006-07-30 21:01:57 +0000
committerdavve <davve@dtek.chalmers.se>2006-07-30 21:01:57 +0000
commit7e00d4646b0ab3694cee32752d2a8bac04317446 (patch)
tree51aa4eaf5dede3de999e1ac6c63c53c1a1587bfe /src/HaddockDevHelp.hs
parentc3f8f4f1ab6ef0e0ba46e838055c938c061b6161 (diff)
Start porting the Html renderer
Diffstat (limited to 'src/HaddockDevHelp.hs')
-rw-r--r--src/HaddockDevHelp.hs32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/HaddockDevHelp.hs b/src/HaddockDevHelp.hs
index c16e474c..511cfe90 100644
--- a/src/HaddockDevHelp.hs
+++ b/src/HaddockDevHelp.hs
@@ -3,20 +3,22 @@ module HaddockDevHelp(ppDevHelpFile) where
import HaddockModuleTree
import HaddockTypes
import HaddockUtil
-import HsSyn2 hiding(Doc)
+import HsSyn2 hiding (Doc, Module)
import qualified Map
+import Module ( moduleString, Module )
+import Name ( Name, nameModule, getOccString )
+
+
import Data.Maybe ( fromMaybe )
import Text.PrettyPrint
-ppDevHelpFile :: FilePath -> String -> Maybe String -> [Interface] -> IO ()
-ppDevHelpFile odir doctitle maybe_package ifaces = do
+ppDevHelpFile :: FilePath -> String -> Maybe String -> [HaddockModule] -> IO ()
+ppDevHelpFile odir doctitle maybe_package modules = do
let devHelpFile = package++".devhelp"
- tree = mkModuleTree [ (iface_module iface,
- iface_package iface,
- toDescription iface)
- | iface <- ifaces ]
+ tree = mkModuleTree [ (hmod_mod mod, hmod_package mod, toDescription mod)
+ | mod <- modules ]
doc =
text "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>" $$
(text "<book xmlns=\"http://www.devhelp.net/book\" title=\""<>text doctitle<>
@@ -55,19 +57,21 @@ ppDevHelpFile odir doctitle maybe_package ifaces = do
(s':ss') = reverse (s:ss)
-- reconstruct the module name
- index :: [(HsName, [Module])]
- index = Map.toAscList (foldr getIfaceIndex Map.empty ifaces)
+ index :: [(Name, [Module])]
+ index = Map.toAscList (foldr getModuleIndex Map.empty modules)
- 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
+ getModuleIndex hmod fm =
+ Map.unionWith (++) (Map.fromListWith (flip (++)) [(name, [mod]) | name <- hmod_exports hmod, nameModule name == mod]) fm
+ where mod = hmod_mod hmod
+ ppList :: [(Name, [Module])] -> Doc
ppList [] = empty
ppList ((name,refs):mdls) =
ppReference name refs $$
ppList mdls
+ ppReference :: Name -> [Module] -> Doc
ppReference name [] = empty
- ppReference name (Module mdl:refs) =
- text "<function name=\""<>text (escapeStr (show name))<>text"\" link=\""<>text (nameHtmlRef mdl name)<>text"\"/>" $$
+ ppReference name (mod:refs) = let modName = moduleString mod in
+ text "<function name=\""<>text (escapeStr (getOccString name))<>text"\" link=\""<>text (nameHtmlRef modName name)<>text"\"/>" $$
ppReference name refs