Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move methods into class pages for docs #1290

Merged
merged 10 commits into from
Nov 6, 2023
10 changes: 3 additions & 7 deletions docs/_templates/autosummary/analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

.. rubric:: Attributes

.. autosummary::
:toctree: ../stubs/
{% for item in all_attributes %}
{%- if not item.startswith('_') %}
{{ name }}.{{ item }}
.. autoattribute:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% endif %}
Expand All @@ -32,16 +30,14 @@

.. rubric:: Methods

.. autosummary::
:toctree: ../stubs/
{% for item in all_methods %}
{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{{ name }}.{{ item }}
.. automethod:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% for item in inherited_members %}
{%- if item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{{ name }}.{{ item }}
.. automethod:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}

Expand Down
61 changes: 20 additions & 41 deletions docs/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,37 @@
:no-inherited-members:
:no-special-members:

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

{# This counter lets us only render the heading if there's at least
one valid entry. #}
{% set count = namespace(value=0) %}
{% set wanted_attributes = [] %}
{% for item in attributes%}
{%- if not item.startswith('_') %}
{% set _ = wanted_attributes.append(item)%}
{%- endif -%}
{%- endfor %}

{% for item in attributes %}
{% if not item.startswith('_') %}
{% set count.value = count.value + 1 %}
{% if count.value == 1 %}
{% if wanted_attributes %}
.. rubric:: Attributes

.. autosummary::
:toctree: ../stubs/
{% endif %}

{{ name }}.{{ item }}
{% endif %}
{% endfor %}
{% for item in wanted_attributes %}
.. autoattribute:: {{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% endblock %}

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

{% set count = namespace(value=0) %}
{% set wanted_methods = [] %}
{% for item in all_methods %}

{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{% set count.value = count.value + 1 %}
{% if count.value == 1 %}
.. rubric:: Methods

.. autosummary::
:toctree: ../stubs/
{% endif %}
{{ name }}.{{ item }}
{% set _ = wanted_methods.append(item)%}
{%- endif -%}
{%- endfor %}
{% for item in inherited_members %}
{%- if item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{% set count.value = count.value + 1 %}
{% if count.value == 1 %}
.. rubric:: Methods

.. autosummary::
:toctree: ../stubs/
{% endif %}
{{ name }}.{{ item }}
{%- endif -%}
{% if wanted_methods%}
.. rubric:: Methods
{% for item in wanted_methods %}
.. automethod:: {{ name }}.{{ item }}
{%- endfor %}

{% endif %}
{% endblock %}
{% endblock %}
52 changes: 52 additions & 0 deletions docs/_templates/autosummary/class_no_inherited_members.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{# This is identical to class.rst, except for the filtering of the inherited_members. -#}

{% if referencefile %}
.. include:: {{ referencefile }}
{% endif %}

{{ objname }}
{{ underline }}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:no-members:
:no-inherited-members:
:no-special-members:

{% block attributes_summary %}

{% set wanted_attributes = [] %}
{% for item in attributes%}
{%- if not item.startswith('_') %}
{% set _ = wanted_attributes.append(item)%}
{%- endif -%}
{%- endfor %}

{% if wanted_attributes%}
.. rubric:: Attributes
{% for item in wanted_attributes %}
.. autoattribute:: {{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block methods_summary %}

{% set wanted_methods = [] %}
{% for item in all_methods %}
{%- if item not in inherited_members %}
{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{% set _ = wanted_methods.append(item)%}
{%- endif -%}
{%- endif -%}
{%- endfor %}

{% if wanted_methods %}
.. rubric:: Methods
{% for item in wanted_methods %}
.. automethod:: {{ name }}.{{ item }}
{%- endfor %}

{% endif %}
{% endblock %}
10 changes: 3 additions & 7 deletions docs/_templates/autosummary/drawer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

.. rubric:: Attributes

.. autosummary::
:toctree: ../stubs/
{% for item in all_attributes %}
{%- if not item.startswith('_') %}
{{ name }}.{{ item }}
.. autoattribute:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% endif %}
Expand All @@ -32,16 +30,14 @@

.. rubric:: Methods

.. autosummary::
:toctree: ../stubs/
{% for item in all_methods %}
{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{{ name }}.{{ item }}
.. automethod:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% for item in inherited_members %}
{%- if item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{{ name }}.{{ item }}
.. automethod:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}

Expand Down
10 changes: 3 additions & 7 deletions docs/_templates/autosummary/experiment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

.. rubric:: Attributes

.. autosummary::
:toctree: ../stubs/
{% for item in all_attributes %}
{%- if not item.startswith('_') %}
{{ name }}.{{ item }}
.. autoattribute:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% endif %}
Expand All @@ -32,16 +30,14 @@

.. rubric:: Methods

.. autosummary::
:toctree: ../stubs/
{% for item in all_methods %}
{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{{ name }}.{{ item }}
.. automethod:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% for item in inherited_members %}
{%- if item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{{ name }}.{{ item }}
.. automethod:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}

Expand Down
11 changes: 3 additions & 8 deletions docs/_templates/autosummary/plotter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

.. rubric:: Attributes

.. autosummary::
:toctree: ../stubs/
{% for item in all_attributes %}
{%- if not item.startswith('_') %}
{{ name }}.{{ item }}
.. autoattribute:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% endif %}
Expand All @@ -32,17 +30,14 @@

.. rubric:: Methods

.. autosummary::
:toctree: ../stubs/

{% for item in all_methods %}
{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{{ name }}.{{ item }}
.. automethod:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% for item in inherited_members %}
{%- if item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{{ name }}.{{ item }}
.. automethod:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}

Expand Down