Reputation: 93
I am using sphinx for documentation. and have used the make html and make latexpdf through a bash script. when running the bash script, and when make html is run, it shows ERROR in teh rst file after the Reading sources.
make clean
+ make clean
rm -rf _build/*
make html
+ make html
sphinx-build -b html -d _build/doctrees . _build/html
Running Sphinx v1.3b3
making output directory...
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 2 source files that are out of date
updating environment: 2 added, 0 changed, 0 removed
reading sources... [100%] index
/home/sphinx/Inder.rst:12:WARNING: Bullet list ends without a blank line; unexpected unindent.
/home/sphinx/Inder.rst:12: ERROR: Document may not end with a transition.
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
How can i catch this error in the bash script or send it to another variable. i have tried grep ERROR with the make html, but it gives blank.
Upvotes: 1
Views: 640
Reputation: 8617
sphinx-build
will probably print output on both stdout and stderr so you likely want to capture both streams.
You can do this like:
out=$(make html 2>&1)
if grep -q 'ERROR: ' <<< "$out"; then
# do some error handling
fi
Upvotes: 0