Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update hackage-docs.sh for new cabal-install
[ci skip]
- Loading branch information
Showing
1 changed file
with
10 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,17 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: scripts/hackage-docs.sh HACKAGE_USER" | ||
exit 1 | ||
fi | ||
|
||
user=$1 | ||
|
||
cabal_file=$(find . -maxdepth 1 -name "*.cabal" -print -quit) | ||
if [ ! -f "$cabal_file" ]; then | ||
echo "Run this script in the top-level package directory" | ||
exit 1 | ||
fi | ||
# Run this script in the top-level of your package directory | ||
# (where the .cabal file is) to compile documentation and | ||
# upload it to hackage. | ||
|
||
pkg=$(awk -F ":[[:space:]]*" 'tolower($1)=="name" { print $2 }' < "$cabal_file") | ||
ver=$(awk -F ":[[:space:]]*" 'tolower($1)=="version" { print $2 }' < "$cabal_file") | ||
# Requirements: | ||
# cabal-install-1.24 (for --for-hackage) | ||
# haddock 2.17 (for the hyperlinked source) | ||
|
||
if [ -z "$pkg" ]; then | ||
echo "Unable to determine package name" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$ver" ]; then | ||
echo "Unable to determine package version" | ||
exit 1 | ||
fi | ||
|
||
echo "Detected package: $pkg-$ver" | ||
set -e | ||
|
||
dir=$(mktemp -d build-docs.XXXXXX) | ||
dir=$(mktemp -d dist-docs.XXXXXX) | ||
trap 'rm -r "$dir"' EXIT | ||
|
||
|
||
if haddock --hyperlinked-source >/dev/null | ||
then | ||
echo "Using fancy hyperlinked source" | ||
HYPERLINK_FLAG="--haddock-option=--hyperlinked-source" | ||
else | ||
echo "Using boring hyperlinked source" | ||
HYPERLINK_FLAG="--hyperlink-source" | ||
fi | ||
|
||
cabal haddock --hoogle $HYPERLINK_FLAG --html-location='/package/$pkg-$version/docs' --contents-location='/package/$pkg-$version' | ||
|
||
cp -R dist/doc/html/$pkg/ $dir/$pkg-$ver-docs | ||
|
||
tar cvz -C $dir --format=ustar -f $dir/$pkg-$ver-docs.tar.gz $pkg-$ver-docs | ||
|
||
curl -X PUT \ | ||
-H 'Content-Type: application/x-tar' \ | ||
-H 'Content-Encoding: gzip' \ | ||
-u "$user" \ | ||
--data-binary "@$dir/$pkg-$ver-docs.tar.gz" \ | ||
"https://hackage.haskell.org/package/$pkg-$ver/docs" | ||
cabal haddock --builddir="$dir" --for-hackage --haddock-option=--hyperlinked-source | ||
cabal upload -d $dir/*-docs.tar.gz |