-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack-gh-pages-haddock.sh
63 lines (53 loc) · 1.24 KB
/
stack-gh-pages-haddock.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh
# Based on https://github.com/yamadapc/stack-gh-pages
set -o errexit
set -o xtrace
mkdocs() {
package=$1
stack_yaml=$2
parent_dir=$(pwd)
docsdir="$parent_dir/haddocks"
cd "$package"
stack --stack-yaml "$stack_yaml" \
haddock \
--haddock-hyperlink-source \
--no-haddock-deps \
--force-dirty \
--haddock-arguments --odir=temp-docs
me=$(whoami)
sudo chown -R "$me"."$me" temp-docs
cd "$parent_dir"
rm -rf "$docsdir"
mv "$package/temp-docs" "$docsdir"
}
mkindex() {
cat << END > index.html
<!DOCTYPE html>
<html>
<head>
<title>Shrubbery Documentation</title>
</head>
<body>
<h1>Documentation for yet-to-be released Shrubbery packages</h1>
<ul>
<li><a href="haddocks">shrubbery</a></li>
</ul>
</body>
</html>
END
}
push_to_pages_branch() {
git stash
git branch -D gh-pages || echo "No existing pages branch to delete"
git checkout --orphan gh-pages
git add .
git commit -m "Automated Haddock commit"
git checkout main
echo "Docs have been generated on the gh-pages branch."
echo "You can push make them live with the following command:"
echo ""
echo " git push -f -u origin gh-pages:gh-pages"
}
mkdocs . stack.yaml
mkindex
push_to_pages_branch