diff --git a/Cabal/src/Distribution/Simple/Haddock.hs b/Cabal/src/Distribution/Simple/Haddock.hs index 784894325cb..f06824b24a9 100644 --- a/Cabal/src/Distribution/Simple/Haddock.hs +++ b/Cabal/src/Distribution/Simple/Haddock.hs @@ -821,6 +821,13 @@ 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 @@ -828,7 +835,7 @@ renderArgs verbosity tmpFileOpts version comp platform args k = do outputDir case o of Html - | fromFlagOrDefault False (argGenIndex args) -> + | isIndexGenerated -> "index.html" Html | otherwise -> diff --git a/release-notes/Cabal-3.10.2.0.md b/release-notes/Cabal-3.10.2.0.md index 0c60f7ff239..6de0bb90dce 100644 --- a/release-notes/Cabal-3.10.2.0.md +++ b/release-notes/Cabal-3.10.2.0.md @@ -24,3 +24,7 @@ Cabal and Cabal-syntax 3.10.2.0 changelog and release notes - Regenerate Cabal-syntax's Lexer.hs with Alex 3.2.7.3 which includes a fix for an out-of-bound array access (only noticeable with GHC's JavaScript backend). + +- The `haddock` command will no longer refer to the creation of a `index.html` + file when Haddock does not create that file + [#5210](https://github.com/haskell/cabal/issues/5210) diff --git a/release-notes/cabal-install-3.10.2.0.md b/release-notes/cabal-install-3.10.2.0.md index 52dc5de7b8f..df85b105603 100644 --- a/release-notes/cabal-install-3.10.2.0.md +++ b/release-notes/cabal-install-3.10.2.0.md @@ -58,3 +58,7 @@ cabal-install and cabal-install-solver 3.10.2.0 changelog and release notes - Added Hackage root key for Joachim Breitner - Added Hackage root key for Mathieu Boespflug + +- The `haddock` command will no longer refer to the creation of a `index.html` + file when Haddock does not create that file + [#5210](https://github.com/haskell/cabal/issues/5210)