-
Notifications
You must be signed in to change notification settings - Fork 5
/
doccCoverage.sh
70 lines (63 loc) · 1.96 KB
/
doccCoverage.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
# sh doccCoverage.sh all 获取全部文档覆盖率
# sh doccCoverage.sh 获取 public 文件 文档覆盖率
project_path='FTMobileSDK.xcodeproj/project.pbxproj'
copyFile="test.pbxproj"
changeFileAttributeToPublic(){
states='init'
lineNum=0
cat -n $project_path | while read line
do
lineNum=`expr $lineNum + 1`
if [[ $line =~ 'Begin PBXBuildFile section */' ]]
then
states='start'
echo $line
elif [[ $line =~ 'End PBXBuildFile section */' ]]
then
states='end'
echo $line
elif [[ $states = 'start' ]]
then
if [[ $line =~ '.h in Headers */' ]];then
if [[ $line =~ 'settings = {ATTRIBUTES = (Public,' ]];then
echo "已经是 Public 文件"
else
#brew install gnu-sed
sed -i "" "$lineNum s/\}\;/settings = \{ATTRIBUTES = \(Public, \)\; \}\; \}\;/" $project_path
fi
fi
fi
done
}
doccCoverage(){
echo '----- 正在清理 -----'
xcodebuild clean -quiet || exit
echo '清理完成 -->>> build'
xcodebuild -target FTMobileSDK DOCC_EXTRACT_SWIFT_INFO_FOR_OBJC_SYMBOLS=NO -quiet || exit
echo 'build completion -->>> docc'
xcrun docc convert FTMobileSDK/FTMobileSDKDocs.docc \
--fallback-display-name FTMobileSDK \
--fallback-bundle-identifier com.cloudcare.ft.mobile.sdk.FTMobileSDK \
--fallback-bundle-version 1.0 \
--additional-symbol-graph-dir ./build/FTMobileSDK.build/Release-iphoneos/FTMobileSDK.build/symbol-graph \
--experimental-documentation-coverage \
--level detailed
}
# 若为 all 则获取所有文件的注释覆盖率
FT_ALL_FILE_COVERAGE="$1"
echo "----- Start -----"
if [[ "$FT_ALL_FILE_COVERAGE" == "all" ]]; then
echo "-----changeFileAttributeToPublic Start-----"
changeFileAttributeToPublic
echo "-----changeFileAttributeToPublic End-----"
fi
#删除旧工程的影响
rm -rf App.xcodeproj
rm -rf App.xcworkspace
echo "-----Coverage Start-----"
doccCoverage
echo "-----Coverage End-----"
if [[ "$FT_ALL_FILE_COVERAGE" == "all" ]]; then
git checkout -- $project_path
echo "----- End -----"
fi