Skip to content

Commit 2794dd8

Browse files
authored
Merge pull request #9319 from haskell/fix9318
Fix #9318 Avoid Haddock warning with `haddock --for-hackage`
2 parents 285a293 + 730095c commit 2794dd8

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

Cabal/src/Distribution/Simple/Haddock.hs

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -866,25 +866,32 @@ renderPureArgs version comp platform args =
866866
, ["--since-qual=external" | isVersion 2 20]
867867
, [ "--quickjump" | isVersion 2 19, True <- flagToList . argQuickJump $ args
868868
]
869-
, [ "--hyperlinked-source" | isVersion 2 17, True <- flagToList . argLinkedSource $ args
870-
]
869+
, ["--hyperlinked-source" | isHyperlinkedSource]
871870
, (\(All b, xs) -> bool (map (("--hide=" ++) . prettyShow) xs) [] b)
872871
. argHideModules
873872
$ args
874873
, bool ["--ignore-all-exports"] [] . getAny . argIgnoreExports $ args
875-
, maybe
876-
[]
877-
( \(m, e, l) ->
878-
[ "--source-module=" ++ m
879-
, "--source-entity=" ++ e
880-
]
881-
++ if isVersion 2 14
882-
then ["--source-entity-line=" ++ l]
883-
else []
884-
)
885-
. flagToMaybe
886-
. argLinkSource
887-
$ args
874+
, -- Haddock's --source-* options are ignored once --hyperlinked-source is
875+
-- set.
876+
-- See https://haskell-haddock.readthedocs.io/en/latest/invoking.html#cmdoption-hyperlinked-source
877+
-- To avoid Haddock's warning, we only set --source-* options if
878+
-- --hyperlinked-source is not set.
879+
if isHyperlinkedSource
880+
then []
881+
else
882+
maybe
883+
[]
884+
( \(m, e, l) ->
885+
[ "--source-module=" ++ m
886+
, "--source-entity=" ++ e
887+
]
888+
++ if isVersion 2 14
889+
then ["--source-entity-line=" ++ l]
890+
else []
891+
)
892+
. flagToMaybe
893+
. argLinkSource
894+
$ args
888895
, maybe [] ((: []) . ("--css=" ++)) . flagToMaybe . argCssFile $ args
889896
, maybe [] ((: []) . ("--use-contents=" ++)) . flagToMaybe . argContents $ args
890897
, bool ["--gen-contents"] [] . fromFlagOrDefault False . argGenContents $ args
@@ -965,6 +972,10 @@ renderPureArgs version comp platform args =
965972
| otherwise = "--verbose"
966973
haddockSupportsVisibility = version >= mkVersion [2, 26, 1]
967974
haddockSupportsPackageName = version > mkVersion [2, 16]
975+
haddockSupportsHyperlinkedSource = isVersion 2 17
976+
isHyperlinkedSource =
977+
haddockSupportsHyperlinkedSource
978+
&& fromFlagOrDefault False (argLinkedSource args)
968979

969980
---------------------------------------------------------------------------------
970981

0 commit comments

Comments
 (0)