mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #10110: sphinx-build: Emit builder-finished before shutdown
The error on the builder-finished event has been ignored for the calculation of the exit code. This emits the event earilier step to be calculated correctly.
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -16,6 +16,9 @@ Features added
|
|||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
* #10110: sphinx-build: exit code is not changed when error is raised on
|
||||||
|
builder-finished event
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|||||||
@@ -328,33 +328,7 @@ class Sphinx:
|
|||||||
self.builder.compile_update_catalogs()
|
self.builder.compile_update_catalogs()
|
||||||
self.builder.build_update()
|
self.builder.build_update()
|
||||||
|
|
||||||
if self._warncount and self.keep_going:
|
self.events.emit('build-finished', None)
|
||||||
self.statuscode = 1
|
|
||||||
|
|
||||||
status = (__('succeeded') if self.statuscode == 0
|
|
||||||
else __('finished with problems'))
|
|
||||||
if self._warncount:
|
|
||||||
if self.warningiserror:
|
|
||||||
if self._warncount == 1:
|
|
||||||
msg = __('build %s, %s warning (with warnings treated as errors).')
|
|
||||||
else:
|
|
||||||
msg = __('build %s, %s warnings (with warnings treated as errors).')
|
|
||||||
else:
|
|
||||||
if self._warncount == 1:
|
|
||||||
msg = __('build %s, %s warning.')
|
|
||||||
else:
|
|
||||||
msg = __('build %s, %s warnings.')
|
|
||||||
|
|
||||||
logger.info(bold(msg % (status, self._warncount)))
|
|
||||||
else:
|
|
||||||
logger.info(bold(__('build %s.') % status))
|
|
||||||
|
|
||||||
if self.statuscode == 0 and self.builder.epilog:
|
|
||||||
logger.info('')
|
|
||||||
logger.info(self.builder.epilog % {
|
|
||||||
'outdir': relpath(self.outdir),
|
|
||||||
'project': self.config.project
|
|
||||||
})
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
# delete the saved env to force a fresh build next time
|
# delete the saved env to force a fresh build next time
|
||||||
envfile = path.join(self.doctreedir, ENV_PICKLE_FILENAME)
|
envfile = path.join(self.doctreedir, ENV_PICKLE_FILENAME)
|
||||||
@@ -362,8 +336,35 @@ class Sphinx:
|
|||||||
os.unlink(envfile)
|
os.unlink(envfile)
|
||||||
self.events.emit('build-finished', err)
|
self.events.emit('build-finished', err)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
if self._warncount and self.keep_going:
|
||||||
|
self.statuscode = 1
|
||||||
|
|
||||||
|
status = (__('succeeded') if self.statuscode == 0
|
||||||
|
else __('finished with problems'))
|
||||||
|
if self._warncount:
|
||||||
|
if self.warningiserror:
|
||||||
|
if self._warncount == 1:
|
||||||
|
msg = __('build %s, %s warning (with warnings treated as errors).')
|
||||||
|
else:
|
||||||
|
msg = __('build %s, %s warnings (with warnings treated as errors).')
|
||||||
|
else:
|
||||||
|
if self._warncount == 1:
|
||||||
|
msg = __('build %s, %s warning.')
|
||||||
|
else:
|
||||||
|
msg = __('build %s, %s warnings.')
|
||||||
|
|
||||||
|
logger.info(bold(msg % (status, self._warncount)))
|
||||||
else:
|
else:
|
||||||
self.events.emit('build-finished', None)
|
logger.info(bold(__('build %s.') % status))
|
||||||
|
|
||||||
|
if self.statuscode == 0 and self.builder.epilog:
|
||||||
|
logger.info('')
|
||||||
|
logger.info(self.builder.epilog % {
|
||||||
|
'outdir': relpath(self.outdir),
|
||||||
|
'project': self.config.project
|
||||||
|
})
|
||||||
|
|
||||||
self.builder.cleanup()
|
self.builder.cleanup()
|
||||||
|
|
||||||
# ---- general extensibility interface -------------------------------------
|
# ---- general extensibility interface -------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user