Sphinx autosummary of class attributes not included in the proper toctree with numpydoc?

159 Views Asked by At

My class.rst:

{% extends "!autosummary/class.rst" %}

{% block methods %}
{% if methods %}

.. HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages.
   .. autosummary::
      :toctree:
      {% for item in all_methods %}
         {%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
         {{ name }}.{{ item }}
         {%- endif -%}
      {%- endfor %}
      {% for item in inherited_members %}
         {%- if item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
         {{ name }}.{{ item }}
      {%- endif -%}
      {%- endfor %}

{% endif %}
{% endblock %}

{% block attributes %}
{% if attributes %}

.. HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages.
   .. autosummary::
      :toctree:
      {% for item in all_attributes %}
         {%- if not item.startswith('_') %}
         {{ name }}.{{ item }}
         {%- endif -%}
      {%- endfor %}

{% endif %}
{% endblock %}

In the main source file:

.. autosummary::
   :nosignatures:
   :toctree: generated/

   ExperimentalValueArray

And my function docstring:

"""An array of values with uncertainties

    Attributes
    ----------

    values : ndarray
    errors : ndarray
    relative_errors : ndarray
    name : str
    unit : str

    Methods
    -------

    append
    insert
    extend
    delete

"""

Here, the attributes are all defined as functions with the @property decorator. When I generate the docs like this, the toctree only contains the methods, but not the attributes.

enter image description here

When each method is properly nested under the class description:

enter image description here

The attribute pages are all dangling on their own:

enter image description here

Any idea how to fix this?

0

There are 0 best solutions below