aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/serve-docs.sh
diff options
context:
space:
mode:
authorGravatar Alex Humesky <ahumesky@google.com>2016-06-22 19:14:13 +0000
committerGravatar Lukacs Berki <lberki@google.com>2016-06-23 11:10:21 +0000
commit6105e2415faa0f36ec6ae3399d90e1a173ef7f58 (patch)
tree6ddb293760a7df70d67ba93e32b093674a8f3f3e /scripts/serve-docs.sh
parent3a8935c28d3407b893cd23edde5355fc2b688ba9 (diff)
Update serve-docs.sh to allow easily rebuilding the docs and restarting jekyll by pressing "r".
-- MOS_MIGRATED_REVID=125593474
Diffstat (limited to 'scripts/serve-docs.sh')
-rwxr-xr-xscripts/serve-docs.sh46
1 files changed, 35 insertions, 11 deletions
diff --git a/scripts/serve-docs.sh b/scripts/serve-docs.sh
index 8b6c119b61..6723682b4b 100755
--- a/scripts/serve-docs.sh
+++ b/scripts/serve-docs.sh
@@ -18,28 +18,52 @@ set -eu
readonly PORT=${1-12345}
readonly WORKING_DIR=$(mktemp -d)
-trap "rm -rf $WORKING_DIR" EXIT
function check {
which $1 > /dev/null || (echo "$1 not installed. Please install $1."; exit 1)
}
-function main {
- check jekyll
-
+function build_and_serve {
bazel build //site:jekyll-tree.tar
+ rm -rf $WORKING_DIR/*
tar -xf bazel-genfiles/site/jekyll-tree.tar -C $WORKING_DIR
- cd $WORKING_DIR
+ pkill -9 jekyll || true
+ jekyll serve --detach --quiet --port $PORT --source $WORKING_DIR
+}
+
+function main {
+ check jekyll
+
old_version="Jekyll 0.11.2"
if expr match "$(jekyll --version)" "$old_version"; then
# The ancient version that apt-get has.
- echo "WARNING: Running with an old version of Jekyll, consider updating " \
- "to 2.5.3 (\`gem install jekyll -v 2.5.3\`)"
- jekyll serve --server $PORT
- else
- # Any reasonable version.
- jekyll serve --port $PORT
+ echo "ERROR: Running with an old version of Jekyll, update " \
+ "to 2.5.3 with \`sudo gem install jekyll -v 2.5.3\`"
+ exit 1
fi
+
+ build_and_serve
+
+ echo "Type q to quit, r to rebuild docs and restart jekyll"
+ while true; do
+
+ read -n 1 -s user_input
+ if [ "$user_input" == "q" ]; then
+ echo "Quitting"
+ exit 0
+ elif [ "$user_input" == "r" ]; then
+ echo "Rebuilding docs and restarting jekyll"
+ build_and_serve
+ echo "Rebuilt docs and restarted jekyll"
+ fi
+ done
}
+
+function cleanup {
+ rm -rf $WORKING_DIR
+ pkill -9 jekyll
+}
+trap cleanup EXIT
+
main