MyNixOS website logo
Description

Help Manage project specific documentation.

Parochial helps manage local documentation by creating an index of a project's html, it also builds a hoogle index. In both instances the project's transitive dependencies are included.

Parochial

Parochial is a tool for managing local haddocks and hoogle databases. I work in cafes and on the train plus I live in Australia where the internet speed is, err, somewhat variable. The other significant benefit I found when learning Haskell (and I'm very much still in that category) is knowing that I was reading the actual documentation of the installed library. For example if I searched for a function on Hoogle I wasn't sure if it was the correct function. In fact I still find this really useful.

The whole point behind Parochial is to group the documentation on a project by project basis. For the html documentation it simply builds a symlink farm to the installed documentation in $HOME/.cabal/... (you will need to set the -haddock ghc option or set it in $HOME/.cabal/config to ensure the documentation is built) to a directory named after the current project in $XDG_DATA_DIR/parochial. For the hoogle database it does much the same but instead of building a symlink farm it builds a hoogle database, again named after the project.

Benefits

  • Fast.
  • Works without an internet connection.
  • Per project documentation.
  • Indexes all project libraries (including transitive dependencies). Hoogle only indexes Stackage which doesn't include everything on Hackage.

Of course the downside is that if you don't have the library in your cabal file you won't have any documentation for it.

Limitations

This is still fairly raw and at an early stage of development but it's certainly usable and I will be adding to it over time.

  • Only works for Simple distributions.
  • Only tested with nix-style local builds.
  • Only works for projects that build a binary. You can work around this by specifying the state file with the --state option.
  • It's tied to a specific hoogle version so if the docs in $HOME/.cabal/... were built with a different version parochial will fail with a version mismatch error.
  • It's tied to a specific version of cabal. I thinkcabal-helpr should fix this but I need to look into it more.
  • If you want to access the hoogle database from a browser you will need to run hoogle server manually. This is probably fine if you mainly work on one project but would become annoying fairly quickly. The hoogle hrefs are file:///</local/path> which most browsers will refuse to render.
  • I'm sure there are others as well!

Usage

Building the Documentation

parochial --help displays a help message.

If the project contains a single binary the following will work:

for haddock:

parochial haddock

and hoogle:

parochial hoogle

If the project containes a single library then you will need to provide the --state option:

for haddock:

parochial haddock --state $(find . -name setup-config)

and hoogle:

parochial hoogle --state $(find . -name setup-config)

It there is more than one library you will need to build each one separately (I want to fix this in the future):

for haddock:

find . -name setup-config | xargs -n1 parochial haddock --state

and hoogle:

find . -name setup-config | xargs -n1 parochial hoogle --state

Reading the Documentation

Serving up the html

I use caddy to serve up the target directory but you can choose whatever you like, it just needs to be able to serve up some files. The following Caddyfile should do the job:

localhost:80 {
  file_server browse
}

Either change the port number to above 1024 or set the following capability on the caddy binary. As root run:

setcap CAP_NET_BIND_SERVICE=ep $(which caddy)

Command line hoogle

You can specify the database on the command line, like so:

hoogle --database=/$XDG_DATA_DIR/parochial/parochial.hoo Functor

or write a simple wrapper script that infers the name of the database from the CWD or some other clue.

TODO

  • Work out a better way of locating the setup-config parent directory. I basically recurse the dist directory searching for setup-config which works but is pretty simplistic. I would have thought Cabal would have a way of doing this but I can't find it. If anyone knows how to do this please do let me know.
  • Integrate the local hoogle database and the local haddocks.
  • If the project has multiple local packages merge the results so the documentation is in a single place for the entire project.
  • Make the index page less ugly.
Metadata

Version

0.2.0.0

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows