Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions Cabal/Distribution/Simple/Haddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions Cabal/Distribution/Simple/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,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,
Expand All @@ -1324,6 +1325,7 @@ defaultHaddockFlags = HaddockFlags {
haddockHoogle = Flag False,
haddockHtml = Flag False,
haddockHtmlLocation = NoFlag,
haddockForHackage = Flag False,
haddockExecutables = Flag False,
haddockTestSuites = Flag False,
haddockBenchmarks = Flag False,
Expand Down Expand Up @@ -1389,6 +1391,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 })
Expand Down Expand Up @@ -1452,6 +1459,7 @@ instance Monoid HaddockFlags where
haddockHoogle = mempty,
haddockHtml = mempty,
haddockHtmlLocation = mempty,
haddockForHackage = mempty,
haddockExecutables = mempty,
haddockTestSuites = mempty,
haddockBenchmarks = mempty,
Expand All @@ -1470,6 +1478,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,
Expand Down
1 change: 1 addition & 0 deletions cabal-install/Distribution/Client/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,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,
Expand Down