aboutsummaryrefslogtreecommitdiff
path: root/src/HaddockModuleTree.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/HaddockModuleTree.hs')
-rw-r--r--src/HaddockModuleTree.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/HaddockModuleTree.hs b/src/HaddockModuleTree.hs
index ffc8b98e..e32cb960 100644
--- a/src/HaddockModuleTree.hs
+++ b/src/HaddockModuleTree.hs
@@ -1,15 +1,18 @@
module HaddockModuleTree ( ModuleTree(..), mkModuleTree ) where
-import HaddockTypes ( DocName )
-import GHC ( HsDoc, Name )
-import Module ( Module, moduleString )
+import HaddockTypes ( DocName )
+import GHC ( HsDoc, Name )
+import Module ( Module, moduleNameString, moduleName, modulePackageId )
+import PackageConfig ( packageIdString )
data ModuleTree = Node String Bool (Maybe String) (Maybe (HsDoc Name)) [ModuleTree]
-mkModuleTree :: [(Module, Maybe String, Maybe (HsDoc Name))] -> [ModuleTree]
-mkModuleTree mods =
- foldr fn [] [ (splitModule mod, pkg, short) | (mod,pkg,short) <- mods ]
- where
+mkModuleTree :: Bool -> [(Module, Maybe (HsDoc Name))] -> [ModuleTree]
+mkModuleTree showPkgs mods =
+ foldr fn [] [ (splitModule mod, modPkg mod, short) | (mod, short) <- mods ]
+ where
+ modPkg mod | showPkgs = Just (packageIdString (modulePackageId mod))
+ | otherwise = Nothing
fn (mod,pkg,short) trees = addToTrees mod pkg short trees
addToTrees :: [String] -> Maybe String -> Maybe (HsDoc Name) -> [ModuleTree] -> [ModuleTree]
@@ -29,7 +32,7 @@ mkSubTree [s] pkg short = [Node s True pkg short []]
mkSubTree (s:ss) pkg short = [Node s (null ss) Nothing Nothing (mkSubTree ss pkg short)]
splitModule :: Module -> [String]
-splitModule mod = split (moduleString mod)
+splitModule mod = split (moduleNameString (moduleName mod))
where split mod0 = case break (== '.') mod0 of
(s1, '.':s2) -> s1 : split s2
(s1, _) -> [s1]