From 394ce55bcda74c7adb48d6e29f096f11e909be82 Mon Sep 17 00:00:00 2001 From: Arnau Casau Date: Fri, 20 Oct 2023 18:23:23 +0200 Subject: [PATCH] Move methods into class pages for docs --- docs/_templates/autosummary/class.rst | 33 +++++---------- .../class_no_inherited_members.rst | 40 +++++++++++++++++++ 2 files changed, 50 insertions(+), 23 deletions(-) create mode 100644 docs/_templates/autosummary/class_no_inherited_members.rst diff --git a/docs/_templates/autosummary/class.rst b/docs/_templates/autosummary/class.rst index e4d661a00..89d0fab3c 100644 --- a/docs/_templates/autosummary/class.rst +++ b/docs/_templates/autosummary/class.rst @@ -12,38 +12,25 @@ :no-inherited-members: :no-special-members: - {% block attributes_summary %} +{% block attributes_summary %} {% if attributes %} - .. rubric:: Attributes - - .. autosummary:: - :toctree: ../stubs/ - {% for item in all_attributes %} - {%- if not item.startswith('_') %} - {{ name }}.{{ item }} - {%- endif -%} - {%- endfor %} + {% for item in all_attributes %} + {%- if not item.startswith('_') %} + .. autoattribute:: {{ name }}.{{ item }} + {%- endif -%} + {%- endfor %} {% endif %} - {% endblock %} +{% endblock %} - {% block methods_summary %} +{% block methods_summary %} {% if methods %} - .. rubric:: Methods - - .. autosummary:: - :toctree: ../stubs/ {% 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 }} + .. automethod:: {{ name }}.{{ item }} {%- endif -%} {%- endfor %} {% endif %} - {% endblock %} +{% endblock %} \ No newline at end of file diff --git a/docs/_templates/autosummary/class_no_inherited_members.rst b/docs/_templates/autosummary/class_no_inherited_members.rst new file mode 100644 index 000000000..95b66da08 --- /dev/null +++ b/docs/_templates/autosummary/class_no_inherited_members.rst @@ -0,0 +1,40 @@ +{# 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 %} + {% if attributes %} + .. rubric:: Attributes + {% for item in all_attributes %} + {%- if not item.startswith('_') %} + .. autoattribute:: {{ name }}.{{ item }} + {%- endif -%} + {%- endfor %} + {% endif %} +{% endblock %} + +{% block methods_summary %} + {% if methods %} + .. rubric:: Methods + {% for item in all_methods %} + {%- if item not in inherited_members %} + {%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %} + .. automethod:: {{ name }}.{{ item }} + {%- endif -%} + {%- endif -%} + {%- endfor %} + + {% endif %} +{% endblock %} \ No newline at end of file