-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck_docs.sh
executable file
·98 lines (84 loc) · 2.41 KB
/
check_docs.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
#!/bin/bash
_usage()
{
echo "Check that the documentation is built without error and that automatically"
echo "generated files are committed."
echo
echo "'waf install' (parallel build) must have been run"
echo "just before. The waf script can be changed but it must point to a"
echo "parallel configuration."
echo "This script should be run in the same environment as 'waf install' was."
echo
echo "Usage: $(basename $0) [options]"
echo
echo "Options:"
echo
echo " --help (-h) Print this help information and exit."
echo " --waf script Define the script to be used (default: ./waf_mpi)."
echo " --use-debug Use the debug build (default: 'release' using 'waf_mpi')."
echo " --verbose (-v) Show commands output."
echo
exit "${1:-1}"
}
check_docs_main()
{
local waf=./waf_mpi
local variant="release"
local verbose=0
OPTS=$(getopt -o hv --long help,verbose,use-debug,waf: -n $(basename $0) -- "$@")
if [ $? != 0 ] ; then
_usage >&2
fi
eval set -- "$OPTS"
while true; do
case "$1" in
-h | --help ) _usage ;;
-v | --verbose ) verbose=1 ;;
--use-debug ) variant="debug" ;;
--waf ) waf="$2" ; shift ;;
-- ) shift; break ;;
* ) break ;;
esac
shift
done
if [ -d .git ]; then
getstatus="git status --porcelain"
elif [ -d .hg ]; then
getstatus="hg status -ardm"
fi
[ -z "${getstatus}" ] && echo "not a repository" && exit 1
# with waf_debug, doc and doc_debug are identical
local suffix=""
if [ ${variant} = "debug" ]; then
suffix="_debug"
fi
local log=$(mktemp)
echo -n "Checking docs... "
(
(
printf "\nGenerate html documentation...\n"
${waf} doc${suffix} --force-doc
return $?
)
iret=$?
[ ${iret} -ne 0 ] && return 1
if [ $(${getstatus} | wc -l) != 0 ]; then
printf "\nChanges must be committed:\n"
${getstatus}
return 1
fi
return 0
) >> ${log} 2>&1
ret=$?
test "${ret}" = "0" && ok=ok || ok=failed
echo ${ok}
if [ "${ok}" != "ok" ] || [ ${verbose} -eq 1 ]
then
printf "\nOutput+Error:\n"
cat ${log}
fi
rm -f ${log}
return ${ret}
}
check_docs_main "$@"
exit $?