forked from riot/riot.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
import.sh
executable file
·42 lines (35 loc) · 1.12 KB
/
import.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
# store the riot submodules in an array
SUBMODULES=(route observable compiler)
# clone the riot submodules in a temporary folder
function _clone {
git clone [email protected]:riot/$1.git tmp/$1
}
# update the doc files merging the doc files from each single submodule
function _update {
tmp_file=api/$1-tmp.md
# take the header from the old api file
sed -n -e "1,/{% include api-tabs.html %}/w $tmp_file" api/$1.md
# print the doc/README.md of each submodule after the files headers
tail -n +2 tmp/$1/doc/README.md >> $tmp_file
# for the compiler api we just need to change
# the prefix of the methods(compiler.compile => riot.compile)
if [ $1 == 'compiler' ]
then
sed -i '' "s/$1\([(|.]\)/riot\1/g" $tmp_file
# prefix the submodule api methods using riot (observable => riot.observable)
else
if [ $1 == 'observable' ]
then
sed -i '' "s/$1\([(|.]\)/riot.$1\1/g" $tmp_file
fi
fi
# replace the old api file
mv $tmp_file api/$1.md
}
# loop all the submodules
for sumbodule in ${SUBMODULES[@]}; do
_clone ${sumbodule}
_update ${sumbodule}
done
# remove the temporary folder
rm -rf tmp