Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ENH: make it possible to also specify abort_on_example_error in the sphinx_gallery_conf #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ New features
* Print aggregated and sorted list of computation times of all examples
in the console during the build.
* For examples that create multiple figures, set the thumbnail image.

* The ``abort_on_example_error`` option can now be specified in
``sphinx_gallery_conf`` (although the build option takes precedence over the
``sphinx_gallery_conf`` option).

v0.1.2
------
Expand Down
5 changes: 4 additions & 1 deletion doc/advanced_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ by including in your ``Makefile``::
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

Remember that for ``Makefile`` white space is significant and the indentation are tabs
and not spaces
and not spaces.

Alternatively, you can also instead add the ``abort_on_example_error`` option to
the ``sphinx_gallery_conf`` inside your ``conf.py`` configuration file.

.. _regular expressions: https://docs.python.org/2/library/re.html
21 changes: 18 additions & 3 deletions sphinx_gallery/gen_gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,19 @@ def generate_gallery_rst(app):

gallery_conf.update(app.config.sphinx_gallery_conf)
gallery_conf.update(plot_gallery=plot_gallery)
gallery_conf.update(
abort_on_example_error=app.builder.config.abort_on_example_error)

# If abort_on_example_error was specified in the sphinx_gallery_conf, we
# only override it if it was explicitly set in the build config. If it was
# not explicitly specified, it will be None, otherwise it will be
# True/False.
if app.builder.config.abort_on_example_error is None:
if 'abort_on_example_error' in gallery_conf:
pass # use the value from sphinx_gallery_conf
else:
gallery_conf['abort_on_example_error'] = False
else:
gallery_conf['abort_on_example_error'] = \
app.builder.config.abort_on_example_error

# this assures I can call the config in other places
app.config.sphinx_gallery_conf = gallery_conf
Expand Down Expand Up @@ -156,7 +167,11 @@ def touch_empty_backreferences(app, what, name, obj, options, lines):
def setup(app):
"""Setup sphinx-gallery sphinx extension"""
app.add_config_value('plot_gallery', True, 'html')
app.add_config_value('abort_on_example_error', False, 'html')

# We set the default abort_on_example_error to None here so that we can
# determine later if the option was explicitly set to False or True.
app.add_config_value('abort_on_example_error', None, 'html')

app.add_config_value('sphinx_gallery_conf', gallery_conf, 'html')
app.add_stylesheet('gallery.css')

Expand Down