Skip to content

Commit ef9fc19

Browse files
committed
Merge pull request #3770 from jenshnielsen/doc_w_as_error
DOC/BLD : Treat Sphinx warnings as errors when building docs on Travis
2 parents d7cc9eb + f0e03e0 commit ef9fc19

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ script:
4343
- if [[ $BUILD_DOCS == false ]]; then mkdir ../tmp_test_dir; fi
4444
- if [[ $BUILD_DOCS == false ]]; then cd ../tmp_test_dir; fi
4545
- if [[ $BUILD_DOCS == false ]]; then gdb -return-child-result -batch -ex r -ex bt --args python ../matplotlib/tests.py -sv --processes=8 --process-timeout=300 $TEST_ARGS; fi
46-
- if [[ $BUILD_DOCS == true ]]; then cd doc; python make.py html --small; fi
46+
- if [[ $BUILD_DOCS == true ]]; then cd doc; python make.py html --small --warningsaserrors; fi
4747
# We don't build the LaTeX docs here, so linkchecker will complain
4848
- if [[ $BUILD_DOCS == true ]]; then touch build/html/Matplotlib.pdf; fi
4949
- if [[ $BUILD_DOCS == true ]]; then linkchecker build/html/index.html; fi

doc/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
'sphinxext.github',
3535
'numpydoc']
3636

37-
exclude_patterns = ['api/api_changes/README.rst', 'users/whats_new/README.rst']
37+
exclude_patterns = ['api/api_changes/*', 'users/whats_new/*']
3838

3939
# Use IPython's console highlighting by default
4040
try:

doc/make.py

+24-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import shutil
77
import sys
88
import re
9-
9+
import argparse
1010

1111
def copy_if_out_of_date(original, derived):
1212
if (not os.path.exists(derived) or
@@ -43,6 +43,8 @@ def html(buildername='html'):
4343
options = "-D plot_formats=\"[('png', 80)]\""
4444
else:
4545
options = ''
46+
if warnings_as_errors:
47+
options = options + ' -W'
4648
if os.system('sphinx-build %s -b %s -d build/doctrees . build/%s' % (options, buildername, buildername)):
4749
raise SystemExit("Building HTML failed.")
4850

@@ -136,6 +138,7 @@ def all():
136138

137139

138140
small_docs = False
141+
warnings_as_errors = False
139142

140143
# Change directory to the one containing this file
141144
current_dir = os.getcwd()
@@ -174,17 +177,28 @@ def all():
174177
'as spurious changes in your \'git status\':\n\t{}'
175178
.format('\n\t'.join(symlink_warnings)))
176179

177-
if len(sys.argv)>1:
178-
if '--small' in sys.argv[1:]:
179-
small_docs = True
180-
sys.argv.remove('--small')
181-
for arg in sys.argv[1:]:
182-
func = funcd.get(arg)
180+
parser = argparse.ArgumentParser(description='Build matplotlib docs')
181+
parser.add_argument("cmd", help=("Command to execute. Can be multiple. "
182+
"Valid options are: %s" % (funcd.keys())), nargs='*')
183+
parser.add_argument("--small",
184+
help="Smaller docs with only low res png figures",
185+
action="store_true")
186+
parser.add_argument("--warningsaserrors",
187+
help="Turn Sphinx warnings into errors",
188+
action="store_true")
189+
args = parser.parse_args()
190+
if args.small:
191+
small_docs = True
192+
if args.warningsaserrors:
193+
warnings_as_errors = True
194+
195+
if args.cmd:
196+
for command in args.cmd:
197+
func = funcd.get(command)
183198
if func is None:
184-
raise SystemExit('Do not know how to handle %s; valid args are %s'%(
185-
arg, funcd.keys()))
199+
raise SystemExit(('Do not know how to handle %s; valid commands'
200+
' are %s' % (command, funcd.keys())))
186201
func()
187202
else:
188-
small_docs = False
189203
all()
190204
os.chdir(current_dir)

0 commit comments

Comments
 (0)