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/changelog.d/pr-9332 b/changelog.d/pr-9332 new file mode 100644 index 00000000000..c5d4c3d4ac4 --- /dev/null +++ b/changelog.d/pr-9332 @@ -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