Skip to content

autosummary ignores __all__ for modules #2021

@carlos-jenkins

Description

@carlos-jenkins

I'm having an issue where in module.rst template I do the following:

{% for item in classes %}
.. autoclass:: {{ item }}
   :members:
{%- endfor %}

But some imported object are not being filtered out. I checked the implementation:

https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/autosummary/generate.py#L167

And this function is not considering the __all__ attribute for modules to determine the public objects.

The main issue is because I tried the following:

.. autosummary::
   :toctree: _reference
{% for item in classes %}
   {{ item }}
{%- endfor %}

To try to generate a recursive page for each class.

The problem is that the page gets generated, but the autosummary directive does check if the object is truly public (considering __all__, i think here) and thus it doesn't output that entry to the toctree, causing a build error when running with -W because the generated *.rst file doesn't belong to any toctree.

Regards.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions