How to locally generate a preview of the web page for my cabal package?
Question
From the Hackage check/upload page:
Checking a Cabal package
Re-uploading a package with the same version number is not permitted, so you might want to do some checking before uploading:
- You could check that your source bundle builds, including the haddock documentation if it's a library.
- The following form checks that a package is uploadable, warns about sundry other matters, and presents a preview of the web page for the package. It does not add the package to the database.
(my emphasis)
How do I generate a preview of the web page for the package locally? i.e. without using that website form?
(The "web page for the package" is e.g. this is QuickCheck's.)
Solution
You use cabal haddock
to generate this page. This will generate the documentation in dist/doc/html/<library-or-executable-name>/index.html
.
Additionally, you can edit your ~/.cabal/config
file to include the line:
documentation: True
This will automatically install documentation for all of the packages you install with Cabal, and you will get a list of all installed modules on the system in the ~/.cabal/share/doc/index.html
file; this is useful for ghci
sessions or when you want to find out which package contains which modules, etc.