Skip to content
Browse files

Make 'cabal haddock' always define __HADDOCK__ CPP macro.

This is useful e.g. for "writing documentation that links to module A without
explicitly qualifying everything, where A is not directly imported." (see the
discussion in #926)

Fixes #1237.
  • Loading branch information...
1 parent f2d876a commit 121d4e512cfe9dc780a90f2b225aa626d5c0fc0f @23Skidoo committed
Showing with 4 additions and 6 deletions.
  1. +4 −6 Cabal/Distribution/Simple/Haddock.hs
View
10 Cabal/Distribution/Simple/Haddock.hs
@@ -211,14 +211,14 @@ haddock pkg_descr lbi suffixes flags = do
let bi = libBuildInfo lib
libArgs <- fromLibrary verbosity tmp lbi lib clbi htmlTemplate
libArgs' <- prepareSources verbosity tmp
- lbi isVersion2 bi (commonArgs `mappend` libArgs)
+ lbi bi (commonArgs `mappend` libArgs)
runHaddock verbosity keepTempFiles confHaddock libArgs'
CExe exe -> when (flag haddockExecutables) $ do
withTempDirectory verbosity keepTempFiles (buildDir lbi) "tmp" $ \tmp -> do
let bi = buildInfo exe
exeArgs <- fromExecutable verbosity tmp lbi exe clbi htmlTemplate
exeArgs' <- prepareSources verbosity tmp
- lbi isVersion2 bi (commonArgs `mappend` exeArgs)
+ lbi bi (commonArgs `mappend` exeArgs)
runHaddock verbosity keepTempFiles confHaddock exeArgs'
_ -> return ()
@@ -236,11 +236,10 @@ haddock pkg_descr lbi suffixes flags = do
prepareSources :: Verbosity
-> FilePath
-> LocalBuildInfo
- -> Bool -- haddock >= 2.0
-> BuildInfo
-> HaddockArgs
-> IO HaddockArgs
-prepareSources verbosity tmp lbi isVersion2 bi args@HaddockArgs{argTargets=files} =
+prepareSources verbosity tmp lbi bi args@HaddockArgs{argTargets=files} =
mapM (mockPP tmp) files >>= \targets -> return args {argTargets=targets}
where
mockPP pref file = do
@@ -267,8 +266,7 @@ prepareSources verbosity tmp lbi isVersion2 bi args@HaddockArgs{argTargets=files
return hsFile
needsCpp = EnableExtension CPP `elem` allExtensions bi
- defines | isVersion2 = []
- | otherwise = ["-D__HADDOCK__"]
+ defines = ["-D__HADDOCK__"]
--------------------------------------------------------------------------------------------------
-- constributions to HaddockArgs

0 comments on commit 121d4e5

Please sign in to comment.
Something went wrong with that request. Please try again.