Skip to content

[Bug]: plot_directive does not raise warning or error when the code it runs fails #30899

@kratsg

Description

@kratsg

Bug summary

When the plot directive is used on code that fails, plot directive silently accepts it (no figure is produced) by proceeding like nothing went wrong.

Code for reproduction

The following


1D Regular Binning
^^^^^^^^^^^^^^^^^^

.. plot::
   :include-source:

   raise RuntimeWarning('I will break')

Actual outcome

Image

Expected outcome

I expect to see a warning or error when building the docs via sphinx

$ python -m sphinx ./ ./_build --fail-on-warning -T
Running Sphinx v8.2.3
loading translations [en]... done
Converting `source_suffix = ['.rst', '.md']` to `source_suffix = {'.rst': 'restructuredtext', '.md': 'restructuredtext'}`.
loading pickled environment... checking bibtex cache... up to date
The configuration has changed (3 options: 'html_css_files', 'html_static_path', 'pygments_dark_style')
done
myst v4.0.1: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions={'colon_fence'}, disable_syntax=[], all_links_external=False, links_external_new_tab=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=0, heading_slug_func=None, html_meta={}, footnote_sort=True, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True)
[autosummary] generating autosummary for: CODE_OF_CONDUCT.md, CONTRIBUTING.md, _generated/pyhs3.Model.rst, _generated/pyhs3.Workspace.rst, _generated/pyhs3.analyses.Analyses.rst, _generated/pyhs3.analyses.Analysis.rst, _generated/pyhs3.analyses.rst, _generated/pyhs3.base.Evaluable.rst, _generated/pyhs3.data.Axis.rst, _generated/pyhs3.data.BinnedData.rst, ..., broadcasting.rst, defining_components.rst, development.rst, index.rst, model.rst, structure.rst, talks.rst, testing.rst, visualization.rst, workspace.rst

Additional information

matplotlib                    3.10.3
matplotlib-inline             0.1.7
Sphinx                        8.2.3

Operating system

OS/X [Sonoma, 14.7.6 (23H626)]

Matplotlib Version

3.10.3

Matplotlib Backend

Agg

Python version

Python 3.13.0

Jupyter version

n/a

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions