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

haddock --for-hackage enables Haddock's --hyperlinked-sources AND --source-* options #9318

Closed
mpilgrem opened this issue Oct 8, 2023 · 3 comments

Comments

@mpilgrem
Copy link
Collaborator

mpilgrem commented Oct 8, 2023

Describe the bug

Haddock warns:

Warning: --source-* options are ignored when --hyperlinked-source is enabled.

See also its documentation at: https://haskell-haddock.readthedocs.io/en/latest/invoking.html#cmdoption-hyperlinked-source

However, Distribution.Simple.Haddock.fromFlags has (extracts):

fromFlags :: PathTemplateEnv -> HaddockFlags -> HaddockArgs
fromFlags env flags =
    mempty {
      ...
      argLinkSource = if fromFlag (haddockLinkedSource flags)
                               then Flag ("src/%{MODULE/./-}.html"
                                         ,"src/%{MODULE/./-}.html#%{NAME}"
                                         ,"src/%{MODULE/./-}.html#line-%{LINE}")
                               else NoFlag,
      argLinkedSource = haddockLinkedSource flags,
      ...

and Distribution.Simple.Haddock.renderPureArgs has (extracts) (as an aside, looking at the isVersion checks for Haddock, GHC 8.0.1 comes with Haddock 2.17.2):

renderPureArgs :: Version -> Compiler -> Platform -> HaddockArgs -> [String]
renderPureArgs version comp platform args = concat
    [ ...
    , [ "--hyperlinked-source" | isVersion 2 17
                               , True <- flagToList . argLinkedSource $ args ]
      ...
    , maybe [] (\(m,e,l) ->
                 ["--source-module=" ++ m
                 ,"--source-entity=" ++ e]
                 ++ if isVersion 2 14 then ["--source-entity-line=" ++ l]
                    else []
               ) . flagToMaybe . argLinkSource $ args
      ...

That is, both --hyperlinked-source and --source-* options are being passed.

To Reproduce

On Windows/PowerShell, for a simple one-package project HfHTest (as an aside, stack runghc --no-ghc-package-path -- simply runs runghc in a Cabal-friendly environment) (extracts):

❯ stack runghc --no-ghc-package-path -- Setup.hs configure
❯ stack runghc --no-ghc-package-path -- Setup.hs haddock --for-hackage
Preprocessing library for HfHTest-0.1.0.0..
Running Haddock on library for HfHTest-0.1.0.0..
Warning: --source-* options are ignored when --hyperlinked-source is enabled. <<<< Haddock's msg
   0% (  0 /  2) in 'Lib'
  Missing documentation for:
    Module header
    someFunc (src\Lib.hs:5)
Documentation created: dist\doc\html\HfHTest-0.1.0.0-docs\index.html,
dist\doc\html\HfHTest-0.1.0.0-docs\HfHTest.txt
Preprocessing executable 'HfHTest-exe' for HfHTest-0.1.0.0.

Expected behavior
That Cabal (the library) does not set things up to trigger Haddock's warning.

System information
I think this is applicable to all released versions of Cabal on all operating systems.

@mpilgrem
Copy link
Collaborator Author

mpilgrem commented Oct 8, 2023

I think this is easy to fix. I'll raise a pull request.

@ulysses4ever
Copy link
Collaborator

@coot opinions?

@mergify mergify bot closed this as completed in fd31a01 Oct 11, 2023
mergify bot added a commit that referenced this issue Oct 11, 2023
Fix #9318 Avoid Haddock warning with `haddock --for-hackage`
@coot
Copy link
Collaborator

coot commented Oct 12, 2023

I think that's fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants