Skip to content

Commit

Permalink
fix: cleanup autoapi templates using macros (#556)
Browse files Browse the repository at this point in the history
Co-authored-by: pyansys-ci-bot <[email protected]>
Co-authored-by: Jorge Martínez <[email protected]>
Co-authored-by: Jorge Martinez <[email protected]>
  • Loading branch information
4 people authored Oct 23, 2024
1 parent 8871005 commit ff89444
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 67 deletions.
1 change: 1 addition & 0 deletions doc/changelog.d/556.miscellaneous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: cleanup autoapi templates using macros
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,39 @@
- {{ obj.summary }}
{% endfor %}
{%- endmacro %}
{# --------------------------- End macros definition ----------------------- #}

{# ------------------------ End macros definition for tab ------------------- #}

{# ----------------- Start macros definition for autosummary -----------------#}

{% macro render_autosummary_section(title, members) -%}

{{ title }}
{{ "-" * title | length }}

.. autoapisummary::

{% for member in members %}
{{ member.id }}
{% endfor %}

{%- endmacro %}
{# ------------------ End macros definition for autosummary --------------- #}

{# ----------------- Start macros definition for headers -----------------#}

{% macro render_members_section(title, members) -%}

{{ title }}
{{ "-" * title | length }}

{% for member in members %}
{{ member.render() }}
{% endfor %}

{%- endmacro %}
{# ------------------ End macros definition for headers --------------- #}


{% if is_own_page %}
:class:`{{ obj.name }}`
Expand Down Expand Up @@ -140,84 +172,40 @@ Import detail
from {{ joined_parts }} import {{ obj["short_name"] }}
{% if visible_properties %}
Property detail
---------------
{% for property in visible_properties %}
{{ property.render() }}
{% endfor %}
{{ render_members_section("Property detail", visible_properties) }}
{% endif %}


{% if visible_attributes %}
Attribute detail
----------------
{% for attribute in visible_attributes %}
{{ attribute.render() }}
{% endfor %}
{% if visible_attributes %}
{{ render_members_section("Attribute detail", visible_attributes) }}
{% endif %}


{% if all_visible_methods %}
Method detail
-------------
{% for method in all_visible_methods %}
{{ method.render() }}
{% endfor %}
{% if all_visible_methods %}
{{ render_members_section("Method detail", all_visible_methods) }}
{% endif %}

{% if is_own_page and own_page_children %}
{% set visible_attributes = own_page_children|selectattr("type", "equalto", "attribute")|list %}
{% if visible_attributes %}
Attributes
----------

.. autoapisummary::

{% for attribute in visible_attributes %}
{{ attribute.id }}
{% endfor %}


{% endif %}
{% set visible_exceptions = own_page_children|selectattr("type", "equalto", "exception")|list %}
{% if visible_exceptions %}
Exceptions
----------

.. autoapisummary::

{% for exception in visible_exceptions %}
{{ exception.id }}
{% endfor %}


{% endif %}
{% set visible_classes = own_page_children|selectattr("type", "equalto", "class")|list %}
{% if visible_classes %}
Classes
-------

.. autoapisummary::

{% for klass in visible_classes %}
{{ klass.id }}
{% endfor %}


{% endif %}
{% set visible_methods = own_page_children|selectattr("type", "equalto", "method")|list %}
{% if visible_methods %}
Methods
-------
{% if visible_attributes %}
{{ autosummary_section("Attributes", visible_attributes) }}
{% endif %}
{% set visible_exceptions = own_page_children|selectattr("type", "equalto", "exception")|list %}

.. autoapisummary::
{% if visible_exceptions %}
{{ autosummary_section("Exceptions", visible_exceptions) }}
{% endif %}
{% set visible_classes = own_page_children|selectattr("type", "equalto", "class")|list %}

{% for method in visible_methods %}
{{ method.id }}
{% endfor %}
{% if visible_classes %}
{{ autosummary_section("Classes", visible_classes) }}

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

{% endif %}
{% if visible_methods %}
{{ autosummary_section("Methods", visible_methods) }}
{% endif %}
{% endif %}

{# ---------------------- End class details -------------------- #}
{% endif %}
{% endif %}

0 comments on commit ff89444

Please sign in to comment.