python sphinx autosummary template, how to create single page module documentation

52 Views Asked by At

I am documenting modules that contain one class with same name as the module. With autosummary the module page contains a summary table of the class, and I have to click in the table to go into the sub-page for the class itself. I would like to reduce this extra level of nesting, documenting all module classes / attributes / methods / etc in one file for the module.

I modified the module template to add .. autoclass directive and loop over classes

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

And the class documentation shows up in the module page, but I don't get the summary table for the class methods. When I try to add the autosummary table for the class methods it seems the module template does not have access to the class methods


{% for item in classes %}
   {% if item.methods %}
   .. rubric:: {{ _('Methods') }}

   .. autosummary::
   {% for itemx in item.methods %}
      ~{{ name }}.{{ itemx }}
   {%- endfor %}
   {% endif %}
   {% endblock %}

   .. autoclass:: {{ item }}
{%- endfor %}

I was hoping item.methods would allow me to iterate over the classes methods to create the summary table for the class methods in the module page

0

There are 0 best solutions below