aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsimonmar <unknown>2002-07-10 10:26:11 +0000
committersimonmar <unknown>2002-07-10 10:26:11 +0000
commitc9f149c64c44dcc7fa14d30767a205a991510430 (patch)
tree341044b69fb108f096e479e01f8b1562b31d9421 /src
parent3dc04655c5aa80676489dd45ad6bb7d61013ec5b (diff)
[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).
Diffstat (limited to 'src')
-rw-r--r--src/HaddockHH.hs188
-rw-r--r--src/HaddockHtml.hs13
-rw-r--r--src/Main.hs25
3 files changed, 118 insertions, 108 deletions
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 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">" $$
- text "<HTML>" $$
- text "<HEAD>" $$
- text "<META name=\"GENERATOR\" content=\"Haddock\">" $$
- text "<!-- Sitemap 1.0 -->" $$
- text "</HEAD><BODY>" $$
- ppModuleTree tree $$
- text "</BODY><HTML>"
- writeFile (odir ++ pathSeparator:contentsHHFile) (render html)
- where
- ppModuleTree :: [ModuleTree] -> Doc
- ppModuleTree ts =
- text "<OBJECT type=\"text/site properties\">" $$
- text "<PARAM name=\"FrameName\" value=\"main\">" $$
- text "</OBJECT>" $$
- text "<UL>" $+$
- nest 4 (fn [] ts) $+$
- text "</UL>"
-
- 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 "<UL>" $+$
- nest 4 (fn (s:ss) ts) $+$
- text "</UL>"
-
- ppLeaf s ss isleaf =
- text "<LI>" <> nest 4
- (text "<OBJECT type=\"text/sitemap\">" $$
- text "<PARAM name=\"Name\" value=\"" <> text s <> text "\">" $$
- (if isleaf then text "<PARAM name=\"Local\" value=\"" <> text (moduleHtmlFile "" mod) <> text "\">" else empty) $$
- text "</OBJECT>") $+$
- text "</LI>"
- 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 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">" $$
- text "<HTML>" $$
- text "<HEAD>" $$
- text "<META name=\"GENERATOR\" content=\"Haddock\">" $$
- text "<!-- Sitemap 1.0 -->" $$
- text "</HEAD><BODY>" $$
- text "<UL>" $+$
- nest 4 (ppList index) $+$
- text "</UL>" $$
- text "</BODY><HTML>"
- 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 "<LI>" <> nest 4
- (text "<OBJECT type=\"text/sitemap\">" $$
- text "<PARAM name=\"Name\" value=\"" <> text (show name) <> text "\">" $$
- text "<PARAM name=\"Local\" value=\"" <> text (moduleHtmlFile "" mod) <> char '#' <> text (show name) <> text "\">" $$
- text "</OBJECT>") $+$
- text "</LI>" $$
- 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 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">" $$
+ text "<HTML>" $$
+ text "<HEAD>" $$
+ text "<META name=\"GENERATOR\" content=\"Haddock\">" $$
+ text "<!-- Sitemap 1.0 -->" $$
+ text "</HEAD><BODY>" $$
+ ppModuleTree tree $$
+ text "</BODY><HTML>"
+ writeFile (odir ++ pathSeparator:contentsHHFile) (render html)
+ where
+ ppModuleTree :: [ModuleTree] -> Doc
+ ppModuleTree ts =
+ text "<OBJECT type=\"text/site properties\">" $$
+ text "<PARAM name=\"FrameName\" value=\"main\">" $$
+ text "</OBJECT>" $$
+ text "<UL>" $+$
+ nest 4 (fn [] ts) $+$
+ text "</UL>"
+
+ 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 "<UL>" $+$
+ nest 4 (fn (s:ss) ts) $+$
+ text "</UL>"
+
+ ppLeaf s ss isleaf =
+ text "<LI>" <> nest 4
+ (text "<OBJECT type=\"text/sitemap\">" $$
+ text "<PARAM name=\"Name\" value=\"" <> text s <> text "\">" $$
+ (if isleaf then text "<PARAM name=\"Local\" value=\"" <> text (moduleHtmlFile "" mod) <> text "\">" else empty) $$
+ text "</OBJECT>") $+$
+ text "</LI>"
+ 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 "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">" $$
+ text "<HTML>" $$
+ text "<HEAD>" $$
+ text "<META name=\"GENERATOR\" content=\"Haddock\">" $$
+ text "<!-- Sitemap 1.0 -->" $$
+ text "</HEAD><BODY>" $$
+ text "<UL>" $+$
+ nest 4 (ppList index) $+$
+ text "</UL>" $$
+ text "</BODY><HTML>"
+ 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 "<LI>" <> nest 4
+ (text "<OBJECT type=\"text/sitemap\">" $$
+ text "<PARAM name=\"Name\" value=\"" <> text (show name) <> text "\">" $$
+ text "<PARAM name=\"Local\" value=\"" <> text (moduleHtmlFile "" mod) <> char '#' <> text (show name) <> text "\">" $$
+ text "</OBJECT>") $+$
+ text "</LI>" $$
+ ppList mods
diff --git a/src/HaddockHtml.hs b/src/HaddockHtml.hs
index 23d4c512..3d5a4c95 100644
--- a/src/HaddockHtml.hs
+++ b/src/HaddockHtml.hs
@@ -49,9 +49,11 @@ ppHtml :: String
-> String -- $libdir
-> InstMaps
-> Maybe Doc -- prologue text, maybe
+ -> Bool -- do MS Help stuff
-> IO ()
-ppHtml title source_url ifaces odir maybe_css libdir inst_maps prologue = do
+ppHtml title source_url ifaces odir maybe_css libdir inst_maps prologue
+ do_ms_help = do
let
css_file = case maybe_css of
Nothing -> libdir ++ pathSeparator:cssFile
@@ -71,10 +73,15 @@ ppHtml title source_url ifaces odir maybe_css libdir inst_maps prologue = do
ppHtmlContents odir title source_url (map fst visible_ifaces) prologue
ppHtmlIndex odir title visible_ifaces
- ppHHContents odir (map fst visible_ifaces)
- ppHHIndex odir visible_ifaces
+
+ -- Generate index and contents page for MS help if requested
+ when do_ms_help $ do
+ ppHHContents odir (map fst visible_ifaces)
+ ppHHIndex odir visible_ifaces
+
mapM_ (ppHtmlModule odir title source_url inst_maps) visible_ifaces
+
contentsHtmlFile = "index.html"
indexHtmlFile = "doc-index.html"
subIndexHtmlFile k a = "doc-index-" ++ k:a:".html"
diff --git a/src/Main.hs b/src/Main.hs
index 30d670ec..6b814c1e 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -55,19 +55,20 @@ main = do
usage = usageInfo "usage: haddock [OPTION] file...\n" options
data Flag
- = Flag_Verbose
- | Flag_DocBook
+ = Flag_CSS String
| Flag_Debug
- | Flag_Html
+ | Flag_DocBook
+ | Flag_DumpInterface FilePath
| Flag_Heading String
- | Flag_Prologue FilePath
- | Flag_SourceURL String
- | Flag_CSS String
+ | Flag_Html
| Flag_Lib String
+ | Flag_MSHtmlHelp
+ | Flag_NoImplicitPrelude
| Flag_OutputDir FilePath
+ | Flag_Prologue FilePath
| Flag_ReadInterface FilePath
- | Flag_DumpInterface FilePath
- | Flag_NoImplicitPrelude
+ | Flag_SourceURL String
+ | Flag_Verbose
deriving (Eq)
options =
@@ -95,9 +96,11 @@ options =
Option [] ["css"] (ReqArg Flag_CSS "FILE")
"The CSS file to use for HTML output",
Option [] ["lib"] (ReqArg Flag_Lib "DIR")
- "Directory containing Haddock's auxiliary files",
+ "Location of Haddock's auxiliary files",
Option [] ["no-implicit-prelude"] (NoArg Flag_NoImplicitPrelude)
- "Do not assume Prelude is imported"
+ "Do not assume Prelude is imported",
+ Option [] ["ms-help"] (NoArg Flag_MSHtmlHelp)
+ "Produce Microsoft HTML Help files (with -h)"
]
saved_flags :: IORef [Flag]
@@ -178,7 +181,7 @@ run flags files = do
when (Flag_Html `elem` flags) $
ppHtml title source_url these_mod_ifaces odir css_file
- libdir inst_maps prologue
+ libdir inst_maps prologue (Flag_MSHtmlHelp `elem` flags)
-- dump an interface if requested
case dump_iface of