From c9f149c64c44dcc7fa14d30767a205a991510430 Mon Sep 17 00:00:00 2001 From: simonmar Date: Wed, 10 Jul 2002 10:26:11 +0000 Subject: [haddock @ 2002-07-10 10:26:11 by simonmar] Tweaks to the MS Help support: the extra files are now only generated if you ask for them (--ms-help). --- src/HaddockHH.hs | 188 +++++++++++++++++++++++++++---------------------------- 1 file changed, 94 insertions(+), 94 deletions(-) (limited to 'src/HaddockHH.hs') diff --git a/src/HaddockHH.hs b/src/HaddockHH.hs index 05ff9243..5feac3e4 100644 --- a/src/HaddockHH.hs +++ b/src/HaddockHH.hs @@ -1,94 +1,94 @@ -module HaddockHH(ppHHContents, ppHHIndex) where - -import HsSyn hiding(Doc) -import Text.PrettyPrint -import Data.FiniteMap -import HaddockModuleTree -import HaddockUtil -import HaddockTypes - -contentsHHFile = "index.hhc" -indexHHFile = "index.hhk" - -ppHHContents :: FilePath -> [Module] -> IO () -ppHHContents odir mods = do - let tree = mkModuleTree mods - html = - text "" $$ - text "" $$ - text "" $$ - text "" $$ - text "" $$ - text "" $$ - ppModuleTree tree $$ - text "" - writeFile (odir ++ pathSeparator:contentsHHFile) (render html) - where - ppModuleTree :: [ModuleTree] -> Doc - ppModuleTree ts = - text "" $$ - text "" $$ - text "" $$ - text "" - - fn :: [String] -> [ModuleTree] -> Doc - fn ss [x] = ppNode ss x - fn ss (x:xs) = ppNode ss x $$ fn ss xs - - ppNode :: [String] -> ModuleTree -> Doc - ppNode ss (Node s leaf []) = - ppLeaf s ss leaf - ppNode ss (Node s leaf ts) = - ppLeaf s ss leaf $$ - text "" - - ppLeaf s ss isleaf = - text "
  • " <> nest 4 - (text "" $$ - text " text s <> text "\">" $$ - (if isleaf then text " text (moduleHtmlFile "" mod) <> text "\">" else empty) $$ - text "") $+$ - text "
  • " - where - mod = foldr (++) "" (s' : map ('.':) ss') - (s':ss') = reverse (s:ss) - -- reconstruct the module name - -------------------------------- -ppHHIndex :: FilePath -> [(Module,Interface)] -> IO () -ppHHIndex odir ifaces = do - let html = - text "" $$ - text "" $$ - text "" $$ - text "" $$ - text "" $$ - text "" $$ - text "" $$ - text "" - writeFile (odir ++ pathSeparator:indexHHFile) (render html) - where - index :: [(HsName, Module)] - index = fmToList full_index - - iface_indices = map getIfaceIndex ifaces - full_index = foldr1 plusFM iface_indices - - getIfaceIndex (mod,iface) = listToFM - [ (name, mod) | (name, Qual mod' _) <- fmToList (iface_env iface), mod == mod'] - - ppList [] = empty - ppList ((name,Module mod):mods) = - text "
  • " <> nest 4 - (text "" $$ - text " text (show name) <> text "\">" $$ - text " text (moduleHtmlFile "" mod) <> char '#' <> text (show name) <> text "\">" $$ - text "") $+$ - text "
  • " $$ - ppList mods \ No newline at end of file +module HaddockHH(ppHHContents, ppHHIndex) where + +import HsSyn hiding(Doc) +import Pretty +import FiniteMap +import HaddockModuleTree +import HaddockUtil +import HaddockTypes + +contentsHHFile = "index.hhc" +indexHHFile = "index.hhk" + +ppHHContents :: FilePath -> [Module] -> IO () +ppHHContents odir mods = do + let tree = mkModuleTree mods + html = + text "" $$ + text "" $$ + text "" $$ + text "" $$ + text "" $$ + text "" $$ + ppModuleTree tree $$ + text "" + writeFile (odir ++ pathSeparator:contentsHHFile) (render html) + where + ppModuleTree :: [ModuleTree] -> Doc + ppModuleTree ts = + text "" $$ + text "" $$ + text "" $$ + text "" + + fn :: [String] -> [ModuleTree] -> Doc + fn ss [x] = ppNode ss x + fn ss (x:xs) = ppNode ss x $$ fn ss xs + + ppNode :: [String] -> ModuleTree -> Doc + ppNode ss (Node s leaf []) = + ppLeaf s ss leaf + ppNode ss (Node s leaf ts) = + ppLeaf s ss leaf $$ + text "" + + ppLeaf s ss isleaf = + text "
  • " <> nest 4 + (text "" $$ + text " text s <> text "\">" $$ + (if isleaf then text " text (moduleHtmlFile "" mod) <> text "\">" else empty) $$ + text "") $+$ + text "
  • " + where + mod = foldr (++) "" (s' : map ('.':) ss') + (s':ss') = reverse (s:ss) + -- reconstruct the module name + +------------------------------- +ppHHIndex :: FilePath -> [(Module,Interface)] -> IO () +ppHHIndex odir ifaces = do + let html = + text "" $$ + text "" $$ + text "" $$ + text "" $$ + text "" $$ + text "" $$ + text "" $$ + text "" + writeFile (odir ++ pathSeparator:indexHHFile) (render html) + where + index :: [(HsName, Module)] + index = fmToList full_index + + iface_indices = map getIfaceIndex ifaces + full_index = foldr1 plusFM iface_indices + + getIfaceIndex (mod,iface) = listToFM + [ (name, mod) | (name, Qual mod' _) <- fmToList (iface_env iface), mod == mod'] + + ppList [] = empty + ppList ((name,Module mod):mods) = + text "
  • " <> nest 4 + (text "" $$ + text " text (show name) <> text "\">" $$ + text " text (moduleHtmlFile "" mod) <> char '#' <> text (show name) <> text "\">" $$ + text "") $+$ + text "
  • " $$ + ppList mods -- cgit v1.2.3