From 97f9e913b65736bae23d0d9cedd7631457557e99 Mon Sep 17 00:00:00 2001 From: davve Date: Tue, 6 Feb 2007 20:52:27 +0000 Subject: Wibble --- src/Main.hs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index 3c00b08b..03b202e0 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -112,15 +112,18 @@ main = do -- parse Haddock specific flags (flags, fileArgs) <- parseHaddockOpts rest' - - -- try to sort and check the input files using the GHC API - modules <- sortAndCheckModules session dynflags' fileArgs + + -- react to some flags before doing anything + handleEagerFlags flags -- create a PackageData for each external package in the session -- using the GHC API. The PackageData contains an html path, -- a doc env and a list of module names. packages <- getPackages session dynflags' flags + -- try to sort and check the input files using the GHC API + modules <- sortAndCheckModules session dynflags' fileArgs + -- update the html references (module -> html file mapping) updateHTMLXRefs packages @@ -254,6 +257,7 @@ data Flag = Flag_CSS String | Flag_Debug -- | Flag_DocBook + | Flag_DumpInterface String | Flag_Heading String | Flag_Html | Flag_Hoogle @@ -284,10 +288,12 @@ data Flag options :: Bool -> [OptDescr Flag] options backwardsCompat = [ - Option ['o'] ["odir"] (ReqArg Flag_OutputDir "DIR") + Option ['o'] ["odir"] (ReqArg Flag_OutputDir "DIR") "directory in which to put the output files", Option ['l'] ["lib"] (ReqArg Flag_Lib "DIR") "location of Haddock's auxiliary files", + Option ['D'] ["dump-interface"] (ReqArg Flag_DumpInterface "FILE") + "interface file name", -- Option ['S'] ["docbook"] (NoArg Flag_DocBook) -- "output in DocBook XML", Option ['h'] ["html"] (NoArg Flag_Html) @@ -344,12 +350,12 @@ options backwardsCompat = ] handleEagerFlags flags = do - whenFlag Flag_Help $ do + when ((Flag_Help `elem` flags) || null flags) $ do prog <- getProgramName bye (usageInfo (usageHeader prog) (options False)) - + whenFlag Flag_Version $ - bye ("Haddock version " ++ projectVersion ++ + bye ("Haddock-GHC version " ++ projectVersion ++ ", (c) Simon Marlow 2003; port to GHC-api by David Waern 2006\n") when ((Flag_GenIndex `elem` flags || Flag_GenContents `elem` flags) -- cgit v1.2.3