2021-02-02 07:55:36 -05:00
#!/bin/bash
#
# Post-build checks on HTML go here.
2022-04-28 12:11:49 -04:00
if [ -z ${ 1 +x } ] ; then echo "Usage: ./htmlChecks.sh <htmlPath>" && exit 0; fi
htmlPath = $1
2021-02-02 07:55:36 -05:00
RED = '\033[0;31m'
NC = '\033[0m' # No Color
2022-04-28 12:11:49 -04:00
cd ${ htmlPath } || { echo " Can't change to ${ htmlPath } " && exit 0; }
2021-02-02 07:55:36 -05:00
echo "Checking for \"grey bar\" formatting errors in output ..."
GREY_FILES = ( $( grep -rl --include= "*.html" "blockquote" .) )
if [ ${# GREY_FILES [@] } != 0 ] ; then
2021-06-18 14:04:34 -04:00
echo " Found ${# GREY_FILES [@] } HTML file(s) with greybar formatting issues: "
2021-02-02 07:55:36 -05:00
for FILE in ${ GREY_FILES [@] } ;
do
echo -e " ${ RED } $FILE ${ NC } "
done
2021-06-18 14:04:34 -04:00
echo "Using a browser, locate vertical grey bars in the left margin of the above file(s), then correct the issue(s) in the corresponding rST file(s)."
error = 1
2021-02-02 07:55:36 -05:00
fi
2021-06-18 14:04:34 -04:00
echo "Checking for \".. include::\" errors in output ..."
2022-04-28 12:11:49 -04:00
INCLUDE_FILES = ( $( grep -rl --include= "*.html" -e "start-after" -e "end-before" .) )
2021-06-18 14:04:34 -04:00
if [ ${# INCLUDE_FILES [@] } != 0 ] ; then
echo " Found ${# INCLUDE_FILES [@] } HTML file(s) with exposed \"start-after\" and \"end-before\" _include argument(s): "
for FILE in ${ INCLUDE_FILES [@] } ;
do
echo -e " ${ RED } $FILE ${ NC } "
done
echo "Correct the issue(s) in the corresponding rST file(s)."
error = 1
fi
2021-07-07 07:05:21 -04:00
echo "Checking for unexpanded substitution errors in output ..."
2022-04-28 12:11:49 -04:00
SUBS_FILES = ( $( grep -rlo --include= "*.html" --exclude= "doc_contribute_guide.html" '[>\s]|\S\+|[<\s]' .) )
if [ ${# SUBS_FILES [@] } != 0 ] ; then
echo -e " Found ${# SUBS_FILES [@] } HTML file(s) that may have unexpanded substitution(s):\n ${ RED } "
2022-04-27 12:55:24 -04:00
grep -ro --include= "*.html" --exclude= "doc_contribute_guide.html" '[>\s]|\S\+|[<\s]' . | awk -F: '{if(f!=$1)print ""; f=$1; print $0;}'
2022-04-28 12:11:49 -04:00
echo -e " ${ NC } \nCorrect the issue(s) in the corresponding rST file(s).\nHINT: Substitions are not allowed in code blocks, :ref:s,\n:doc:s, or with in rST markup such as **, \`\`, and so on. "
2021-07-07 07:05:21 -04:00
error = 1
fi
2021-06-18 14:04:34 -04:00
# Set -W to halt tox
2022-04-28 12:11:49 -04:00
if [ [ $2 = = "-W" ] ] && [ [ ${ error } -eq 1 ] ] ; then
2021-06-18 14:04:34 -04:00
exit 1
elif [ [ ${ error } -ne 1 ] ] ; then
echo "... OK"
fi