10

I'm using GHC and have installed several packages via Cabal. One of the packages' web site says "go see the haddock documentation". The haddock command seems to only work on source files, and cabal haddock only seems to work in the top-level directory of a project with a .cabal build file. Is there a way to say "show me the haddock" for a module?

I'm longing for pydoc -p 12345 which starts an HTTP server providing Python documentation based on what you have installed locally.

As a work-around, I extracted the source tarball from under ~/.cabal and ran cabal configure; cabal haddock in the source directory, but that's kind of a pain.

Harold L
  • 5,166
  • 28
  • 28

4 Answers4

18

edit your config file:

~/.cabal/config

there is a option to enable default install doc:

documentation: True

to install doc of existing packages, use:

cabal install xxx --reinstall

re-install docs from basic packages then the upper-level packages, so the "hyper-link" to other modules will be generated properly.

wuxb
  • 2,572
  • 1
  • 21
  • 30
8

The --haddock flag didn’t work for me. However, replacing --haddock with --enable-documentation did:

cabal install $project --enable-documentation

Now, if they could allow the --hyperlink-source flag to zip through to haddock I’d be very happy.

Rudy Matela
  • 6,310
  • 2
  • 32
  • 37
Kim
  • 381
  • 4
  • 3
3

This is a known issue. As a workaround you can configure your Apache installation (if you have one) to serve your doc directory using this small PHP script.

Martijn
  • 6,713
  • 3
  • 31
  • 38
  • @Martjin: regarding that link, does hackage.haskell.org work for you? from here it looks like it's down for the last two days, and http://downforeveryoneorjustme.com/hackage.haskell.org confirms.. – yairchu Oct 19 '09 at 14:48
  • Thanks, your notes in that post also led me to change my .cabal/config to generate docs by default. – Harold L Oct 19 '09 at 19:43
  • Hackage should be back up now. :-) Yes, it was down for a while. People were asking about it in the Haskell café as well. – Martijn Oct 21 '09 at 11:53
3

You should be able to generate local documentation with:

cabal install $project --haddock

Assuming you have Haddock installed.

Don Stewart
  • 137,316
  • 36
  • 365
  • 468
  • 1
    Thanks - the hackage link in the other answer led me to the same flag. Then I updated my .cabal/config file to make that the default. Now (on OS X) I can say "open ~/.cabal/share/doc/$project-*/html/index.html" and the docs pop up in my browser. I've written a bash function to do that for a project name or print an error message if the index.html file doesn't exist. – Harold L Oct 20 '09 at 19:38