| 1 |
ron |
1 |
#!/usr/bin/env bash
|
|
|
2 |
#
|
|
|
3 |
# mfdoc
|
|
|
4 |
#
|
|
|
5 |
# Start Jekyll in watch mode to work on Marlin Documentation and preview locally
|
|
|
6 |
#
|
|
|
7 |
|
|
|
8 |
[[ $# == 0 ]] || { echo "Usage: `basename $0`" 1>&2 ; exit 1; }
|
|
|
9 |
|
|
|
10 |
MFINFO=$(mfinfo "$@") || exit 1
|
|
|
11 |
IFS=' ' read -a INFO <<< "$MFINFO"
|
|
|
12 |
ORG=${INFO[0]}
|
|
|
13 |
REPO=${INFO[2]}
|
|
|
14 |
BRANCH=${INFO[5]}
|
|
|
15 |
|
|
|
16 |
[[ $ORG == "MarlinFirmware" && $REPO == "MarlinDocumentation" ]] || { echo "Wrong repository." 1>&2; exit 1; }
|
|
|
17 |
|
|
|
18 |
opensite() {
|
|
|
19 |
TOOL=$(which gnome-open xdg-open open | awk '{ print $1 }')
|
|
|
20 |
URL="http://127.0.0.1:4000/"
|
|
|
21 |
if [ -z "$TOOL" ]; then
|
|
|
22 |
echo "Can't find a tool to open the URL:"
|
|
|
23 |
echo $URL
|
|
|
24 |
else
|
|
|
25 |
echo "Opening preview site in the browser..."
|
|
|
26 |
"$TOOL" "$URL"
|
|
|
27 |
fi
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
echo "Previewing MarlinDocumentation..."
|
|
|
31 |
|
|
|
32 |
# wait to open the url for about 8s
|
|
|
33 |
( sleep 45; opensite ) &
|
|
|
34 |
|
|
|
35 |
bundle exec jekyll serve --watch --incremental
|