aboutsummaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
authorsimonmar <unknown>2002-06-20 12:39:02 +0000
committersimonmar <unknown>2002-06-20 12:39:02 +0000
commitf467a9b6f442dd4ffe823ad36b8879d490f649f8 (patch)
tree2ab680bc0ec1fce8c3bdd270bb3824838ca9b99d /src/Main.hs
parente13b5af42f8921146059a74ad4a8c4818d05db0a (diff)
[haddock @ 2002-06-20 12:39:01 by simonmar]
Add support for a "prologue" - a description for the whole library, placed on the contents page before the module list.
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 82162ef1..3d8c86dc 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -8,6 +8,7 @@ module Main (main) where
import HaddockRename
import HaddockParse
+import HaddockLex
--import HaddockDB -- not compiling
import HaddockHtml
import HaddockTypes
@@ -54,6 +55,7 @@ data Flag
| Flag_DocBook
| Flag_Html
| Flag_Heading String
+ | Flag_Prologue FilePath
| Flag_SourceURL String
| Flag_CSS String
| Flag_Lib String
@@ -68,9 +70,11 @@ options =
"output in HTML",
Option ['o'] ["odir"] (ReqArg Flag_OutputDir "DIR")
"directory in which to put the output files",
+ Option ['p'] ["prologue"] (ReqArg Flag_Prologue "FILE")
+ "file containing prologue text",
Option ['s'] ["source"] (ReqArg Flag_SourceURL "URL")
"base URL for links to source code",
- Option ['t'] ["title"] (ReqArg Flag_Heading "TITLE")
+ Option ['t'] ["title"] (ReqArg Flag_Heading "TITLE")
"page heading",
Option ['v'] ["verbose"] (NoArg Flag_Verbose)
"be verbose",
@@ -104,6 +108,8 @@ run flags files = do
[] -> return "."
fs -> return (last fs)
+ prologue <- getPrologue flags
+
writeIORef saved_flags flags
parsed_mods <- sequence (map parse_file files)
@@ -129,7 +135,7 @@ run flags files = do
let inst_maps = collectInstances mod_ifaces
when (Flag_Html `elem` flags) $
- ppHtml title source_url mod_ifaces odir css_file libdir inst_maps
+ ppHtml title source_url mod_ifaces odir css_file libdir inst_maps prologue
parse_file file = do
bracket
@@ -142,6 +148,17 @@ parse_file file = do
exitWith (ExitFailure 1)
)
+getPrologue :: [Flag] -> IO (Maybe Doc)
+getPrologue flags
+ = case [filename | Flag_Prologue filename <- flags ] of
+ [] -> return Nothing
+ [filename] -> do
+ str <- readFile filename
+ case parseParas (tokenise str) of
+ Left err -> dieMsg err
+ Right doc -> return (Just doc)
+ _otherwise -> dieMsg "multiple -p/--prologue options"
+
-----------------------------------------------------------------------------
-- Figuring out the definitions that are exported from a module