Skip to content

Commit 5e0802a

Browse files
committed
cabal haddock imply enable-documentation
1 parent 1da1893 commit 5e0802a

File tree

6 files changed

+41
-2
lines changed

6 files changed

+41
-2
lines changed

cabal-install/src/Distribution/Client/CmdHaddock.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import Distribution.Client.TargetProblem
2424
import Distribution.Client.NixStyleOptions
2525
( NixStyleFlags (..), nixStyleOptions, defaultNixStyleFlags )
2626
import Distribution.Client.Setup
27-
( GlobalFlags, ConfigFlags(..) )
27+
( GlobalFlags, ConfigFlags(..), InstallFlags (..))
2828
import Distribution.Simple.Setup
2929
( HaddockFlags(..), fromFlagOrDefault, trueArg )
3030
import Distribution.Simple.Command
@@ -141,7 +141,8 @@ haddockAction flags@NixStyleFlags {..} targetStrings globalFlags = do
141141
runProjectPostBuildPhase verbosity baseCtx buildCtx' buildOutcomes
142142
where
143143
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
144-
cliConfig = commandLineFlagsToProjectConfig globalFlags flags mempty -- ClientInstallFlags, not needed here
144+
flags' = flags { installFlags = installFlags { installDocumentation = Flag True } }
145+
cliConfig = commandLineFlagsToProjectConfig globalFlags flags' mempty -- ClientInstallFlags, not needed here
145146

146147
-- | This defines what a 'TargetSelector' means for the @haddock@ command.
147148
-- It selects the 'AvailableTarget's that the 'TargetSelector' refers to,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module Lib where
2+
3+
import Text.PrettyPrint (render, text)
4+
5+
-- | Rendering using 'text' and 'render'
6+
myLibFunc :: IO ()
7+
myLibFunc = do
8+
putStrLn (render (text "foo"))
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# cabal haddock
2+
Resolving dependencies...
3+
Build profile: -w ghc-<GHCVER> -O1
4+
In order, the following will be built:
5+
- test-1.0 (lib) (first run)
6+
Configuring library for test-1.0..
7+
Preprocessing library for test-1.0..
8+
Running Haddock on library for test-1.0..
9+
Documentation created: <ROOT>/cabal.dist/work/dist/build/<ARCH>/ghc-<GHCVER>/test-1.0/doc/html/test/index.html
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: .
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Test.Cabal.Prelude
2+
-- Test that `cabal haddock` doesn't require explicit
3+
-- `--enable-dependencies` to happily process links to external packages
4+
main = cabalTest $
5+
cabal "haddock" ["lib"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: test
2+
version: 1.0
3+
cabal-version: >= 1.10
4+
author: Artem Pelenitsyn
5+
category: PackageTests
6+
build-type: Simple
7+
8+
description:
9+
Check that `cabal haddock` implies `--enable-dependencies`
10+
---------------------------------------
11+
12+
Library
13+
exposed-modules: Lib
14+
build-depends: base, pretty
15+
default-language: Haskell2010

0 commit comments

Comments
 (0)