test-documentation: Validate HTML with vnu.jar.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2019-04-22 15:46:04 -07:00
committed by Tim Abbott
parent 12e6189970
commit f407a12ba2
5 changed files with 45 additions and 21 deletions

View File

@@ -41,27 +41,35 @@ rm -rf _build
# The crawler would take a very long time to finish and TravisCI would fail as a result.
sphinx-build -j8 -b html -d _build/doctrees -D html_theme_options.collapse_navigation=True . _build/html
err=0
check() {
if "$@"; then
color_message 92 "Passed!"
else
color_message 91 "Failed!"
err=1
fi
}
color_message 94 "Validating HTML..."
check java -jar ../node_modules/vnu-jar/build/dist/vnu.jar \
--filterfile ../tools/documentation.vnufilter \
--skip-non-html \
_build/html
if [ -n "$skip_check_links" ]; then
color_message 94 "Skipped testing links in documentation."
exit 0
else
cd ../tools/documentation_crawler
if [ -n "$skip_external_links" ]; then
color_message 94 "Testing only internal links in documentation..."
check scrapy crawl_with_status documentation_crawler -a skip_external=set "${loglevel[@]}"
# calling crawl directly as parameter needs to be passed
else
color_message 94 "Testing links in documentation..."
check scrapy crawl_with_status documentation_crawler "${loglevel[@]}"
fi
fi
cd ../tools/documentation_crawler
set +e
if [ -n "$skip_external_links" ]; then
color_message 94 "Testing only internal links in documentation..."
scrapy crawl_with_status documentation_crawler -a skip_external=set "${loglevel[@]}"
# calling crawl directly as parameter needs to be passed
else
color_message 94 "Testing links in documentation..."
scrapy crawl_with_status documentation_crawler "${loglevel[@]}"
fi
result=$?
if [ "$result" -ne 0 ]; then
color_message 91 "Failed!"
exit 1
else
color_message 92 "Passed!"
exit 0
fi
exit "$err"