Search code examples
haskelldocumentationhaddock

how to generate documentations with haddock?


The project I am using does not have docs on Stackage (they're out of date). Here is the original one which is on verson 0.3

https://hackage.haskell.org/package/reflex-dom-0.3/docs/Reflex-Dom-Widget-Basic.html

I was told I could generate docs with haddock. I have the source code on my computer (using git clone) version 0.4

The haddock web page was way too advanced.

For the beginner, once I am in my directory, how do I generate docs?


Thanks to one of the answer I made come progress, but here is an error message:

src/Reflex/Dom/Xhr.hs:154:0:
     error: missing binary operator before token "("
     #if MIN_VERSION_aeson(1,0,0)
     ^

Solution

  • Once you have installed haddock, you can run it as follows:

    haddock --html -o <haddock-folder> <list-of-haskell-files>
    

    So for instance:

    haddock --html -o the_documentation *.hs
    

    will generate the documentation of all the Haskell files in that directory (not any subdirectories) in a directory named the_documentation.

    Some shells allow **.hs to look for all .hs files (subdirectories included). So you might try:

    haddock --html -o the_documentation **.hs
    

    If the shell does not suport that, you can of course use a combination of find and xargs, like:

    find -iname '*.hs' | xargs haddock --html -o the_documentation
    

    Here find will generate a list of all files that end with .hs, and xargs will write all these files as parameters to haddock --html ....