Skip to content

Commit

Permalink
Move methods into class pages for docs (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaucasau authored Oct 17, 2023
1 parent 82193dc commit c6de909
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
17 changes: 7 additions & 10 deletions docs/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{#
The general principle of this is that we manually document attributes here in
the same file, but give all methods their own page. By default, we document
The general principle of this is that we manually document methods and attributes here in
the same file. By default, we document
all methods, including those defined by parent classes.
-#}

Expand All @@ -15,20 +15,17 @@
#}
:no-members:
:show-inheritance:
:no-inherited-members:
:no-special-members:
{#
Methods all get their own separate page, with their names and the first lines
of their docstrings tabulated. The documentation from `__init__` is
automatically included in the standard class documentation, so we don't want
to repeat it.
The documentation from `__init__` is automatically included in the
standard class documentation, so we don't want to repeat it.
-#}
{% block methods_summary %}{% set wanted_methods = (methods | reject('==', '__init__') | list) %}{% if wanted_methods %}
.. rubric:: Methods

.. autosummary::
:nosignatures:
:toctree: ../stubs/
{% for item in wanted_methods %}
~{{ name }}.{{ item }}
.. automethod:: {{ name }}.{{ item }}
{%- endfor %}
{% endif %}{% endblock %}

Expand Down
12 changes: 4 additions & 8 deletions docs/_templates/autosummary/class_no_inherited_members.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@
#}
:no-members:
:show-inheritance:
{#
Methods all get their own separate page, with their names and the first lines
of their docstrings tabulated.
-#}
:no-inherited-members:
:no-special-members:

{% block methods_summary %}{% set wanted_methods = (methods | reject('in', inherited_members) | reject('==', '__init__') | list) %}{% if wanted_methods %}
.. rubric:: Methods Defined Here

.. autosummary::
:nosignatures:
:toctree: ../stubs/
{% for item in wanted_methods %}
~{{ name }}.{{ item }}
.. automethod:: {{ name }}.{{ item }}
{%- endfor %}
{% endif %}{% endblock %}

Expand Down

0 comments on commit c6de909

Please sign in to comment.