[Haskell-cafe] Problem with haddock 2.3.0 (again)
Sean Leather
leather at cs.uu.nl
Thu Dec 11 18:22:04 EST 2008
> I would be happy to work around it if I could, but I can't. As far as I can
> tell, I can't pass any flags to Haddock via the Cabal file. I would love to
> tell Hackage to run Haddock like so, "cabal haddock
> --haddock-option=--optghc=-D__HADDOCK__", but I don't know how.
>
Let's suppose that I do actually want to define __HADDOCK__ for my library.
Can I do this with a user-defined hook using the Cabal library?
main :: IO ()
main = defaultMainWithHooks hooks where
hooks = simpleUserHooks { haddockHook = haddockHook' }
-- Define CPP __HADDOCK__ macro when running haddock.
haddockHook' p l h f =
do putStrLn ("f=\"" ++ show f ++ "\"")
putStrLn ("f'=\"" ++ show f' ++ "\"")
haddock p l (hookedPreProcessors h) f'
where
-- The Haddock flag to pass a flag to GHC to define the macro.
*define__HADDOCK__ = ("haddock",["--optghc=-D__HADDOCK__"])*
-- Add the flag to the the other flags.
f' = f `mappend` emptyHaddockFlags { haddockProgramArgs =
[define__HADDOCK__] }
I got the value for define__HADDOCK__ from passing the
"--haddock-option=--optghc=-D__HADDOCK__" flag at the command line.
If I run "cabal haddock --verbose=3", I get:
f="HaddockFlags {haddockProgramPaths = [], haddockProgramArgs = [],
haddockHoogle = Flag False, haddockHtmlLocation = NoFlag, haddockExecutables
= Flag False, haddockInternal = Flag False, haddockCss = NoFlag,
haddockHscolour = Flag False, haddockHscolourCss = NoFlag, haddockDistPref =
Flag "dist", haddockVerbosity = Flag Deafening}"
f'="HaddockFlags {haddockProgramPaths = [], haddockProgramArgs = *
[("haddock",["--optghc=-D__HADDOCK__"])]*, haddockHoogle = Flag False,
haddockHtmlLocation = NoFlag, haddockExecutables = Flag False,
haddockInternal = Flag False, haddockCss = NoFlag, haddockHscolour = Flag
False, haddockHscolourCss = NoFlag, haddockDistPref = Flag "dist",
haddockVerbosity = Flag Deafening}"
[...]
("/.../haddock",["--html", ...
My flag shows up in f' but not in the actual call to haddock. Thus, it
doesn't work.
With "cabal haddock --verbose=3 --haddock-option=--optghc=-D__HADDOCK__", I
get:
f="HaddockFlags {haddockProgramPaths = [], haddockProgramArgs = [*
("haddock",["--optghc=-D__HADDOCK__"])]*, haddockHoogle = Flag False,
haddockHtmlLocation = NoFlag, haddockExecutables = Flag False,
haddockInternal = Flag False, haddockCss = NoFlag, haddockHscolour = Flag
False, haddockHscolourCss = NoFlag, haddockDistPref = Flag "dist",
haddockVerbosity = Flag Deafening}"
f'="HaddockFlags {haddockProgramPaths = [], haddockProgramArgs = *
[("haddock",["--optghc=-D__HADDOCK__"]),("haddock",["--optghc=-D__HADDOCK__"])]
*, haddockHoogle = Flag False, haddockHtmlLocation = NoFlag,
haddockExecutables = Flag False, haddockInternal = Flag False, haddockCss =
NoFlag, haddockHscolour = Flag False, haddockHscolourCss = NoFlag,
haddockDistPref = Flag "dist", haddockVerbosity = Flag Deafening}"
[...]
("/.../haddock",[*"--optghc=-D__HADDOCK__"*,"--html", ...
Now, the command-line flag shows up in all 3. And, of course, it works.
Is there something wrong with my hook code?
Regards,
Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081212/62b59780/attachment.htm
More information about the Haskell-Cafe
mailing list