Check for tabs instead of spaces in the doc build

This adds a tool that checks style (currently just for tabs instead of
spaces in files under include/tests/docs) and produces a travis-ci build
failure if any problems are found.
This commit is contained in:
Jason Rhinelander 2016-08-28 13:00:44 -04:00
parent 8c41974630
commit ac4278970c
2 changed files with 23 additions and 2 deletions

View File

@ -38,9 +38,11 @@ matrix:
# Documentation build: # Documentation build:
- os: linux - os: linux
language: docs language: docs
env: DOCS env: DOCS STYLE
install: pip install sphinx sphinx_rtd_theme install: pip install sphinx sphinx_rtd_theme
script: make -C docs html SPHINX_OPTIONS=-W script:
- make -C docs html SPHINX_OPTIONS=-W
- tools/check-style.sh
cache: cache:
directories: directories:
- $HOME/.cache/pip - $HOME/.cache/pip

19
tools/check-style.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
#
# Script to check include/test code for common pybind11 code style errors.
# Currently just checks for tabs used instead of spaces.
#
# Invoke as: tools/check-style.sh
#
found=0
for f in `grep $'\t' include/ tests/ docs/*.rst -rl`; do
if [ "$found" -eq 0 ]; then
echo -e '\e[31m\e[01mError: found tabs instead of spaces in the following files:\e[0m'
found=1
fi
echo " $f"
done
exit $found