Skip to content

Instantly share code, notes, and snippets.

@dpwiz
Last active August 29, 2015 14:02
Show Gist options
  • Save dpwiz/3967fc700c573d382572 to your computer and use it in GitHub Desktop.
Save dpwiz/3967fc700c573d382572 to your computer and use it in GitHub Desktop.
rest-* documentation builder
The script utilizes `cabal sandbox` to keep the guts from spilling into system packages.
The documentation builder is `standalone-haddock`[1] so you have to install it and put on your PATH first. A `hscolour` have to be installed to provide source links.
[1]: https://hackage.haskell.org/package/standalone-haddock
[2]: https://hackage.haskell.org/package/hscolour
#!/usr/bin/env bash
OUTPUT="docs-sh"
PACKAGES="rest-client rest-core rest-gen rest-happstack rest-snap rest-wai rest-types rest-stringmap code-builder"
PACKAGES_SANDBOX=".cabal-sandbox/*-packages.conf.d"
PACKAGE_DB=`readlink -f $PACKAGES_SANDBOX`
ARGS="${@:2}"
PACKAGE_ARGS="${ARGS:-$PACKAGES}"
function help {
echo "$0 <init|build|clean>"
exit
}
function init {
cabal sandbox init
CONFIG=`readlink -f cabal.sandbox.config`
for package in $PACKAGE_ARGS; do
echo $package
cd $package
CABAL_SANDBOX_CONFIG=$CONFIG cabal install -j
CABAL_SANDBOX_CONFIG=$CONFIG cabal configure
cd ..
done
}
function build {
standalone-haddock -o $OUTPUT --package-db $PACKAGE_DB --hyperlink-source $PACKAGE_ARGS
}
function clean {
cabal sandbox delete
}
case "x$1" in
"x") help ;;
"xinit") init ;;
"xbuild") build ;;
"xclean") clean ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment