Skip to content

Commit

Permalink
cabal haddock imply enable-documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ulysses4ever committed Jul 2, 2022
1 parent 1da1893 commit 5e0802a
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cabal-install/src/Distribution/Client/CmdHaddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Distribution.Client.TargetProblem
import Distribution.Client.NixStyleOptions
( NixStyleFlags (..), nixStyleOptions, defaultNixStyleFlags )
import Distribution.Client.Setup
( GlobalFlags, ConfigFlags(..) )
( GlobalFlags, ConfigFlags(..), InstallFlags (..))
import Distribution.Simple.Setup
( HaddockFlags(..), fromFlagOrDefault, trueArg )
import Distribution.Simple.Command
Expand Down Expand Up @@ -141,7 +141,8 @@ haddockAction flags@NixStyleFlags {..} targetStrings globalFlags = do
runProjectPostBuildPhase verbosity baseCtx buildCtx' buildOutcomes
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
cliConfig = commandLineFlagsToProjectConfig globalFlags flags mempty -- ClientInstallFlags, not needed here
flags' = flags { installFlags = installFlags { installDocumentation = Flag True } }
cliConfig = commandLineFlagsToProjectConfig globalFlags flags' mempty -- ClientInstallFlags, not needed here

-- | This defines what a 'TargetSelector' means for the @haddock@ command.
-- It selects the 'AvailableTarget's that the 'TargetSelector' refers to,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Lib where

import Text.PrettyPrint (render, text)

-- | Rendering using 'text' and 'render'
myLibFunc :: IO ()
myLibFunc = do
putStrLn (render (text "foo"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# cabal haddock
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- test-1.0 (lib) (first run)
Configuring library for test-1.0..
Preprocessing library for test-1.0..
Running Haddock on library for test-1.0..
Documentation created: <ROOT>/cabal.dist/work/dist/build/<ARCH>/ghc-<GHCVER>/test-1.0/doc/html/test/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: .
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Test.Cabal.Prelude
-- Test that `cabal haddock` doesn't require explicit
-- `--enable-dependencies` to happily process links to external packages
main = cabalTest $
cabal "haddock" ["lib"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: test
version: 1.0
cabal-version: >= 1.10
author: Artem Pelenitsyn
category: PackageTests
build-type: Simple

description:
Check that `cabal haddock` implies `--enable-dependencies`
---------------------------------------

Library
exposed-modules: Lib
build-depends: base, pretty
default-language: Haskell2010

0 comments on commit 5e0802a

Please sign in to comment.