aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Hengel <sol@typeful.net>2012-10-02 00:47:46 +0200
committerSimon Hengel <sol@typeful.net>2012-10-04 16:12:17 +0200
commitae3690c2349b595a1fb459a4374cfe2e668a04aa (patch)
tree36eb06b667ae57de85fe6590ea77af8d17f492a1 /src
parent96e57fc09b13779c43b1f2465561a7ede242533e (diff)
Export Haddock's main entry point from library
Diffstat (limited to 'src')
-rw-r--r--src/Documentation/Haddock.hs7
-rw-r--r--src/Haddock.hs (renamed from src/Main.hs)15
2 files changed, 13 insertions, 9 deletions
diff --git a/src/Documentation/Haddock.hs b/src/Documentation/Haddock.hs
index cbdc4d61..855cdc79 100644
--- a/src/Documentation/Haddock.hs
+++ b/src/Documentation/Haddock.hs
@@ -48,8 +48,10 @@ module Documentation.Haddock (
-- * Flags and options
Flag(..),
- DocOption(..)
+ DocOption(..),
+ -- * Program entry point
+ haddock,
) where
@@ -58,7 +60,7 @@ import Haddock.Interface
import Haddock.Types
import Haddock.Options
import Haddock.Utils
-import Main
+import Haddock
-- | Create 'Interface' structures from a given list of Haddock command-line
@@ -72,4 +74,3 @@ createInterfaces
createInterfaces flags modules = do
(_, ifaces, _) <- withGhc' flags (readPackagesAndProcessModules flags modules)
return ifaces
-
diff --git a/src/Main.hs b/src/Haddock.hs
index abeda77f..f53e01a9 100644
--- a/src/Main.hs
+++ b/src/Haddock.hs
@@ -2,7 +2,7 @@
{-# LANGUAGE CPP, ScopedTypeVariables #-}
-----------------------------------------------------------------------------
-- |
--- Module : Main
+-- Module : Haddock
-- Copyright : (c) Simon Marlow 2003-2006,
-- David Waern 2006-2010
-- License : BSD-like
@@ -15,7 +15,7 @@
--
-- Program entry point and top-level code.
-----------------------------------------------------------------------------
-module Main (main, readPackagesAndProcessModules, withGhc') where
+module Haddock (haddock, readPackagesAndProcessModules, withGhc') where
import Haddock.Backends.Xhtml
@@ -39,7 +39,6 @@ import Data.IORef
import qualified Data.Map as Map
import System.IO
import System.Exit
-import System.Environment
#if defined(mingw32_HOST_OS)
import Foreign
@@ -123,14 +122,18 @@ handleGhcExceptions =
-------------------------------------------------------------------------------
-main :: IO ()
-main = handleTopExceptions $ do
+-- | Run Haddock with given list of arguments.
+--
+-- Haddock's own main function is defined in terms of this:
+--
+-- > main = getArgs >>= haddock
+haddock :: [String] -> IO ()
+haddock args = handleTopExceptions $ do
-- Parse command-line flags and handle some of them initially.
-- TODO: unify all of this (and some of what's in the 'render' function),
-- into one function that returns a record with a field for each option,
-- or which exits with an error or help message.
- args <- getArgs
(flags, files) <- parseHaddockOpts args
shortcutFlags flags
qual <- case qualification flags of {Left msg -> throwE msg; Right q -> return q}