Following code makes Sphinx autosummary fail:
@dataclasses.dataclass
class Foo:
bar: int
class FooChild(Foo):
pass
My autosummary template (_templates/autosummary/class.rst
):
{{ name | escape | underline}}
.. currentmodule:: {{ module }}
.. autoclass:: {{ objname }}
:members:
{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Attributes') }}
.. autosummary::
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
When running sphinx-build -j 2 -W -b html docs docs/gh-pages
I get following warning:
Warning, treated as error:
~/path/docs/generated/module.FooChild.rst:14:autosummary:
failed to import FooChild.bar.
I need to treat warnings as errors because otherwise documentation in my project will quickly degrade, but I would like to either fix root cause of this one or ignore this specific warning.
I couldn't find any way to ignore a warning from source code comments, nor to selectively suppress warnings from Sphinx configuration. Please help!
EDIT:
here is what generated FooChild.rst
file looks like:
FooChild
========
.. currentmodule:: package.module
.. autoclass:: FooChild
:members:
.. rubric:: Attributes
.. autosummary::
~FooChild.bar
I have a conf.py
adding api.rst
to toctree, api.rst
is designed to trigger autosummary to create documentation for all modules and classes, in this example just module.py
.
API Overview
************
.. currentmodule:: package
.. autosummary::
:toctree: generated
:recursive:
module