-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompile.sh
63 lines (51 loc) · 1.92 KB
/
compile.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
#!/usr/bin/env bash
# https://mrbuds.github.io/wow-api-web/
# this script concatenate the 100+ .lua documentation in one big file and compile lua to js
# install moonshinejs : http://moonshinejs.org/
# need this directory : https://github.com/Gethe/wow-ui-source/tree/live/AddOns/Blizzard_APIDocumentation
# or beta branch : https://github.com/Gethe/wow-ui-source/tree/beta/AddOns/Blizzard_APIDocumentation
BLIZZDOC='Blizzard_APIDocumentation'
UPDATEDDOCPATH="../wow-ui-source/Interface/AddOns/${BLIZZDOC}"
TOCFILE="${BLIZZDOC}/${BLIZZDOC}.toc"
CONCATFILE="fulldoc.lua"
# clean files
if [ -e ${CONCATFILE} ]; then
echo ". delete old files"
rm ${CONCATFILE} *.luac api.lua.json ${BLIZZDOC}/*.lua ${BLIZZDOC}/*.luac ${BLIZZDOC}/*.json
fi
echo ". copy data from ${UPDATEDDOCPATH}"
cp ${UPDATEDDOCPATH}/* ${BLIZZDOC}/
# concatenate documentation
echo ". make ${CONCATFILE}"
cat "patch.lua" > "${CONCATFILE}"
go=false
cat "${TOCFILE}" | sed $'s/\r$//' | while read -r line || [[ -n "$line" ]]; do
if [ "${line:0:7}" = "# Start" ]; then
go=true
continue
fi
if [ "$go" = true ]; then
if [ ! "${line:0:1}" = '#' ]; then
file="${BLIZZDOC}/${line}"
if [ -e "$file" ]; then
echo ".. add file ${file}"
echo "" >> "${CONCATFILE}"
cat "$file" >> "${CONCATFILE}"
else
echo ".. can't find file: ${file}"
fi
fi
fi
done
cat "${CONCATFILE}" | tr '\n' '\f' | sed -r 's/BACKPACK\|PLAYER/BACKPACK_PLAYER/g' | sed -r 's/local \w+ =/APIDocumentation:AddDocumentationTable\(/g' | sed -r 's/\};/\}\);/g' | sed -r 's/\fAPIDocumentation:AddDocumentationTable\(\w+\);//g' | tr '\f' '\n' > fulldoc2.lua
echo ". compile Lua files to javascript"
moonshine distil api.lua
moonshine distil fulldoc2.lua
for file in ${BLIZZDOC}/*
do
mv $file ${file}.tmp
cat ${file}.tmp | sed -r 's/BACKPACK\|PLAYER/BACKPACK_PLAYER/g' > $file
rm ${file}.tmp
done
cd "${BLIZZDOC}"
moonshine distil *.lua