Skip to content

Commit a275dfb

Browse files
committed
Add warnings to CLI
1 parent ae0f8ff commit a275dfb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

doc/make.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class DocBuilder:
7878
script.
7979
"""
8080
def __init__(self, num_jobs=1, include_api=True, single_doc=None,
81-
verbosity=0):
81+
verbosity=0, allow_warnings=False):
8282
self.num_jobs = num_jobs
8383
self.include_api = include_api
8484
self.verbosity = verbosity
@@ -87,6 +87,7 @@ def __init__(self, num_jobs=1, include_api=True, single_doc=None,
8787
if single_doc is not None:
8888
self._process_single_doc(single_doc)
8989
self.exclude_patterns = self._exclude_patterns
90+
self.allow_warnings = allow_warnings
9091

9192
self._generate_index()
9293
if self.single_doc_type == 'docstring':
@@ -233,10 +234,10 @@ def _sphinx_build(self, kind):
233234
if kind not in ('html', 'latex', 'spelling'):
234235
raise ValueError('kind must be html, latex or '
235236
'spelling, not {}'.format(kind))
236-
237237
self._run_os('sphinx-build',
238238
'-j{}'.format(self.num_jobs),
239239
'-b{}'.format(kind),
240+
'{}'.format("" if self.allow_warnings else "-W"),
240241
'-{}'.format(
241242
'v' * self.verbosity) if self.verbosity else '',
242243
'-d{}'.format(os.path.join(BUILD_PATH, 'doctrees')),
@@ -355,6 +356,10 @@ def main():
355356
argparser.add_argument('-v', action='count', dest='verbosity', default=0,
356357
help=('increase verbosity (can be repeated), '
357358
'passed to the sphinx build command'))
359+
argparser.add_argument("--allow-warnings",
360+
default=False,
361+
action="store_true",
362+
help="Whether to allow warnings in the build.")
358363
args = argparser.parse_args()
359364

360365
if args.command not in cmds:
@@ -374,7 +379,7 @@ def main():
374379
os.environ['MPLBACKEND'] = 'module://matplotlib.backends.backend_agg'
375380

376381
builder = DocBuilder(args.num_jobs, not args.no_api, args.single,
377-
args.verbosity)
382+
args.verbosity, args.allow_warnings)
378383
getattr(builder, args.command)()
379384

380385

0 commit comments

Comments
 (0)