Building haddock docs with Cabal from .lhs sources

Alistair Bayley alistair at abayley.org
Wed Sep 19 05:44:00 EDT 2007


Hello,

I'm having a bit of fun trying to get Cabal to make Haddock docs for
Takusen. Takusen's sources are a mixture of .lhs (birdtrack), .hs, and
.hsc files. .hsc files are preprocessed OK, but the cabal source code
for the haddock build action, and also the preprocessor code, seems to
deal with .lhs -> .hs as a special case.

The normal .lhs -> .hs preprocessor strips comments, which is useless
for hadock. I have tried to hook in a custom preprocessor to turn .lhs
into .hs (while preserving comments), but this is not triggered
because of the hard-coded special cases for .lhs -> .hs. I have
resorted to lifting out the entire hadbock function from
Distribution.Simple, and modifying it so that it does nothing special
for .lhs files. My own .lhs -> .hs transformation runs just before the
new haddock hook.

Does anyone have a better solution than this?

Also, when I finally run haddock, I get this (sorry about the odd
formatting, it's a cut-'n'patse from a Windows cmd.exe terminal):

C:\haskell\bin\haddock.exe --html --odir=dist\doc\html --title=Takusen-0.7: Data
base access library with left-fold interface. Supports PostgreSQL, Oracle, SQLit
e. --package=Takusen-0.7 --dump-interface=dist\doc\html\Takusen.haddock --prolog
ue=Takusen-0.7-haddock-prolog.txt --use-package=base-2.1.1 --use-package=mtl-1.0
.1 --use-package=time-1.1.1 dist\build\tmp\Database\Enumerator.hs dist\build\tmp
\Database\Enumerator.hs dist\build\tmp\Database\Util.hs dist\build\tmp\Database\
Util.hs dist\build\tmp\Database\ODBC\Enumerator.hs dist\build\tmp\Database\ODBC\
Enumerator.hs dist\build\tmp\Database\ODBC\OdbcFunctions.hs dist\build\tmp\Datab
ase\Oracle\Enumerator.hs dist\build\tmp\Database\Oracle\Enumerator.hs dist\build
\tmp\Database\Oracle\OCIConstants.hs dist\build\tmp\Database\Oracle\OCIConstants
.hs dist\build\tmp\Database\Oracle\OCIFunctions.hs dist\build\tmp\Database\Oracl
e\OCIFunctions.hs dist\build\tmp\Database\PostgreSQL\Enumerator.hs dist\build\tm
p\Database\PostgreSQL\Enumerator.hs dist\build\tmp\Database\PostgreSQL\PGFunctio
ns.hs dist\build\tmp\Database\PostgreSQL\PGFunctions.hs dist\build\tmp\Database\
Sqlite\Enumerator.hs dist\build\tmp\Database\Sqlite\Enumerator.hs dist\build\tmp
\Database\Sqlite\SqliteFunctions.hs dist\build\tmp\Database\Sqlite\SqliteFunctio
ns.hs dist\build\tmp\Database\Stub\Enumerator.hs dist\build\tmp\Database\Stub\En
umerator.hs dist\build\tmp\Control\Exception\MonadIO.hs dist\build\tmp\Foreign\C
\UTF8.hs dist\build\tmp\Database\InternalEnumerator.hs dist\build\tmp\Database\I
nternalEnumerator.hs --hide=Database.InternalEnumerator
Warning: cannot use package base-2.1.1:
 does not exist.y c:/ghc/ghc-6.6.1\html\libraries\base
Warning: cannot use package mtl-1.0.1:
 does not exist.y c:/ghc/ghc-6.6.1\html\libraries\mtl
Warning: cannot use package time-1.1.1:
 does not exist.y c:/ghc/ghc-6.6.1\html\libraries\time
Warning: Foreign.C.UTF8: the following names could not be resolved:
    CChar Word8 CString IO String CStringLen Char Int Ptr
 <wads of unresolved-name warnings>

There are two problems:
  1. the library docs bundled with GHC are actually under
c:\ghc\ghc-6.6.1\doc\html\libraries, not
c:\ghc\ghc-6.6.1\html\libraries. ghc-pjg reports them as in
$topdir\html\libraries\base (etc), where I assume $topdir is
c:\ghc\ghc-6.6.1. I've copied them up to
c:\ghc\ghc-6.6.1\html\libraries to try to keep haddock happy, but as
you can see...

  2. even with the base.haddock etc files in the right places, haddock
still doesn't find them. !?

Alistair


More information about the Libraries mailing list