Commit c9bd2834 authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

Merge pull request #2852 from bennofs/cabal-haddock-for-hackage

cabal haddock: add --for-hackage flag
parents 06420158 0ecb2835
......@@ -192,12 +192,12 @@ haddock pkg_descr lbi suffixes flags = do
when (flag haddockHscolour) $
hscolour' (warn verbosity) pkg_descr lbi suffixes
(defaultHscolourFlags `mappend` haddockToHscolour flags)
(defaultHscolourFlags `mappend` haddockToHscolour hackageFlags)
libdirArgs <- getGhcLibDir verbosity lbi
let commonArgs = mconcat
[ libdirArgs
, fromFlags (haddockTemplateEnv lbi (packageId pkg_descr)) flags
, fromFlags (haddockTemplateEnv lbi (packageId pkg_descr)) hackageFlags
, fromPackageDescription pkg_descr ]
let pre c = preprocessComponent pkg_descr c lbi False verbosity suffixes
......@@ -213,7 +213,7 @@ haddock pkg_descr lbi suffixes flags = do
let exeArgs' = commonArgs `mappend` exeArgs
runHaddock verbosity tmpFileOpts comp confHaddock exeArgs'
Nothing -> do
warn (fromFlag $ haddockVerbosity flags)
warn (fromFlag $ haddockVerbosity hackageFlags)
"Unsupported component, skipping..."
return ()
case component of
......@@ -236,9 +236,19 @@ haddock pkg_descr lbi suffixes flags = do
keepTempFiles = flag haddockKeepTempFiles
comp = compiler lbi
tmpFileOpts = defaultTempFileOptions { optKeepTempFiles = keepTempFiles }
flag f = fromFlag $ f flags
flag f = fromFlag $ f hackageFlags
hackageFlags
| fromFlag (haddockForHackage flags) = flags
{ haddockHoogle = Flag True
, haddockHtml = Flag True
, haddockHtmlLocation = Flag (pkg_url ++ "/docs")
, haddockContents = Flag (toPathTemplate pkg_url)
, haddockHscolour = Flag True
}
| otherwise = flags
pkg_url = "/package/$pkg-$version"
htmlTemplate = fmap toPathTemplate . flagToMaybe . haddockHtmlLocation
$ flags
$ hackageFlags
-- ------------------------------------------------------------------------------
-- Contributions to HaddockArgs.
......
......@@ -1311,6 +1311,7 @@ data HaddockFlags = HaddockFlags {
haddockHoogle :: Flag Bool,
haddockHtml :: Flag Bool,
haddockHtmlLocation :: Flag String,
haddockForHackage :: Flag Bool,
haddockExecutables :: Flag Bool,
haddockTestSuites :: Flag Bool,
haddockBenchmarks :: Flag Bool,
......@@ -1332,6 +1333,7 @@ defaultHaddockFlags = HaddockFlags {
haddockHoogle = Flag False,
haddockHtml = Flag False,
haddockHtmlLocation = NoFlag,
haddockForHackage = Flag False,
haddockExecutables = Flag False,
haddockTestSuites = Flag False,
haddockBenchmarks = Flag False,
......@@ -1397,6 +1399,11 @@ haddockOptions showOrParseArgs =
haddockHtmlLocation (\v flags -> flags { haddockHtmlLocation = v })
(reqArgFlag "URL")
,option "" ["for-hackage"]
"Collection of flags to generate documentation suitable for upload to hackage"
haddockForHackage (\v flags -> flags { haddockForHackage = v })
trueArg
,option "" ["executables"]
"Run haddock for Executables targets"
haddockExecutables (\v flags -> flags { haddockExecutables = v })
......@@ -1460,6 +1467,7 @@ instance Monoid HaddockFlags where
haddockHoogle = mempty,
haddockHtml = mempty,
haddockHtmlLocation = mempty,
haddockForHackage = mempty,
haddockExecutables = mempty,
haddockTestSuites = mempty,
haddockBenchmarks = mempty,
......@@ -1478,6 +1486,7 @@ instance Monoid HaddockFlags where
haddockHoogle = combine haddockHoogle,
haddockHtml = combine haddockHtml,
haddockHtmlLocation = combine haddockHtmlLocation,
haddockForHackage = combine haddockForHackage,
haddockExecutables = combine haddockExecutables,
haddockTestSuites = combine haddockTestSuites,
haddockBenchmarks = combine haddockBenchmarks,
......
......@@ -370,6 +370,7 @@ instance Monoid SavedConfig where
haddockHoogle = combine haddockHoogle,
haddockHtml = combine haddockHtml,
haddockHtmlLocation = combine haddockHtmlLocation,
haddockForHackage = combine haddockForHackage,
haddockExecutables = combine haddockExecutables,
haddockTestSuites = combine haddockTestSuites,
haddockBenchmarks = combine haddockBenchmarks,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment