Skip to content

Conversation

@Daniel53245
Copy link

@Daniel53245 Daniel53245 commented Jan 4, 2026

PR summary

closes #15715

As described in #15715, currently the warning in the ..plot is not correctly handled by the sphinx
By modifying file lib/matplotlib/sphinxext/plot_directive.py , I catch any warning generated during the code execution and log it through sphinx logs. When compiling the document, sphinx will fail on warning with the -W flag

(matplotlib_dev_env) PS D:\CodeProjects\matplot_lib_test_file> sphinx-build -E  -b html -d _build/doctrees   . _build/html -W    
Running Sphinx v9.1.0
loading translations [en]... done
building [mo]: targets for 0 po files that are out of date
writing output... 
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index
WARNING: [plot] Python warning during plot execution: A warning occurred (UserWarning)
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
copying assets... 
copying downloadable files... [100%] _build/plot_directive/index-1.py
copying static files... 
Writing evaluated template result to D:\CodeProjects\matplot_lib_test_file\_build\html\_static\basic.css
Writing evaluated template result to D:\CodeProjects\matplot_lib_test_file\_build\html\_static\documentation_options.js
Writing evaluated template result to D:\CodeProjects\matplot_lib_test_file\_build\html\_static\language_data.js
Writing evaluated template result to D:\CodeProjects\matplot_lib_test_file\_build\html\_static\alabaster.css
copying static files: done
copying extra files... 
copying extra files: done
copying assets: done
writing output... [100%] index
generating indices... genindex done
writing additional pages... search done
dumping search index in English (code: en)... done
dumping object inventory... done
build finished with problems, 1 warning (with warnings treated as errors).
(matplotlib_dev_env) PS D:\CodeProjects\matplot_lib_test_file> 

PR checklist

@Daniel53245 Daniel53245 marked this pull request as draft January 4, 2026 07:52
@Daniel53245 Daniel53245 marked this pull request as ready for review January 5, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warnings in plot directive aren't treated as such by Sphinx

1 participant