forked from ground-x/caver-js-ext-kas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yamlFormatting.sh
executable file
·99 lines (73 loc) · 2.21 KB
/
yamlFormatting.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
#!/bin/bash
cd src
cd rest-client
cd src
DIRS=`ls -d ./*/`
for i in ${DIRS};do
echo "Entering directory=${i}model";
cd ${i}model;
FILES=`ls`
for j in ${FILES};do
model=${j%".js"}
# echo $model
# Changed model name from exports to acutal
sed -i '' "s/ exports/ ${model}/g" $j
# Modified path
sed -i '' "s/'..\/ApiClient'/'..\/..\/ApiClient'/g" $j
sed -i '' "s/'ApiClient'/'..\/..\/ApiClient'/g" $j
sed -i '' "s/'model/'..\/model/g" $j
# Refined class name to simple version
sed -i '' "s/ model\// /g" $j
sed -i '' "s/module:model\///g" $j
# Add memberof tag to each methods and variables
cnt=$(grep -o 'memberof' $j | wc -l)
cmp=0
if [ ${cnt} -eq ${cmp} ]; then
sed -i '' '/return {'"$model"'}/ {a\
* @memberof '"$model"'
}' $j
sed -i '' '/member {/ {a\
* @memberof '"$model"'
}' $j
sed -i '' '/type {/ {a\
* @memberof '"$model"'
}' $j
fi
# Changed module to class
sed -i '' "s/@module/@class/g" $j
# Change tag from member to type for make it member variable
# If tag is @member with `AnchorBlockRequest.prototype.operator = undefined` format,
# jsDoc will generate docs with static variable.
members=$(grep -F '@member ' $j | rev | cut -d ' ' -f1 | rev)
for item in ${members};do
sed -i '' 's/} '"$item"'$/}/g' $j
done
sed -i '' "s/@member /@type /g" $j
# Format empty brace without newline
sed -i '' 'H;1h;$!d;x; s/{\n *}/{}/g' $j
done
cd ../../;
echo "Entering directory=${i}api";
cd ${i}api;
FILES=`ls`
for j in ${FILES};do
api=${j%".js"}
# echo $api
# Changed api name from exports to acutal
sed -i '' "s/ exports/ ${api}/g" $j
# Modified path
sed -i '' "s/'..\/ApiClient'/'..\/..\/ApiClient'/g" $j
sed -i '' "s/'ApiClient'/'..\/..\/ApiClient'/g" $j
sed -i '' "s/'model/'..\/model/g" $j
# Refined class name to simple version
sed -i '' "s/module:api\///g" $j
sed -i '' "s/module:model\///g" $j
sed -i '' "s/ api\// /g" $j
sed -i '' "s/module://g" $j
# Changed module to class
sed -i '' "s/@module/@class/g" $j
# Format empty brace without newline
sed -i '' 'H;1h;$!d;x; s/{\n *}/{}/g' $j
done
cd ../../;
done