[Haskell-cafe] Re: How to get Haddock to generate docs for a
directory tree of modules
brianh at metamilk.com
Mon Apr 24 08:53:25 EDT 2006
Simon Marlow wrote:
> Brian Hulley wrote:
>> I've been looking at the docs for Haddock at
>> http://haskell.org/haddock/haddock-html-0.7/index.html but I can't
>> seem to find any option to recursively traverse a directory
>> generating hyperlinked docs for all modules anywhere in the
>> directory or any sub directory etc.
>> Is there a simple undocumented flag I'm missing?
> Haddock doesn't do this on its own, but Cabal can do it (./setup
> haddock). You do have to specify all the modules in the .cabal file
> though, so it's not really "traversing a directory".
Thanks for this suggestion. I've also got things to work quite well by using
the following makefile on a Windows command shell (using a Win32 port of gnu
make and based on a helpful example makefile received offlist):
# Makefile for Haddock docs
GHCFLAGS = -fglasgow-exts -fffi
API_FILES := $(wildcard *.hs)
# preprocess for Haddock
ghc $(GHCFLAGS) -cpp -E -optP-P -D__HADDOCK__ $^ -o docs/$@
# generate docs
docs: $(patsubst %.hs,%.haddock,$(API_FILES))
haddock -o docs -h $(addprefix docs/, $^)
This works as long as all the subdirectories containing modules are
explicitly listed in API_FILES, and the whole directory tree (including the
docs directory) is manually created (for Windows, since Windows doesn't
automatically create directories that don't exist when it tries to open a
file for writing when the filename contains a path) - not a big problem
since the directory tree only needs to be created once.
More information about the Haskell-Cafe