forked from asmexcaliburwoods/isis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreview.sh
152 lines (137 loc) · 4.31 KB
/
preview.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/env bash
export ANTORA_CACHE_DIR=.antora-cache-dir
export ANTORA_TARGET_SITE=antora/target/site
#
# for now, we disable index generation, because (a) java 11 dependency,
# probably not available on CI build server, and (b) need to build tooling.
#
# nevertheless, a committer can use this script to easily regenerate the
# index (only) using the -I flag.
#
PLAYBOOK_FILE=antora/playbooks/site.yml
BRANCH=$(git branch --show-current)
DATE=$(date +%Y%m%d-%H%M)
export REVISION="${BRANCH}.${DATE}"
while getopts 'ECDAKSLecdaksxylhf:' opt
do
case $opt in
E) export SKIP_EXAMPLES=false
forcing=true ;;
C) export SKIP_CONFIGS=false
forcing=true ;;
D) export SKIP_PROJDOC_GENERATION=false
forcing=true ;;
L) export SKIP_FIX_ADOC_LINE_ENDINGS=false
forcing=true ;;
A) export SKIP_ANTORA_GENERATION=false
export SKIP_CLEAR_CACHE=false
export SKIP_CLEAR_PREVIOUS=false
forcing=true ;;
K) export SKIP_STALE_EXAMPLE_CHECK=false
forcing=true ;;
S) export SKIP_SERVE=false
forcing=true ;;
e) export SKIP_EXAMPLES=true ;;
c) export SKIP_CONFIGS=true ;;
d) export SKIP_PROJDOC_GENERATION=true ;;
l) export SKIP_FIX_ADOC_LINE_ENDINGS=true ;;
a) export SKIP_ANTORA_GENERATION=true
export SKIP_CLEAR_CACHE=true
export SKIP_CLEAR_PREVIOUS=true
;;
k) export SKIP_STALE_EXAMPLE_CHECK=true ;;
s) export SKIP_SERVE=true ;;
x) export SKIP_CLEAR_CACHE=true ;;
y) export SKIP_CLEAR_PREVIOUS=true ;;
f) PLAYBOOK_FILE=$OPTARG ;;
h) echo ""
echo "preview.sh options:"
echo ""
echo " Skip options:"
echo " -e skip examples"
echo " -k skip stale example check"
echo " -c skip config doc generation"
echo " -d skip projdoc generation"
echo " -l skip fix adoc line endings"
echo " -a skip Antora generation"
echo " -s skip serving generated site"
echo ""
echo " Force options (override skip):"
echo " -E force examples"
echo " -K force stale example check"
echo " -C force config doc generation"
echo " -D force projdoc generation"
echo " -L force fix adoc line endings"
echo " -A force Antora generation"
echo " -S force serving generated site"
echo ""
echo " -f antora/playbooks/site-xxx.yml"
exit 1
;;
*) echo "unknown option $opt - aborting" >&2
exit 1
;;
esac
done
if [ "$forcing" = "true" ]; then
if [ -z "$SKIP_EXAMPLES" ]; then
export SKIP_EXAMPLES=true
fi
if [ -z "$SKIP_CONFIGS" ]; then
export SKIP_CONFIGS=true
fi
if [ -z "$SKIP_PROJDOC_GENERATION" ]; then
export SKIP_PROJDOC_GENERATION=true
fi
if [ -z "$SKIP_FIX_ADOC_LINE_ENDINGS" ]; then
export SKIP_FIX_ADOC_LINE_ENDINGS=true
fi
if [ -z "$SKIP_ANTORA_GENERATION" ]; then
export SKIP_ANTORA_GENERATION=true
export SKIP_CLEAR_CACHE=true
export SKIP_CLEAR_PREVIOUS=true
fi
if [ -z "$SKIP_STALE_EXAMPLE_CHECK" ]; then
export SKIP_STALE_EXAMPLE_CHECK=true
fi
if [ -z "$SKIP_SERVE" ]; then
export SKIP_SERVE=true
fi
fi
echo ""
echo "SKIP_EXAMPLES : $SKIP_EXAMPLES"
echo "SKIP_STALE_EXAMPLE_CHECK : $SKIP_STALE_EXAMPLE_CHECK"
echo "SKIP_PROJDOC_GENERATION : $SKIP_PROJDOC_GENERATION"
echo "SKIP_FIX_ADOC_LINE_ENDINGS : $SKIP_FIX_ADOC_LINE_ENDINGS"
echo "SKIP_CONFIGS : $SKIP_CONFIGS"
echo "SKIP_ANTORA_GENERATION : $SKIP_ANTORA_GENERATION"
echo "SKIP_SERVE : $SKIP_SERVE"
echo "SKIP_CLEAR_PREVIOUS (site) : $SKIP_CLEAR_PREVIOUS"
echo "SKIP_CLEAR_CACHE (template): $SKIP_SKIP_CLEAR_CACHE"
echo ""
if [[ "$SKIP_CLEAR_CACHE" == "true" ]]; then
echo "skipping clearing the Antora cache"
else
rm -rf $ANTORA_CACHE_DIR
fi
if [[ "$SKIP_CLEAR_PREVIOUS" == "true" ]]; then
echo "skipping clearing any previous build site"
else
rm -rf $ANTORA_TARGET_SITE
fi
if [ ! -f $PLAYBOOK_FILE ]; then
echo "no such file $PLAYBOOK_FILE" >&2
exit 1
fi
export ANTORA_CMD=antora
SECONDS=0
echo "\$PLAYBOOK_FILE = $PLAYBOOK_FILE"
sh build-site.sh $PLAYBOOK_FILE || exit 1
if [[ "$SKIP_SERVE" == "true" ]]; then
echo "skipping serving"
else
echo ""
echo "http://localhost:5000/docs/latest/about.html"
echo ""
serve -S -p 5000 $ANTORA_TARGET_SITE
fi