Skip to content

Instantly share code, notes, and snippets.

@hvr
Last active August 29, 2015 13:59
Show Gist options
  • Save hvr/4b7b3074826ccc327a7d to your computer and use it in GitHub Desktop.
Save hvr/4b7b3074826ccc327a7d to your computer and use it in GitHub Desktop.
regen haddock docs
#!/bin/bash
set -e
PKGID="$1"
PKGN=$(echo "$PKGID" | sed 's,^\(.*\)-\([0-9.]*\)$,\1,')
PKGV=$(echo "$PKGID" | sed 's,^\(.*\)-\([0-9.]*\)$,\2,')
# EDIT ME XXX
CREDS="MyUser:MyPass"
if [ "${PKGN}-${PKGV}" != "$PKGID" ]; then
echo "internal error"
exit 1
fi
rm -rf tmp.doc
mkdir tmp.doc
cd tmp.doc
# http://hackage.haskell.org/package/hoopl-3.10.0.1/hoopl-3.10.0.1.tar.gz
wget https://hackage.haskell.org/package/${PKGID}/${PKGID}.tar.gz
tar xaf $PKGID.tar.gz
cd $PKGID
cabal configure -O0 --solver=topdown
cabal haddock \
--hoogle --html \
--hyperlink-source \
--contents-location='/package/$pkg-$version' \
--html-location='/package/$pkg-$version/docs'
cd ..
mv -v $PKGID/dist/doc/html/$PKGN "$PKGID-docs"
cp -v ../haddock-util.js "$PKGID-docs/"
tar --format=ustar -cvzf "$PKGID-docs".tar.gz "$PKGID-docs"
curl -i -X DELETE -u "${CREDS}" https://hackage.haskell.org/package/$PKGID/docs
curl -i \
-X PUT --data-binary @"$PKGID-docs".tar.gz \
-H "Content-Type: application/x-tar" \
-H "Content-Encoding: gzip" \
-u "${CREDS}" \
https://hackage.haskell.org/package/$PKGID/docs
echo https://hackage.haskell.org/package/$PKGID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment