forked from arthurevans/doctools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·268 lines (237 loc) · 8.05 KB
/
deploy.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
DEBUG_TEMPLATE=template
PROD_TEMPLATE=template-min
VIDEO_LIST="videos.json"
PROCESSED_VIDEO_LIST="build/videos.json"
config="./jsduck.config"
guidesdir="./htmlguides"
outdir="./dist/platform/latest"
title="Appcelerator Platform - Appcelerator Docs"
progname=$0
usage() {
echo "Usage: $progname [options] [debug|prod]"
echo ""
echo " Options:"
echo " -c <config_file> (i.e., jsduck_21.config for 2.1 docs build)."
echo " -o <optional_project> (currently 'alloy' and 'modules' are supported)"
echo " -g <guides_dir> (defaults to htmlguides)."
echo " -a <addon_guides_dir> Specified add-on guides."
echo " -d <output_dir> (defaults to dist/titanium/3.0)."
echo " -s Enable --seo flag to jsduck."
echo " -t <title> Specify title for doc site."
echo ""
}
while getopts ":so:a:c:d:g:t:j:" opt; do
case $opt in
a)
if [ "$OPTARG" ]; then
addon_guidesdir=$OPTARG
fi
;;
c)
if [ "$OPTARG" ]; then
config=$OPTARG
fi
;;
d)
if [ "$OPTARG" ]; then
outdir=$OPTARG
fi
;;
o)
if [ $OPTARG == "alloy" ]; then
include_alloy="include_alloy"
elif [ $OPTARG = "arrow" ]; then
include_arrow="include_arrow"
elif [ $OPTARG = "modules" ]; then
include_modules="include_modules"
else
echo "Unknown optional project, $OPTARG">&2
usage
exit 1
fi
;;
g)
if [ "$OPTARG" ]; then
guidesdir=$OPTARG
fi
;;
s)
seo="--seo"
;;
t)
if [ "$OPTARG" ]; then
title="$OPTARG"
fi
;;
j)
jenkins="jenkins"
;;
\?)
echo "Invalid option: -$OPTARG">&2
usage
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
usage
exit 1
;;
esac
done
# Skip the options and move on to the positional parameters
shift $((OPTIND-1))
while [ "$1" ]; do
if [ "$1" == "prod" ]; then
production_build="production"
seo="--seo"
no_thumbnails=""
elif [ "$1" == "debug" ]; then
debug_build="debug"
fi
shift
done
if [ ! "$TI_DOCS" ]; then
if [ "$TI_ROOT" ]; then
TI_DOCS=${TI_ROOT}/titanium_mobile/apidoc
else
echo "No doc root \$TI_DOCS and \$TI_ROOT not defined. Exiting."
exit 1
fi
fi
if [ ! "$JSDUCK" ]; then
if [ "$TI_ROOT" ]; then
JSDUCK=${TI_ROOT}/jsduck
else
echo "No JSDuck dir \$JSDUCK and \$TI_ROOT not defined. Exiting."
exit 1
fi
fi
if [ ! "$DOCTOOLS" ]; then
if [ "$TI_ROOT" ]; then
DOCTOOLS=${TI_ROOT}/doctools
else
echo "No doctools dir \$DOCTOOLS and \$TI_ROOT not defined. Exiting."
exit 1
fi
fi
if [ ! "$ALLOY" ]; then
if [ "$TI_ROOT" ]; then
ALLOY=${TI_ROOT}/alloy
else
echo "No alloy dir \$ALLOY and \$TI_ROOT not defined. Exiting."
exit 1
fi
fi
if [ ! "$ARROW" ]; then
if [ "$TI_ROOT" ]; then
ARROW=${TI_ROOT}
else
echo "No arrow dir \$ARROW and \$TI_ROOT not defined. Exiting."
exit 1
fi
fi
if [ $include_alloy ]; then
alloyDirs="${ALLOY}/Alloy/lib ${ALLOY}/docs/apidoc ${DOCTOOLS}/add-ons
$(find $ALLOY/Alloy/builtins -maxdepth 1 -type f ! -name moment.js)"
fi
if [ $include_arrow ]; then
arrowDirs="${ARROW}/arrow-orm/apidoc
${ARROW}/arrow-orm/lib/collection.js
${ARROW}/arrow-orm/lib/connector.js
${ARROW}/arrow-orm/lib/error.js
${ARROW}/arrow-orm/lib/instance.js
${ARROW}/arrow-orm/lib/model.js
${ARROW}/arrow-orm/lib/connector/capabilities/index.js
${ARROW}/arrow/apidoc
${ARROW}/arrow/lib/engines
${ARROW}/arrow/lib/api.js
${ARROW}/arrow/lib/arrow.js
${ARROW}/arrow/lib/block.js
${ARROW}/arrow/lib/middleware.js
${ARROW}/arrow/lib/router.js"
fi
if [ $include_modules ]; then
if [ ! "$APPC_MODULES" ]; then
if [ "$TI_ROOT" ]; then
APPC_MODULES=${TI_ROOT}/appc_modules
else
echo "No appc_modules dir \$APPC_MODULES and \$TI_ROOT not defined. Exiting."
exit 1
fi
fi
module_dirs="$APPC_MODULES/ti.map/apidoc $APPC_MODULES/ti.facebook/apidoc
$APPC_MODULES/ti.nfc/apidoc $APPC_MODULES/ti.newsstand/apidoc $TIZEN_MODULE
$APPC_MODULES/ti.coremotion/apidoc $APPC_MODULES/ti.urlsession/apidoc
$APPC_MODULES/ti.touchid/apidoc"
module_dirs+=" $APPC_MODULES/ti.geofence/apidoc $APPC_MODULES/appcelerator.https/apidoc
$APPC_MODULES/com.appcelerator.apm/apidoc"
fi
if [ -d "$TI_ROOT/titanium_mobile_windows" ]; then
pushd $TI_ROOT/titanium_mobile_windows/apidoc
npm install .
node ti_win_yaml
## Workaround
rm Titanium/Map.yml
rm -r Titanium/Map
addon_win=" -a ${TI_ROOT}/titanium_mobile_windows/apidoc/WindowsOnly "
addon_win+=" -a ${TI_ROOT}/titanium_mobile_windows/apidoc/Titanium "
popd
fi
node ${TI_DOCS}/docgen.js -f jsduck -o ./build/ $module_dirs $addon_win
if [ $addon_guidesdir ]; then
python ./guides_merger.py --input "${guidesdir}/toc.xml" --addon "${addon_guidesdir}/toc.xml" --output "./build/merged_guides"
## Workaround for new Confluence plug-in
#cp -r $guidesdir/attachments_* ./build/merged_guides/.
#cp -r $guidesdir/images_* ./build/merged_guides/.
## Attachments
cp -r $guidesdir/attachments_* ./build/merged_guides/.
cp -r $addon_guidesdir/attachments_* ./build/merged_guides/.
## Images
cp -r $guidesdir/images ./build/merged_guides/.
cp -r $addon_guidesdir/images ./build/merged_guides/.
guidesdir="./build/merged_guides"
parseropts=""
else
parseropts="--show_edit_button"
fi
node guides_parser --input "${guidesdir}/toc.xml" --output "./build/guides" $parseropts
# Assume video list is pre-processed, with real thumbnails
cp $VIDEO_LIST $PROCESSED_VIDEO_LIST
# After updating video list, add thumbnails manually using the video_thumbs command:
# python ./video_thumbs.py --input $VIDEO_LIST --output $PROCESSED_VIDEO_LIST
if [ $production_build ] ; then
(cd ${JSDUCK}; rake compress)
TEMPLATE=${JSDUCK}/${PROD_TEMPLATE}
## Generate Solr content
echo "Generating Solr content for indexing..."
node $TI_DOCS/docgen -f solr -o ./build/ $module_dirs $addon_win
mkdir -p $outdir/../data/solr
cp ./build/api_solr.json $outdir/../data/solr/.
if [ $include_alloy ]; then
echo "Generating Solr content for Alloy..."
bash $DOCTOOLS/jsduck2json.sh alloy solr
cp ./dist/solr.json $outdir/../data/solr/alloy_api.json
fi
if [ $include_arrow ]; then
echo "Generating Solr content for Arrow..."/
bash $DOCTOOLS/jsduck2json.sh arrow solr
cp ./dist/solr.json $outdir/../data/solr/arrow_api.json
fi
else
compass compile ${JSDUCK}/template/resources/sass
TEMPLATE=${JSDUCK}/${DEBUG_TEMPLATE}
fi
ruby ${JSDUCK}/bin/jsduck --template ${TEMPLATE} $seo --output $outdir --title "$title" --config $config $alloyDirs $arrowDirs
# TIDOC-1327 Fix server errors
cp -r "$guidesdir/images/icons" "$outdir/resources/images/."
## Copy resources
## Workaround for new Confluence plugin
cp -r $guidesdir/attachments_* $outdir/.
#cp -r $guidesdir/images_* $outdir/.
cp -r $guidesdir/css/common.css "$outdir/resources/css/common.css"
cp -r $guidesdir/images "$outdir/images"
#cp -r $guidesdir/attachments "$outdir/attachments"
cp ./resources/mock_video.png $outdir/resources/images/mock_video.png
cp ./resources/codestrong_logo_short.png $outdir/resources/images/codestrong_logo_short.png
# Copy API images folder to $outdir
cp -r $TI_DOCS/images $outdir/.