forked from mongodb/casbah
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildDocs.sh
executable file
·84 lines (68 loc) · 2.18 KB
/
buildDocs.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
usage()
{
cat << EOF
usage: $0 options
This script generates the casbah documentation
OPTIONS:
-h Show this message
-g Auto update the gh-pages branch
EOF
}
GHPAGES=false
while getopts "h:g" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
g)
GHPAGES=$OPTARG
;;
?)
usage
exit
;;
esac
done
SCALA=2.10
WEBSITE_ROOT=mongodb.github.com/casbah/
SPHINX_DIR=./src/sphinx
SITE_DIR=./target/site/
./sbt ++2.10.4 "update" "clean" "compile" "make-site" "unidoc"
mkdir -p $SITE_DIR/api.sxr/casbah-commons
mkdir -p $SITE_DIR/api.sxr/casbah-core
mkdir -p $SITE_DIR/api.sxr/casbah-gridfs
mkdir -p $SITE_DIR/api.sxr/casbah-query
cp ./casbah-commons/target/scala-$SCALA/classes.sxr/* $SITE_DIR/api.sxr/casbah-commons
cp ./casbah-core/target/scala-$SCALA/classes.sxr/* $SITE_DIR/api.sxr/casbah-core
cp ./casbah-gridfs/target/scala-$SCALA/classes.sxr/* $SITE_DIR/api.sxr/casbah-gridfs
cp ./casbah-query/target/scala-$SCALA/classes.sxr/* $SITE_DIR/api.sxr/casbah-query
touch $SITE_DIR/.nojekyll
# Remove double slashes
find $SITE_DIR/api/ -name \*html -exec sed -i "" 's#.sxr//#.sxr/#g' {} \;
# Update the sxr in url
find $SITE_DIR/api/ -name \*html -exec sed -i "" 's#/src\(.*\)/\(.*scala.html\)#/\2#' {} \;
# Update WEBSITE ROUTE
find $SITE_DIR/api/ -name \*html -exec sed -i "" "s#/{{WEBSITE_ROOT}}#/$WEBSITE_ROOT#g" {} \;
# Make pdf / epub
make -C $SPHINX_DIR clean html epub latexpdf
cp $SPHINX_DIR/_build/epub/CasbahMongoDBScalaToolkitDocumentation.epub $SITE_DIR/CasbahDocumentation.epub
cp $SPHINX_DIR/_build/latex/CasbahDocumentation.pdf $SITE_DIR/CasbahDocumentation.pdf
echo " ========== "
echo " Docs built "
echo " ========== "
if $GHPAGES && git diff-index --quiet HEAD --; then
echo " ========================== "
echo " Updating 'gh-pages' branch"
echo " ========================== "
git co gh-pages
mv target .target
rm -rf *
cp -R .target/site/* .
mv .target target
echo " Please check the new docs and checkin ..."
elif $GHPAGES; then
echo "You have changes not checked-in - cannot automatically update gh-pages"
fi