-
Notifications
You must be signed in to change notification settings - Fork 1
/
docs.sh
executable file
·69 lines (53 loc) · 1.54 KB
/
docs.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
#!/bin/bash
# -----------------------------------------------------------------------------
# Find the directory the script is in.
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
# -----------------------------------------------------------------------------
# Start a Python HTTP server.
cd "$DIR/docs"
if [[ ! -d "build" ]]; then
mkdir build
fi
cd build
python3 -m http.server --bind localhost 2> /dev/null &
HTTP_PID="$!"
function terminate() {
echo
echo "Stopping HTTP server..."
kill $HTTP_PID
wait $HTTP_PID
rm -rf "$DIR/docs/build"
exit 0
}
trap terminate SIGINT
cd ..
# -----------------------------------------------------------------------------
# Build the source
while true; do
clear
# Build the docs.
julia --color=yes "--project=$DIR/docs" make.jl nodeploy notest
echo
echo "Build complete!"
# Clean up
if [[ -d "build" ]]; then
rm -rf "$DIR/docs/tessdata"
fi
if [[ -f "$DIR/docs/sample_es.tiff" ]]; then
rm "$DIR/docs/sample_es.tiff"
fi
if [[ -f "$DIR/docs/sample_fr.tiff" ]]; then
rm "$DIR/docs/sample_fr.tiff"
fi
if [[ -f "$DIR/docs/sample.tiff" ]]; then
rm "$DIR/docs/sample.tiff"
fi
# Wait for a change.
inotifywait -q -r -e close_write "$DIR/docs/src" "$DIR/src" "$DIR/docs/make.jl"
done