mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
Generally stderr is the conventional place for this sort of running commentary, and it's better set up for it: by default stdout may have a buffer inside the process so that things written to it don't reach the outside until later, while stderr is always by default unbuffered, so messages are printed immediately. Here, until the previous commit, because our color-reset sequence was being printed without a following newline (with `echo -n`), it was getting buffered; and then error messages from `scrapy` to stderr were being erroneously painted with the color intended for the message "Testing links in documentation...".
42 lines
1.1 KiB
Bash
Executable File
42 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
color_message () {
|
|
local color_code="$1" message="$2"
|
|
echo -e "\e[${color_code}m${message}\e[0m" >&2
|
|
}
|
|
|
|
case $1 in
|
|
-h|--help)
|
|
echo "--help, -h show this help message and exit"
|
|
echo "--loglevel=LEVEL, -L LEVEL log level (default: ERROR)"
|
|
exit 0
|
|
;;
|
|
-L|--loglevel)
|
|
loglevel="$1 $2"
|
|
;;
|
|
esac
|
|
|
|
cd "$(dirname "$0")"/../docs
|
|
rm -rf _build
|
|
|
|
# collapse_navigation is set to False in conf.py to improve sidebar navigation for users.
|
|
# However, we must change its value to True before we begin testing links.
|
|
# Otherwise, sphinx would generate a large number of links we don't need to test.
|
|
# 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
|
|
|
|
color_message 94 "Testing links in documentation..."
|
|
|
|
cd ../tools/documentation_crawler
|
|
set +e
|
|
scrapy crawl_with_status documentation_crawler $loglevel
|
|
result=$?
|
|
if [ "$result" = 1 ]; then
|
|
color_message 91 "Failed!"
|
|
exit 1
|
|
else
|
|
color_message 92 "Passed!"
|
|
exit 0
|
|
fi
|