-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathbuild-documentation.sh
executable file
·52 lines (37 loc) · 1.02 KB
/
build-documentation.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
#!/bin/bash
# exit when any command fails
set -e
# check jazzy is installed
if ! command -v jazzy &> /dev/null
then
echo "Error: 'jazzy' is not installed. Please see https://github.com/realm/jazzy"
exit 126
fi
# specify custom config (or use default)
CFG_FILE=$1
CFG_FILE=".${CFG_FILE:-jazzy}.yaml"
# allow user to specify a browser ( for Chrome use `Google Chrome`)
BROWSER=$2
BROWSER="${BROWSER:-Safari}"
PROJECT_DIR=$PWD
HTML_DIR=$PWD/Docs/html
IMG_SRC_DIR=$PWD/Docs/images/
IMG_DEST_DIR=$HTML_DIR/images
INDEX_PAGE=$HTML_DIR/index.html
function imageSync() {
echo "# syncing images: $IMG_SRC_DIR -> $IMG_DEST_DIR"
rsync --exclude "src" \
--exclude "hires" \
--exclude "psd" \
--exclude "*.psd" \
--exclude "*.aseprite" \
--exclude "*.ase" \
-auvh --no-perms $IMG_SRC_DIR $IMG_DEST_DIR;
}
# run the jazzy command
jazzy --config "$CFG_FILE" ;
# create the images directory
[ -d $IMG_DEST_DIR ] || mkdir $IMG_DEST_DIR
# rsync images
imageSync;
open -a "$BROWSER" $INDEX_PAGE;