Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5210 Don't refer to index.html when Haddock will not create it #9332

Merged
merged 1 commit into from
Oct 17, 2023
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
9 changes: 8 additions & 1 deletion Cabal/src/Distribution/Simple/Haddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -821,14 +821,21 @@ renderArgs verbosity tmpFileOpts version comp platform args k = do
else k (renderedArgs, result)
where
outputDir = (unDir $ argOutputDir args)
isNotArgContents = isNothing (flagToMaybe $ argContents args)
isNotArgIndex = isNothing (flagToMaybe $ argIndex args)
isArgGenIndex = fromFlagOrDefault False (argGenIndex args)
-- Haddock, when generating HTML, does not generate an index if the options
-- --use-contents or --use-index are passed to it. See
-- https://haskell-haddock.readthedocs.io/en/latest/invoking.html#cmdoption-use-contents
isIndexGenerated = isArgGenIndex && isNotArgContents && isNotArgIndex
result =
intercalate ", "
. map
( \o ->
outputDir
</> case o of
Html
| fromFlagOrDefault False (argGenIndex args) ->
| isIndexGenerated ->
"index.html"
Html
| otherwise ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cabal-version: 3.6
name: A
synopsis: A minimal test package for testing haddock.
version: 0.0.0

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

-- | a is zero.
a :: Int
a = 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# cabal haddock
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- A-0.0.0 (lib) (first run)
Configuring library for A-0.0.0...
Preprocessing library for A-0.0.0...
Running Haddock on library for A-0.0.0...
Documentation created: <ROOT>/cabal.dist/work/dist/build/<ARCH>/ghc-<GHCVER>/A-0.0.0/doc/html/A-0.0.0-docs/, <ROOT>/cabal.dist/work/dist/build/<ARCH>/ghc-<GHCVER>/A-0.0.0/doc/html/A-0.0.0-docs/A.txt
Documentation tarball created: <ROOT>/cabal.dist/work/./dist/A-0.0.0-docs.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: A
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Test.Cabal.Prelude

-- Test that `cabal haddock --haddock-for-hackage` does not report that it
-- creates an `index.html` file.
main = cabalTest $ do
r <- cabal' "haddock" ["--haddock-for-hackage", "A"]
assertOutputDoesNotContain "index.html" r
4 changes: 4 additions & 0 deletions changelog.d/pr-9332
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
synopsis: Don't report `index.html` file as created, if not created by Haddock
packages: Cabal cabal-install
prs: #9332
issues: #5120
Loading