-
Notifications
You must be signed in to change notification settings - Fork 3
/
generateDoc.sh
executable file
·113 lines (94 loc) · 2.6 KB
/
generateDoc.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env bash
oldstate="$(set +o)"
set -euo pipefail
date
source ./scripts/loadWritingFunction.sh
# Validation mode: git or approvals
# With approvals: file .approved is compared to .received (no need to have git). It not verifies removed tests
# with git: file .approved is compared with git commited version. It detects tests removed.
ROOT_PATH=$(pwd)
OUTPUT_PATH=$ROOT_PATH/tmp
OUTPUT_LOG=$OUTPUT_PATH/generateDoc.log
GLOBAL_EXIT_VALUE=0
OPTIONS=""
# Usage info
function show_help() {
echo "Usage: ${0##*/} [-h] [-t] [FILE]..."
echo "Build all the project: compile, generate documentation, verify there is no regression"
echo "and convert asciidoctor generated to Html."
echo ""
echo " -h display this help and exit."
echo " -t only tests."
}
while getopts ":ht" opt; do
case ${opt} in
h ) show_help
exit 0
;;
t ) OPTIONS="$OPTIONS -t"
;;
\? ) show_help
exit 0
;;
esac
done
shift $((OPTIND-1))
function restore_shell_options() {
set +u
HISTIGNORE_BACKUP="$HISTIGNORE"
set -u
HISTIGNORE='set [\+\-]o *'
eval "$oldstate"
HISTIGNORE="$HISTIGNORE_BACKUP"
}
function generate_docs() {
ALL_DEMOS=$1
ALL_RESULTS=""
ALL_STATUS_RESULT="${GREEN}OK${NO_COLOR}"
local TEST_COLOR
echo "Generate projects documentation..."
rm -f "$OUTPUT_LOG"
mkdir -p "$OUTPUT_PATH"
for DEMO_NAME in $ALL_DEMOS
do
echo -n "Project ${DEMO_NAME}: "
echo "---------------------" >> "$OUTPUT_LOG"
echo "Project ${DEMO_NAME} ${OPTIONS}" >> "$OUTPUT_LOG"
pushd $DEMO_NAME > /dev/null
returncode=0
./generateDoc.sh $OPTIONS >> "$OUTPUT_LOG" 2>&1 || returncode=$?
if [[ returncode -eq 0 ]]
then
DEMO_STATUS="OK"
TEST_COLOR=${GREEN}
else
ALL_STATUS_RESULT="${RED}FAILED${NO_COLOR}"
DEMO_STATUS="FAILED"
GLOBAL_EXIT_VALUE=1
TEST_COLOR=${RED}
cat $OUTPUT_LOG
fi
echo -e "${TEST_COLOR}${DEMO_STATUS}${NO_COLOR}"
ALL_RESULTS="$ALL_RESULTS${TEST_COLOR}- ${DEMO_NAME}: ${DEMO_STATUS}${NO_COLOR}\n"
popd > /dev/null
done
echo ---------------------
echo Results:
echo ---------------------
echo -e "$ALL_RESULTS"
echo ---------------------
echo -e "$ALL_STATUS_RESULT"
echo ---------------------
}
set +u
if [ -z "$1" ]
then
MODULES="documentationtesting samples/samples_tools $(find samples -maxdepth 1 -name "demo_*") $(find samples -maxdepth 1 -name "tech_*") documentationtestingdoc"
else
MODULES="$1"
fi
set -u
generate_docs "$MODULES"
restore_shell_options
date
exit $GLOBAL_EXIT_VALUE