views:

293

answers:

3

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.

+2  A: 

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
@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
Thanks, your notes in that post also led me to change my .cabal/config to generate docs by default.
Harold L
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
+2  A: 

You should be able to generate local documentation with:

cabal install $project --haddock

Assuming you have Haddock installed.

Don Stewart
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
+1  A: 
cabal install $project --haddock

The above didn’t work for me. However, replacing “--haddock” with “--enable-documentation” did. Now, if they could allow the “--hyperlink-source” flag to zip through to haddock I’d be very happy.

Kim