aboutsummaryrefslogtreecommitdiff
path: root/src/HaddockModuleTree.hs
diff options
context:
space:
mode:
authorkrasimir <unknown>2002-07-09 16:33:33 +0000
committerkrasimir <unknown>2002-07-09 16:33:33 +0000
commit9728087302a03143624d030642770f17be1eb097 (patch)
tree0744abe99116d9b9927ff2003f560429702ffe1f /src/HaddockModuleTree.hs
parent44f3891a021a5d10d2f5fc1263ac0633573d86a8 (diff)
[haddock @ 2002-07-09 16:33:31 by krasimir]
'Microsoft HTML Help' support
Diffstat (limited to 'src/HaddockModuleTree.hs')
-rw-r--r--src/HaddockModuleTree.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/HaddockModuleTree.hs b/src/HaddockModuleTree.hs
new file mode 100644
index 00000000..21cd404e
--- /dev/null
+++ b/src/HaddockModuleTree.hs
@@ -0,0 +1,25 @@
+module HaddockModuleTree(ModuleTree(..), mkModuleTree) where
+
+import HsSyn
+
+data ModuleTree = Node String Bool [ModuleTree]
+
+mkModuleTree :: [Module] -> [ModuleTree]
+mkModuleTree mods = foldr addToTrees [] (map splitModule mods)
+
+addToTrees :: [String] -> [ModuleTree] -> [ModuleTree]
+addToTrees [] ts = ts
+addToTrees ss [] = mkSubTree ss
+addToTrees (s1:ss) (t@(Node s2 leaf subs) : ts)
+ | s1 > s2 = t : addToTrees (s1:ss) ts
+ | s1 == s2 = Node s2 (leaf || null ss) (addToTrees ss subs) : ts
+ | otherwise = mkSubTree (s1:ss) ++ t : ts
+
+mkSubTree [] = []
+mkSubTree (s:ss) = [Node s (null ss) (mkSubTree ss)]
+
+splitModule :: Module -> [String]
+splitModule (Module mod) = split mod
+ where split mod = case break (== '.') mod of
+ (s1, '.':s2) -> s1 : split s2
+ (s1, _) -> [s1] \ No newline at end of file