Skip to content

Commit

Permalink
[Merge] [#73] Revise ordering of "attributes" and "methods" sections …
Browse files Browse the repository at this point in the history
…in API reference
  • Loading branch information
nathan-hess authored May 5, 2023
2 parents 6a9dd32 + 374ac96 commit 6a9c751
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions docs/source/_templates/api_reference_class_template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,17 @@

.. autoclass:: {{ objname }}

{% block methods %}
{%- set attributes_non_inherited = [] %}
{%- set attributes_inherited = [] %}

{%- for item in attributes %}
{%- if item not in inherited_members %}
{{- attributes_non_inherited.append(item) or '' }}
{%- else %}
{{- attributes_inherited.append(item) or '' }}
{%- endif %}
{%- endfor %}


{%- set methods_non_inherited = [] %}
{%- set methods_inherited = [] %}
Expand All @@ -38,56 +48,42 @@
{%- endif %}
{%- endfor %}

{% if methods_non_inherited %}
.. rubric:: {{ _('Methods') }}

{% if attributes_non_inherited %}
.. rubric:: {{ _('Attributes') }}

.. autosummary::
{% for item in methods_non_inherited %}
{% for item in attributes_non_inherited %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}

{% if methods_inherited %}
.. rubric:: {{ _('Inherited Methods') }}

{% if methods_non_inherited %}
.. rubric:: {{ _('Methods') }}

.. autosummary::
{% for item in methods_inherited %}
{% for item in methods_non_inherited %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}

{% endblock %}


{% block attributes %}

{%- set attributes_non_inherited = [] %}
{%- set attributes_inherited = [] %}

{%- for item in attributes %}
{%- if item not in inherited_members %}
{{- attributes_non_inherited.append(item) or '' }}
{%- else %}
{{- attributes_inherited.append(item) or '' }}
{%- endif %}
{%- endfor %}

{% if attributes_non_inherited %}
.. rubric:: {{ _('Attributes') }}
{% if attributes_inherited %}
.. rubric:: {{ _('Inherited Attributes') }}

.. autosummary::
{% for item in attributes_non_inherited %}
{% for item in attributes_inherited %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}

{% if attributes_inherited %}
.. rubric:: {{ _('Inherited Attributes') }}

{% if methods_inherited %}
.. rubric:: {{ _('Inherited Methods') }}

.. autosummary::
{% for item in attributes_inherited %}
{% for item in methods_inherited %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}

{% endblock %}

0 comments on commit 6a9c751

Please sign in to comment.