I have annotated my code in Haddock style and would like to generate browse-able documentation. Since I am also using stack, I want to integrate the documentation generation into the workflow. However, I have not yet been able to generate anything useful.
I can run
stack haddock
and it will generate documentation in the style I want (to be found deep inside ~/.stack/
), but it only seems to generate documentation for the packages I depend on, rather than for my own code.
When I run
stack haddock --help
I get the impression that I can use the additional argument --haddock
to generate documentation for my own project, and --no-haddock-deps
to leave out the documentation for my dependencies. However, when I run
stack haddock --haddock --no-haddock-deps
nothing seems to happen. If I stack clean
first it will recompile all my code but no output is generated seeming to relate in any way to documentation.
As an intermediate solution I have also tried running Haddock by itself, i.e.
haddock my-source.hs
but then I get an error that it cannot find a module the file depends on (which is installed locally by stack). This gives me the impression that documentation generation will have to go through stack somehow. I have looked for, but not really found any explanations related to configuring my .cabal
and stack.yaml
files for documentation.
TL;DR
How can I use stack and Haddock to generate documentation for the code in my own package?
stack path
), see here: github.com/commercialhaskell/stack/issues/729 (including suggested workaround for building docs for executables with "cabal haddock"). – Rüdiger Hankecabal haddock
and the linked suggested workaround. If you want to write it out as an answer I'll accept it, if not I can write up the solution myself. (My project is an executable.) – Sam van Herwaarden