#!/usr/bin/env bash

set -e
set -x

echo "Installing dependencies"
pip install --user -r requirements.txt

echo "Building docs with Sphinx"
make -C docs html

echo "Checking grammar and style"
write-good `find ./docs -not \( -path ./docs/drafts -prune \) -name '*.rst'` --passive --so --no-illusion --thereIs --cliches

set +e
echo "Checking links"
make -C docs linkcheck

#!/usr/bin/env bash

html="make -C docs html"
linkcheck=$(make -C docs linkcheck | grep 'broken')
grammar="write-good `find ./docs -not \( -path ./docs/drafts -prune \) -name '*.rst'` --passive --so --no-illusion --thereIs --cliches"

if [[ $TRAVIS != "" ]]; then
   OUTPUT=$TRAVIS_BUILD_DIR/_build/linkcheck/output.txt
else
   OUTPUT=docs/_build/linkcheck/output.txt
fi

goodjob() {
  printf "%s\n" "$*" >&2

}

echo "Installing project dependencies"
pip install --user -r requirements.txt

set -e
set -x

echo "Building docs with Sphinx"
$html

echo "Checking grammar and style"
$grammar

[[ $grammar = "" ]] || goodjob "CONGRATULATIONS! You are a grammar wizard."

set +x
set +e
echo "Checking links"
if [[ $linkcheck == "" ]]; then
   echo "Linkcheck succeeded"
else
   echo "WARNING: linkcheck failed. Fix the following broken links:"
   grep 'broken' $OUTPUT
fi

Update docs test script; this will ensure broken links to packages that don't exist yet don't cause build failures
Update docs test script; this will ensure broken links to packages that don't exist yet don't cause build failures
