Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Script for generating and uploading missing documentation for your Hackage packages. Now with fixed package links and contents page.

View hackagedocs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/usr/bin/env bash
cabal configure && cabal build && cabal haddock --hyperlink-source \
--html-location='/package/$pkg-$version/docs' \
--contents-location='/package/$pkg'
S=$?
if [ "${S}" -eq "0" ]; then
cd "dist/doc/html"
DDIR="${1}-${2}-docs"
cp -r "${1}" "${DDIR}" && tar -c -v -z --format=ustar -f "${DDIR}.tar.gz" "${DDIR}"
CS=$?
if [ "${CS}" -eq "0" ]; then
echo "Uploading to Hackageā€¦"
curl -X PUT -H 'Content-Type: application/x-tar' -H 'Content-Encoding: gzip' --data-binary "@${DDIR}.tar.gz" "https://${3}:${4}@hackage.haskell.org/package/${1}-${2}/docs"
exit $?
else
echo "Error when packaging the documentation"
exit $CS
fi
else
echo "Error when trying to build the package."
exit $S
fi
hvr commented

I would rather use relative urls, e.g. --html-location='/package/$pkg/docs'

What does the -Hustar in the tar command do? On OS X it was not recognized and I had to remove it.

Also note that you have to have documentation for all the linked packages on your local system, even though it's totally ignored. If you don't, then haddock won't create links for those packages.

mtolly commented

/package/$pkg-version/docs should be /package/$pkg-$version/docs ($ in front of version).

Owner

@mtolly updated

nh2 commented

@Fuuzetsu Can you switch the curl to https?

curl -u ${3}:${4} worked better for me than inlining the user and password into the URL. I have a several URL metacharacters in my password.

I recommend also adding the --hoogle option to cabal haddock, so we get a Hoogle database as well.

Owner

@lfairy, the --hoogle Haddock flag is almost useless, the backend needs fixing severly

Owner

@cheecheeo can you post the whole curl incantation you would like?

sol commented

@Fuuzetsu Have you tried to parse package name/version from cabal info ., so that $1/$2 can be omitted?

Is the password sent over the wire as cleartext?

(I'm using a modified version of this in hope that it rectifies this: https://gist.github.com/soenkehahn/038701a58cfc0cacca57)

Owner

@sol it could do that, sure, I just never bothered, this was a quick few minute hack that I think got a bit too popular

@soenkehahn I would be glad to incorporate any changes needed, just send me a diff

Everyone: please note that GitHub does not notify me on comments on gists, if you want me to make changes to this script, I'll happily do so (or link to a better one) but you'll have to contact me somehow, IRC, e-mail, whatever. It might take weeks/months for me to see things here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.