4# This if stack-enabled fork of https://github.com/ekmett/lens/blob/master/scripts/hackage-docs.sh
7 echo "Usage: scripts/hackage-docs.sh HACKAGE_USER"
13cabal_file=$(find . -maxdepth 1 -name "*.cabal" -print -quit)
14if [ ! -f "$cabal_file" ]; then
15 echo "Run this script in the top-level package directory"
19pkg=$(awk -F ":[[:space:]]*" 'tolower($1)=="name" { print $2 }' < "$cabal_file")
20ver=$(awk -F ":[[:space:]]*" 'tolower($1)=="version" { print $2 }' < "$cabal_file")
23 echo "Unable to determine package name"
28 echo "Unable to determine package version"
32echo "Detected package: $pkg-$ver"
34dir=$(mktemp -d build-docs.XXXXXX)
35trap 'rm -r "$dir"' EXIT
37export PATH=$(stack path --bin-path)
43if haddock --hyperlinked-source >/dev/null
45 echo "Using fancy hyperlinked source"
46 HYPERLINK_FLAG="--haddock-option=--hyperlinked-source"
48 echo "Using boring hyperlinked source"
49 HYPERLINK_FLAG="--hyperlink-source"
52# Cabal dist in temporary location
55# Build dependencies haddocks with stack, so we get links
56stack haddock --only-dependencies
58# Configure using stack databases
59snapshotpkgdb=$(stack path --snapshot-pkg-db)
60localpkgdb=$(stack path --local-pkg-db)
61cabal configure -v2 --builddir=$builddir --package-db=clear --package-db=global --package-db=$snapshotpkgdb --package-db=$localpkgdb
63# Build Hadckage compatible docs
64cabal haddock -v2 --builddir=$builddir $HYPERLINK_FLAG --html-location='/package/$pkg-$version/docs' --contents-location='/package/$pkg-$version'
66# Copy into right directory
67cp -R $builddir/doc/html/$pkg/ $dir/$pkg-$ver-docs
70tar cvz -C $dir --format=ustar -f $dir/$pkg-$ver-docs.tar.gz $pkg-$ver-docs
74 -H 'Content-Type: application/x-tar' \
75 -H 'Content-Encoding: gzip' \
77 --data-binary "@$dir/$pkg-$ver-docs.tar.gz" \
78 "https://hackage.haskell.org/package/$pkg-$ver/docs"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list