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: Generate haddock for components #5226

Merged
merged 5 commits into from
Apr 12, 2018

Conversation

alexbiehl
Copy link
Member

@alexbiehl alexbiehl commented Mar 21, 2018

Currently settings documentation: true enables documentation
generation via haddock for your whole package, including tests and benchmarks.
However, there are additional flags to control generation of
documentation for these "second class" documentation targets, which are
currently not honored at the cabal-install side of things. Namely,
tests, benchmarks, executables, etc. provided under the
haddock section in your $CABAL_HOME/config.

This patch adds a more sensible approach to documentation generation
via haddock. The new behaviour works like this:

  • Setting documentation: true or passing
    --enable-documentation to cabal-install enables documentation
    for any component in the build plan honoring the respective
    flags for "second class" doc targets from configuration
    or CLI.

  • Invoking new-haddock with a target selector will make sure
    the respective flags for "second class" doc targets are set
    correctly. E.g.

       $ new-haddock tests
    

    Will generate documentation for the test suite of your package
    even if you have tests: false in your haddock configuration.

Please include the following checklist in your PR:

  • Patches conform to the coding conventions.
  • Any changes that could be relevant to users have been recorded in the changelog.
  • The documentation has been updated, if necessary.
  • If the change is docs-only, [ci skip] is used to avoid triggering the build bots.

Please also shortly describe how you tested your change. Bonus points for added tests!

@alexbiehl
Copy link
Member Author

@merijn this should fix your problem.

@merijn
Copy link
Collaborator

merijn commented Mar 22, 2018

You're a hero :)

@alexbiehl alexbiehl force-pushed the pr/haddock-components branch 2 times, most recently from 43310a7 to 712273d Compare March 22, 2018 16:06
@alexbiehl
Copy link
Member Author

(This resolves #4506)

@23Skidoo
Copy link
Member

Needs a changelog note and maybe some tweaks to docs.

@hvr
Copy link
Member

hvr commented Mar 23, 2018

As this extends the Setup.hs haddock CLI, this may need version gating in e.g. Distribution.Client.Setup for custom-setup situations when we talk to an external Setup.hs

@23Skidoo this requires making a decision whether we want to target Cabal-2.2.1 or Cabal-3.0 for this (otherwise backward-compatible) CLI enhancement

@merijn
Copy link
Collaborator

merijn commented Mar 26, 2018

I've been using this patch the past few days and it seems to work fine, but introduces one silly issue. With documentation: True set it will also rebuild docs every time when you run cabal new-repl which is probably the wrong thing to do.

@alexbiehl
Copy link
Member Author

@merijn Generating documentation with new-repl was present before this patch (c.f.
#5178).

@merijn
Copy link
Collaborator

merijn commented Mar 26, 2018

Ok, my bad. I just didn't wanna rebuild all of cabal to test that.

Currently settings `documentation: true` enables documentation
generation via haddock for your whole package, including tests and benchmarks.
However, there are additional flags to control generation of
documentation for this "second class" documentation targets, which are
currently not honored at the cabal-install side of things. Namely,
`tests`, `benchmarks`, `executables`, etc. provided under the
`haddock` section in your `$CABAL_HOME/config`.

This patch adds a more sensible approach to documentation generation
via haddock. Also enabling `new-haddock` to generate documentation for
single components instead whole packages.

The behaviour works like this:

    - Setting `documentation: true` or passing
      `--enable-documentation` to cabal-install enable documentation
      for any component in the build plan honoring the respective
      flags for tests, benchmarks, exes, foreignlibs, etc.

    - Invoking new-haddock with a target selector will make sure
      the respective flags for "second class" doc targets are set
      correctly. E.g.

      $ new-haddock tests

      Will generate documentation for the testsuite of your package
      event if you have `tests: false` in your haddock section.
@alexbiehl
Copy link
Member Author

alexbiehl commented Mar 26, 2018

@merijn I corrected the faulty behaviour.

@merijn
Copy link
Collaborator

merijn commented Mar 26, 2018

works now \o/

@alexbiehl
Copy link
Member Author

@23Skidoo I added change log entry and documentation.

@merijn
Copy link
Collaborator

merijn commented Apr 12, 2018

Incidentally, this PR seems to fix a truckload of issues with new-build's dependency tracking for me. I've been struggling to figure out what was going on with new-repl and new-build being weird about whether stuff had build already, etc. And it all disappears when I use these changes.

@alexbiehl
Copy link
Member Author

alexbiehl commented Apr 12, 2018 via email

@alexbiehl
Copy link
Member Author

@23Skidoo ping

@ezyang ezyang merged commit f3cacff into haskell:master Apr 12, 2018
@hvr
Copy link
Member

hvr commented Apr 14, 2018

@ezyang did you take into account #5226 (comment) ?

EDIT: ...you didn't, see #5260

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.

5 participants