Skip to content

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

Open
@astrofrog

Description

@astrofrog

Bug report

Bug summary

sphinx-build has a -W option to turn warnings into errors. However, this doesn't seem to have any effect on warnings emitted inside plot directives.

Code for reproduction

To reproduce, create an empty directory then add a conf.py file with:

import matplotlib.sphinxext.plot_directive
extensions = [matplotlib.sphinxext.plot_directive.__name__]

and an index.rst file with:

.. plot::

    import warnings
    warnings.warn("A warning occurred")

Then run:

sphinx-build -b html -d _build/doctrees   . _build/html -W

The -W flag should turn warnings into errors, but this is not the case.

Actual outcome

Running Sphinx v2.3.0+
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
<string>:2: UserWarning: A warning occurred                                                                                                                                                                                                                                          

looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index                                                                                                                                                                                                                                                       
generating indices...  genindexdone
writing additional pages...  searchdone
copying static files... ... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded.

Expected outcome

The build should fail with an error.

Matplotlib version

  • Operating system: Ubuntu 19.10
  • Matplotlib version: 3.2.0rc1 (from pip)
  • Python version: 3.7.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Hardhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesGood first issueOpen a pull request against these issues if there are no active ones!topic: sphinx extension

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions