diff options
author | davve <davve@dtek.chalmers.se> | 2006-07-30 21:01:57 +0000 |
---|---|---|
committer | davve <davve@dtek.chalmers.se> | 2006-07-30 21:01:57 +0000 |
commit | 7e00d4646b0ab3694cee32752d2a8bac04317446 (patch) | |
tree | 51aa4eaf5dede3de999e1ac6c63c53c1a1587bfe /src/HaddockModuleTree.hs | |
parent | c3f8f4f1ab6ef0e0ba46e838055c938c061b6161 (diff) |
Start porting the Html renderer
Diffstat (limited to 'src/HaddockModuleTree.hs')
-rw-r--r-- | src/HaddockModuleTree.hs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/HaddockModuleTree.hs b/src/HaddockModuleTree.hs index 51c0fa17..ffc8b98e 100644 --- a/src/HaddockModuleTree.hs +++ b/src/HaddockModuleTree.hs @@ -1,16 +1,18 @@ -module HaddockModuleTree(ModuleTree(..), mkModuleTree) where +module HaddockModuleTree ( ModuleTree(..), mkModuleTree ) where -import HsSyn2 +import HaddockTypes ( DocName ) +import GHC ( HsDoc, Name ) +import Module ( Module, moduleString ) -data ModuleTree = Node String Bool (Maybe String) (Maybe Doc) [ModuleTree] +data ModuleTree = Node String Bool (Maybe String) (Maybe (HsDoc Name)) [ModuleTree] -mkModuleTree :: [(Module,Maybe String,Maybe Doc)] -> [ModuleTree] +mkModuleTree :: [(Module, Maybe String, Maybe (HsDoc Name))] -> [ModuleTree] mkModuleTree mods = - foldr fn [] [ (splitModule mod, pkg,short) | (mod,pkg,short) <- mods ] + foldr fn [] [ (splitModule mod, pkg, short) | (mod,pkg,short) <- mods ] where fn (mod,pkg,short) trees = addToTrees mod pkg short trees -addToTrees :: [String] -> Maybe String -> Maybe Doc -> [ModuleTree] -> [ModuleTree] +addToTrees :: [String] -> Maybe String -> Maybe (HsDoc Name) -> [ModuleTree] -> [ModuleTree] addToTrees [] pkg short ts = ts addToTrees ss pkg short [] = mkSubTree ss pkg short addToTrees (s1:ss) pkg short (t@(Node s2 leaf node_pkg node_short subs) : ts) @@ -21,13 +23,13 @@ addToTrees (s1:ss) pkg short (t@(Node s2 leaf node_pkg node_short subs) : ts) this_pkg = if null ss then pkg else node_pkg this_short = if null ss then short else node_short -mkSubTree :: [String] -> Maybe String -> Maybe Doc -> [ModuleTree] +mkSubTree :: [String] -> Maybe String -> Maybe (HsDoc Name) -> [ModuleTree] mkSubTree [] pkg short = [] 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 (Module mdl) = split mdl - where split mdl0 = case break (== '.') mdl0 of +splitModule mod = split (moduleString mod) + where split mod0 = case break (== '.') mod0 of (s1, '.':s2) -> s1 : split s2 (s1, _) -> [s1] |