+function check_rst_doc() {
+ _src="$1"
+
+ if ! which doc8 > /dev/null ; then
+ echo "Error: 'doc8' not found. Exec 'sudo pip install doc8' first."
+ exit 1
+ fi
+ # Note: This check may fail in many jobs for building project docs, since
+ # the old sample has lines more than 120. We ignore failures on this
+ # check right now, but these have to be fixed before OPNFV B release.
+ _out=$(doc8 --max-line-length 120 "$_src") || {
+ _msg='Error: rst validatino (doc8) has failed, please fix the following error(s).'
+ _errs=$(echo "$_out" | sed -n -e "/^$_src/s/^/ /p")
+ echo
+ echo -e "$_msg\n$_errs"
+ echo
+ [[ -n "$GERRIT_COMMENT" ]] && echo -e "$_msg\n$_errs" >> "$GERRIT_COMMENT"
+ }
+}
+