aboutsummaryrefslogtreecommitdiff
path: root/driver/Main.hs
diff options
context:
space:
mode:
authorranden <randen@users.noreply.github.com>2016-01-01 18:02:11 -0800
committerranden <randen@users.noreply.github.com>2016-01-01 23:45:25 -0800
commitd510c45790432249fe7027b1ed70ce1c06fdd824 (patch)
treef7a276c6cd870aa903abf4f960269e03e3d9be31 /driver/Main.hs
parentac10a4ccbe416e8612c6ca49b9f19c3a6f4cf25f (diff)
The Haddock part for fully gcc-like response files
" driver/Main.hs * Moved the response file handling into ResponseFile.hs, updating import section as appropriate. * driver/ResponseFile.hs * New file. In anticipation that maybe some day this could be provided by another library, and to make it possible to unit test, this functionality is pulled out of the Main.hs module, and expanded to support the style/format of response files which gcc uses. * The specification for the format of response files which gcc generates and consumes, seems to be best derived from the gcc code itself (libiberty/argv.c), so that is what has been done here. * This is intended to fix haskell/haddock#379 * driver-test/Main.hs * New file for testing code in the driver source tree * driver-test/ResponseFileSpec.hs * Tests, adapted/adopted from the same gcc code where the escaping/unescaping is from, in the hspec style of unit tests * haddock.cabal * Add the driver-test test-suite. Introduces a new library dependency (upon hspec) for the haddock driver target in the haddock.cabal file, but practically, this should not be a problem as the haddock-api tests already depend on hspec.
Diffstat (limited to 'driver/Main.hs')
-rw-r--r--driver/Main.hs23
1 files changed, 1 insertions, 22 deletions
diff --git a/driver/Main.hs b/driver/Main.hs
index ccbb8b7d..852f44c7 100644
--- a/driver/Main.hs
+++ b/driver/Main.hs
@@ -1,29 +1,8 @@
-{-# LANGUAGE ScopedTypeVariables #-}
module Main where
-import Control.Exception
import Documentation.Haddock (haddock)
+import ResponseFile (expandResponse)
import System.Environment (getArgs)
-import System.Exit (exitFailure)
-import System.IO
main :: IO ()
main = getArgs >>= expandResponse >>= haddock
-
-
--- | Arguments which look like '@foo' will be replaced with the
--- contents of file @foo@. The contents will be passed through 'words'
--- and blanks filtered out first.
---
--- We quit if the file is not found or reading somehow fails.
-expandResponse :: [String] -> IO [String]
-expandResponse = fmap concat . mapM expand
- where
- expand :: String -> IO [String]
- expand ('@':f) = readFileExc f >>= return . filter (not . null) . lines
- expand x = return [x]
-
- readFileExc f =
- readFile f `catch` \(e :: IOException) -> do
- hPutStrLn stderr $ "Error while expanding response file: " ++ show e
- exitFailure