forked from intohole/moodstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract.sh
41 lines (36 loc) · 1 KB
/
extract.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
#!/bin/sh
FUNCTION_FILE="README.md"
PROJECT_NAME="moodstyle"
echo > ${FUNCTION_FILE}
echo "moodstyle机器学习脚本库" >> ${FUNCTION_FILE}
echo "=======================" >> ${FUNCTION_FILE}
echo "" >> ${FUNCTION_FILE}
echo "" >> ${FUNCTION_FILE}
echo "" >> ${FUNCTION_FILE}
echo "" >> ${FUNCTION_FILE}
cd `dirname $0`
CWD=`pwd`
for function_file in `ls ${CWD}/${PROJECT_NAME}/*.py`;do
echo "+ `basename ${function_file}`" >> ${FUNCTION_FILE}
cat ${function_file} |
grep -En "(^class|^\s*def )" |
# grep -v "__" |
# grep -v "def _" |
sed 's/class / + /' |
sed 's/def / + /' |
sed 's/:$//' |
sed 's/\]/\\]/g' |
sed 's/\[/\\[/g' |
awk -F ":" '{
line_number = $1;
function_name = ""
for(i = 2 ;i <=NF ;i++){
if(i != 2){
function_name=function_name":"$i
}else{
function_name =$i
}
}
print function_name"]('${PROJECT_NAME}'/'`basename ${function_file}`'#L"line_number")"
}' | sed 's/+ /+ [/'>> ${FUNCTION_FILE}
done