Skip to content

Make plot directive errors fail Sphinx builds#31863

Open
chidoziemanagwu wants to merge 1 commit into
matplotlib:mainfrom
chidoziemanagwu:fix-sphinx-plot-error-reporting
Open

Make plot directive errors fail Sphinx builds#31863
chidoziemanagwu wants to merge 1 commit into
matplotlib:mainfrom
chidoziemanagwu:fix-sphinx-plot-error-reporting

Conversation

@chidoziemanagwu

Copy link
Copy Markdown

PR summary

Plot execution exceptions are currently converted into Docutils system messages,
so Sphinx does not treat them as warnings and sphinx-build -W can still exit
successfully.

Log PlotError exceptions through Sphinx while preserving the existing Docutils
system message. This makes warning-as-error builds fail when a plot directive
raises an exception.

Add a regression test that builds a page containing a failing plot directive and
checks that the Sphinx build exits unsuccessfully with the exception details.

closes #30899

AI Disclosure

OpenAI Codex was used to analyze the issue, implement the change, and draft the
regression test and pull request description. The resulting changes were reviewed
and validated with the available local checks.

PR checklist

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process.

You can also join us on discourse chat for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide.
Please let us know if (and how) you use AI, it will help us give you better feedback on your PR.

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@timhoffm

timhoffm commented Jun 9, 2026

Copy link
Copy Markdown
Member

CI errors are unrelated and fixed through #31865.

@timhoffm timhoffm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. If possible, please rebase to pick up #31865 and fix the CI failure.


def build_sphinx_html(source_dir, doctree_dir, html_dir, extra_args=None):
# Build the pages with warnings turned into errors
def run_sphinx_html(source_dir, doctree_dir, html_dir, extra_args=None):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not create a new function for this. Instead, expand build_sphinx_html to cover both cases.

  • Add an expected_returncode=0 parameter
  • Return the proc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

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

2 participants