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

Remove hasLibrary guard from haddock step #582

Closed
wants to merge 3 commits into from

Conversation

andreasabel
Copy link
Contributor

@andreasabel andreasabel commented Apr 16, 2022

Remove hasLibrary guard from haddock step

Rationale:

  • cabal v2-haddock also succeeds for executable packages
  • one can always opt-out with haddock: False in cabal.haskell-ci

In the wild:

Rationale:
- `cabal v2-haddock` also succeeds for `executable` packages
- one can always opt-out with `haddock: False` in `cabal.haskell-ci`
andreasabel added a commit to haskell/hackage-server that referenced this pull request Apr 16, 2022
Atm. requires a patched version of `haskell-ci` 
- haskell-CI/haskell-ci#582

to include the "haddock" step.

Also: 
- fix missing `extra-source-files:` in `.cabal` file
- delete `.travis.yml`.
@andreasabel
Copy link
Contributor Author

@phadej, does this change sound reasonable?

@phadej
Copy link
Collaborator

phadej commented Apr 30, 2022

Does this actually work?

With:

cabal-version: 2.4
name: pkkg
version: 0

executable foo
  default-language: Haskell2010
  main-is: exe.hs
  build-depends: base
module Main (main, foo) where

foo :: Int
foo = 42

main :: IO ()
main = print foo

and

% cabal --version
cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal library 

trying to cabal haddock all fails:

% cabal haddock all
cabal: renderBuildTargetProblem: unexpected status (TargetDisabledByUser,Nothing)
CallStack (from HasCallStack):
  error, called at src/Distribution/Client/CmdErrorMessages.hs:356:14 in main:Distribution.Client.CmdErrorMessages

I tried to find an issue in cabal-install about this behavior, but could find it. Is it fixed recently?

@andreasabel
Copy link
Contributor Author

Does this actually work?

Seems like for your example, no haddock is actually run.

I tried to find an issue in cabal-install about this behavior, but could find it. Is it fixed recently?

I can confirm that the error is gone on cabal-install master.

Seems like one has to pass --haddock-executables to silence the warning:

No documentation was generated as this package does not contain a library.
Perhaps you want to use the --haddock-executables, --haddock-tests,
--haddock-benchmarks or --haddock-internal flags.

Let me try to investigate further... (I remembered it worked fine on hackage-server, but I have to revisit the details).

@andreasabel andreasabel marked this pull request as draft April 30, 2022 15:00
@phadej
Copy link
Collaborator

phadej commented May 1, 2022

hackage-server probably works cause it has internal libraries. But if we can build haddocks with --haddock-all to build haddocks for exes, tests and benchmarks, that will be great. These should generally succeed, there is no reason to have invalid markup in the auxiliary components (even if Hackage won't render/display it, IDEs may, I guess).

@andreasabel
Copy link
Contributor Author

@phadej wrote:

I tried to find an issue in cabal-install about this behavior, but could find it. Is it fixed recently?

Looks like it is still open:

@andreasabel
Copy link
Contributor Author

hackage-server probably works cause it has internal libraries.

Yes, reading up on haskell/cabal#5890 confirms this: if you have other-modules, docs are generated. Thus, your example just hit the case that doesn't work.

But if we can build haddocks with --haddock-all to build haddocks for exes, tests and benchmarks, that will be great.

Since cabal v2-haddock --haddock-all does not fail (even if it does not produce any HTML), unless there is invalid markup, it might be no harm to run it by default, as you said.

@andreasabel andreasabel marked this pull request as ready for review May 1, 2022 20:22
@phadej
Copy link
Collaborator

phadej commented May 4, 2022

Merged in #585 (please don't edit version in the future if it's release i.e. even version).

@phadej phadej closed this May 4, 2022
@andreasabel
Copy link
Contributor Author

Merged in #585

Thanks!

(please don't edit version in the future if it's release i.e. even version).

Ok, understood.

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

Successfully merging this pull request may close these issues.

2 participants