Skip to content

Commit dc0ba05

Browse files
datapythonistajreback
authored andcommitted
DOC: Make sphinx fail the build when --warnings-are-errors is set (#24523)
1 parent b49136e commit dc0ba05

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

doc/make.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,12 @@ def _sphinx_build(self, kind):
124124
if self.num_jobs:
125125
cmd += ['-j', str(self.num_jobs)]
126126
if self.warnings_are_errors:
127-
cmd.append('-W')
127+
cmd += ['-W', '--keep-going']
128128
if self.verbosity:
129129
cmd.append('-{}'.format('v' * self.verbosity))
130130
cmd += ['-d', os.path.join(BUILD_PATH, 'doctrees'),
131131
SOURCE_PATH, os.path.join(BUILD_PATH, kind)]
132-
cmd = ['sphinx-build', SOURCE_PATH, os.path.join(BUILD_PATH, kind)]
133-
self._run_os(*cmd)
132+
return subprocess.call(cmd)
134133

135134
def _open_browser(self, single_doc_html):
136135
"""
@@ -144,13 +143,14 @@ def html(self):
144143
"""
145144
Build HTML documentation.
146145
"""
147-
self._sphinx_build('html')
146+
ret_code = self._sphinx_build('html')
148147
zip_fname = os.path.join(BUILD_PATH, 'html', 'pandas.zip')
149148
if os.path.exists(zip_fname):
150149
os.remove(zip_fname)
151150

152151
if self.single_doc_html is not None:
153152
self._open_browser(self.single_doc_html)
153+
return ret_code
154154

155155
def latex(self, force=False):
156156
"""
@@ -159,7 +159,7 @@ def latex(self, force=False):
159159
if sys.platform == 'win32':
160160
sys.stderr.write('latex build has not been tested on windows\n')
161161
else:
162-
self._sphinx_build('latex')
162+
ret_code = self._sphinx_build('latex')
163163
os.chdir(os.path.join(BUILD_PATH, 'latex'))
164164
if force:
165165
for i in range(3):
@@ -170,12 +170,13 @@ def latex(self, force=False):
170170
'"build/latex/pandas.pdf" for problems.')
171171
else:
172172
self._run_os('make')
173+
return ret_code
173174

174175
def latex_forced(self):
175176
"""
176177
Build PDF documentation with retries to find missing references.
177178
"""
178-
self.latex(force=True)
179+
return self.latex(force=True)
179180

180181
@staticmethod
181182
def clean():
@@ -257,7 +258,7 @@ def main():
257258

258259
builder = DocBuilder(args.num_jobs, not args.no_api, args.single,
259260
args.verbosity, args.warnings_are_errors)
260-
getattr(builder, args.command)()
261+
return getattr(builder, args.command)()
261262

262263

263264
if __name__ == '__main__':

doc/source/conf.py

+4
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,10 @@ def process_class_docstrings(app, what, name, obj, options, lines):
738738
# suppress this warning.
739739
'app.add_directive'
740740
]
741+
if pattern:
742+
# When building a single document we don't want to warn because references
743+
# to other documents are unknown, as it's expected
744+
suppress_warnings.append('ref.ref')
741745

742746

743747
def rstjinja(app, docname, source):

0 commit comments

Comments
 (0)