Skip to content

Commit ff89444

Browse files
Revathyvenugopal162pyansys-ci-botjorgepiloto
authored
fix: cleanup autoapi templates using macros (#556)
Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Jorge Martínez <[email protected]> Co-authored-by: Jorge Martinez <[email protected]>
1 parent 8871005 commit ff89444

File tree

2 files changed

+56
-67
lines changed

2 files changed

+56
-67
lines changed

doc/changelog.d/556.miscellaneous.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fix: cleanup autoapi templates using macros

src/ansys_sphinx_theme/theme/ansys_sphinx_theme/_templates/autoapi/python/class.rst

Lines changed: 55 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,39 @@
1414
- {{ obj.summary }}
1515
{% endfor %}
1616
{%- endmacro %}
17-
{# --------------------------- End macros definition ----------------------- #}
17+
18+
{# ------------------------ End macros definition for tab ------------------- #}
19+
20+
{# ----------------- Start macros definition for autosummary -----------------#}
21+
22+
{% macro render_autosummary_section(title, members) -%}
23+
24+
{{ title }}
25+
{{ "-" * title | length }}
26+
27+
.. autoapisummary::
28+
29+
{% for member in members %}
30+
{{ member.id }}
31+
{% endfor %}
32+
33+
{%- endmacro %}
34+
{# ------------------ End macros definition for autosummary --------------- #}
35+
36+
{# ----------------- Start macros definition for headers -----------------#}
37+
38+
{% macro render_members_section(title, members) -%}
39+
40+
{{ title }}
41+
{{ "-" * title | length }}
42+
43+
{% for member in members %}
44+
{{ member.render() }}
45+
{% endfor %}
46+
47+
{%- endmacro %}
48+
{# ------------------ End macros definition for headers --------------- #}
49+
1850

1951
{% if is_own_page %}
2052
:class:`{{ obj.name }}`
@@ -140,84 +172,40 @@ Import detail
140172
from {{ joined_parts }} import {{ obj["short_name"] }}
141173
142174
{% if visible_properties %}
143-
Property detail
144-
---------------
145-
{% for property in visible_properties %}
146-
{{ property.render() }}
147-
{% endfor %}
175+
{{ render_members_section("Property detail", visible_properties) }}
148176
{% endif %}
149177

150-
151-
{% if visible_attributes %}
152-
Attribute detail
153-
----------------
154-
{% for attribute in visible_attributes %}
155-
{{ attribute.render() }}
156-
{% endfor %}
178+
{% if visible_attributes %}
179+
{{ render_members_section("Attribute detail", visible_attributes) }}
157180
{% endif %}
158181

159-
160-
{% if all_visible_methods %}
161-
Method detail
162-
-------------
163-
{% for method in all_visible_methods %}
164-
{{ method.render() }}
165-
{% endfor %}
182+
{% if all_visible_methods %}
183+
{{ render_members_section("Method detail", all_visible_methods) }}
166184
{% endif %}
185+
167186
{% if is_own_page and own_page_children %}
168187
{% set visible_attributes = own_page_children|selectattr("type", "equalto", "attribute")|list %}
169-
{% if visible_attributes %}
170-
Attributes
171-
----------
172-
173-
.. autoapisummary::
174-
175-
{% for attribute in visible_attributes %}
176-
{{ attribute.id }}
177-
{% endfor %}
178-
179-
180-
{% endif %}
181-
{% set visible_exceptions = own_page_children|selectattr("type", "equalto", "exception")|list %}
182-
{% if visible_exceptions %}
183-
Exceptions
184-
----------
185-
186-
.. autoapisummary::
187-
188-
{% for exception in visible_exceptions %}
189-
{{ exception.id }}
190-
{% endfor %}
191-
192-
193-
{% endif %}
194-
{% set visible_classes = own_page_children|selectattr("type", "equalto", "class")|list %}
195-
{% if visible_classes %}
196-
Classes
197-
-------
198188

199-
.. autoapisummary::
200-
201-
{% for klass in visible_classes %}
202-
{{ klass.id }}
203-
{% endfor %}
204-
205-
206-
{% endif %}
207-
{% set visible_methods = own_page_children|selectattr("type", "equalto", "method")|list %}
208-
{% if visible_methods %}
209-
Methods
210-
-------
189+
{% if visible_attributes %}
190+
{{ autosummary_section("Attributes", visible_attributes) }}
191+
{% endif %}
192+
{% set visible_exceptions = own_page_children|selectattr("type", "equalto", "exception")|list %}
211193

212-
.. autoapisummary::
194+
{% if visible_exceptions %}
195+
{{ autosummary_section("Exceptions", visible_exceptions) }}
196+
{% endif %}
197+
{% set visible_classes = own_page_children|selectattr("type", "equalto", "class")|list %}
213198

214-
{% for method in visible_methods %}
215-
{{ method.id }}
216-
{% endfor %}
199+
{% if visible_classes %}
200+
{{ autosummary_section("Classes", visible_classes) }}
217201

202+
{% endif %}
203+
{% set visible_methods = own_page_children|selectattr("type", "equalto", "method")|list %}
218204

219-
{% endif %}
205+
{% if visible_methods %}
206+
{{ autosummary_section("Methods", visible_methods) }}
207+
{% endif %}
220208
{% endif %}
221209

222210
{# ---------------------- End class details -------------------- #}
223-
{% endif %}
211+
{% endif %}

0 commit comments

Comments
 (0)