Skip to content

Commit

Permalink
Merge pull request #8330 from haskell/unbreak-disable-doc
Browse files Browse the repository at this point in the history
unbreak cabal haddock --disable-documentation
  • Loading branch information
mergify[bot] authored Aug 21, 2022
2 parents a97e1f1 + 033b043 commit a47b0ad
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cabal-install/src/Distribution/Client/CmdHaddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ haddockAction flags@NixStyleFlags {..} targetStrings globalFlags = do
runProjectPostBuildPhase verbosity baseCtx buildCtx' buildOutcomes
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
flags' = flags { installFlags = installFlags { installDocumentation = Flag True } }
installDoc = fromFlagOrDefault True (installDocumentation installFlags)
flags' = flags { installFlags = installFlags { installDocumentation = Flag installDoc } }
cliConfig = commandLineFlagsToProjectConfig globalFlags flags' mempty -- ClientInstallFlags, not needed here

-- | This defines what a 'TargetSelector' means for the @haddock@ command.
Expand Down
12 changes: 12 additions & 0 deletions cabal-testsuite/PackageTests/NewHaddock/DisableDoc/B/B.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cabal-version: 2.4
name: B
version: 0.1.0.0
author: Artem Pelenitsyn
maintainer: a.pelenitsyn@gmail.com

library
exposed-modules: B
build-depends: base
, A
hs-source-dirs: .
default-language: Haskell2010
8 changes: 8 additions & 0 deletions cabal-testsuite/PackageTests/NewHaddock/DisableDoc/B/B.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- | Module using external dependency and mentioning it in haddocks
module B (b) where

import A

-- | Use 'a'
b :: Int
b = a
16 changes: 16 additions & 0 deletions cabal-testsuite/PackageTests/NewHaddock/DisableDoc/cabal.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# cabal v2-update
Downloading the latest package list from test-local-repo
# cabal haddock
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- A-0.1.0.0 (lib) (requires build)
- B-0.1.0.0 (lib) (first run)
Configuring library for A-0.1.0.0..
Preprocessing library for A-0.1.0.0..
Building library for A-0.1.0.0..
Installing library in <PATH>
Configuring library for B-0.1.0.0..
Preprocessing library for B-0.1.0.0..
Running Haddock on library for B-0.1.0.0..
Documentation created: <ROOT>/cabal.dist/work/dist/build/<ARCH>/ghc-<GHCVER>/B-0.1.0.0/doc/html/B/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: B
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Cabal.Prelude
-- Test that `cabal haddock --disable-documention` works as expected and leads
-- to a warning if a local package makes an outer reference.
main = cabalTest . withRepo "repo" $ do
r <- cabal' "haddock" ["--disable-documentation", "B"]
assertOutputContains "Warning: B: could not find link destinations for" r
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cabal-version: 2.4
name: A
version: 0.1.0.0
author: Artem Pelenitsyn
maintainer: a.pelenitsyn@gmail.com

library
exposed-modules: A
build-depends: base
hs-source-dirs: .
default-language: Haskell2010
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module A (a) where

a :: Int
a = 42

0 comments on commit a47b0ad

Please sign in to comment.