aboutsummaryrefslogtreecommitdiff
path: root/haddock-api
diff options
context:
space:
mode:
authoralexbiehl <alex.biehl@gmail.com>2017-04-18 16:45:32 +0200
committerAlex Biehl <alexbiehl@gmail.com>2017-04-25 10:08:48 +0200
commit70885ce16e1b0b9bf19fe0efb85a48daa0e5c281 (patch)
tree97616aa480ce473386bc6f7cf2d58d8f74ac28f1 /haddock-api
parent99ec96e57ea6b002394c923201d46a67ecfb8e16 (diff)
Travis: Use ghc-8.2.1 on master
Diffstat (limited to 'haddock-api')
-rw-r--r--haddock-api/haddock-api.cabal5
-rw-r--r--haddock-api/src/Haddock.hs25
2 files changed, 20 insertions, 10 deletions
diff --git a/haddock-api/haddock-api.cabal b/haddock-api/haddock-api.cabal
index f98a8202..921e16eb 100644
--- a/haddock-api/haddock-api.cabal
+++ b/haddock-api/haddock-api.cabal
@@ -12,7 +12,7 @@ bug-reports: https://github.com/haskell/haddock/issues
copyright: (c) Simon Marlow, David Waern
category: Documentation
build-type: Simple
-cabal-version: >= 1.10
+cabal-version: >= 2.0
stability: experimental
data-dir:
@@ -120,6 +120,9 @@ test-suite spec
, hspec
, QuickCheck == 2.*
+ build-tool-depends:
+ hspec-discover:hspec-discover
+
source-repository head
type: git
location: https://github.com/haskell/haddock.git
diff --git a/haddock-api/src/Haddock.hs b/haddock-api/src/Haddock.hs
index 6af0874a..dec85b79 100644
--- a/haddock-api/src/Haddock.hs
+++ b/haddock-api/src/Haddock.hs
@@ -426,15 +426,22 @@ getHaddockLibDir flags =
#ifdef IN_GHC_TREE
getInTreeDir
#else
- d <- getDataDir -- provided by Cabal
- doesDirectoryExist d >>= \exists -> case exists of
- True -> return d
- False -> do
- -- If directory does not exist then we are probably invoking from
- -- ./dist/build/haddock/haddock so we use ./resources as a fallback.
- doesDirectoryExist "resources" >>= \exists_ -> case exists_ of
- True -> return "resources"
- False -> die ("Haddock's resource directory (" ++ d ++ ") does not exist!\n")
+ -- if data directory does not exist we are probably
+ -- invoking from either ./haddock-api or ./
+ let res_dirs = [ getDataDir -- provided by Cabal
+ , pure "resources"
+ , pure "haddock-api/resources"
+ ]
+
+ check get_path = do
+ p <- get_path
+ exists <- doesDirectoryExist p
+ pure $ if exists then Just p else Nothing
+
+ dirs <- mapM check res_dirs
+ case [p | Just p <- dirs] of
+ (p : _) -> return p
+ _ -> die "Haddock's resource directory does not exist!\n"
#endif
fs -> return (last fs)