@@ -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