Skip to content

Commit

Permalink
fix: update templates for sphinx-autoapi==3.1.0a4 (#347)
Browse files Browse the repository at this point in the history
Co-authored-by: Jorge Martinez <jorge.martinezgarrido@ansys.com>
  • Loading branch information
Revathyvenugopal162 and jorgepiloto committed Apr 1, 2024
1 parent 25b131f commit 47c3745
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 174 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{# ------------------------- Begin macros definition ----------------------- #}
{% if obj.display %}

{# ----------------- Start macros definition for tab item ------------------#}
{% macro tab_item_from_objects_list(objects_list, title="") -%}

.. tab-item:: {{ title }}
.. tab-item:: {{ title }}

.. list-table::
.. list-table::
:header-rows: 0
:widths: auto

Expand All @@ -13,145 +14,121 @@
- {{ obj.summary }}
{% endfor %}
{%- endmacro %}

{# --------------------------- End macros definition ----------------------- #}

{% if obj.display %}

{% if own_page_types and obj["type"] in own_page_types %}
{{ obj.short_name }}
{{"=" * obj.name|length }}
{% endif %}

.. py:{{ obj["type"] }}:: {{ obj["short_name"] }}{% if obj["args"] %}({{ obj["args"] }}){% endif %}
{% if own_page_types and obj["type"] in own_page_types %}
:canonical: {{ obj["obj"]["full_name"] }}
{% endif %}

{% for (args, return_annotation) in obj.overloads %}
{{ " " * (obj.type | length) }} {{ obj.short_name }}{% if args %}({{ args }}){% endif %}
{% endfor %}


{% if obj.bases %}
{% if "show-inheritance" in autoapi_options %}
Bases: {% for base in obj.bases %}{{ base|link_objs }}{% if not loop.last %}, {% endif %}{% endfor %}
{% endif %}

{% if "show-inheritance-diagram" in autoapi_options and obj.bases != ["object"] %}
.. autoapi-inheritance-diagram:: {{ obj.obj["full_name"] }}
:parts: 1
{% if "private-members" in autoapi_options %}
:private-bases:
{% endif %}

{% endif %}
{% endif %}

{% if obj.docstring -%}
{{ obj.docstring|indent(3) }}
{% endif %}
{% if is_own_page %}
:class:`{{ obj.name }}`
========={{ "=" * obj.name | length }}

{% if "inherited-members" in autoapi_options %}
{% set visible_classes = obj.classes|selectattr("display")|list %}
{% else %}
{% set visible_classes = obj.classes|rejectattr("inherited")|selectattr("display")|list %}
{% endif %}

{% for klass in visible_classes %}
{{ klass.render()|indent(3) }}
{% endfor %}

{% if "inherited-members" in autoapi_options %}
{% set visible_properties = obj.properties|selectattr("display")|list %}
{% else %}
{% set visible_properties = obj.properties|rejectattr("inherited")|selectattr("display")|list %}
{% endif %}

{% if "inherited-members" in autoapi_options %}
{% set visible_attributes = obj.attributes|selectattr("display")|list %}
{% else %}
{% set visible_attributes = obj.attributes|rejectattr("inherited")|selectattr("display")|list %}
{% endif %}
{% endif %}
{% set visible_children = obj.children|selectattr("display")|list %}
{% set own_page_children = visible_children|selectattr("type", "in", own_page_types)|list %}
{% if is_own_page and own_page_children %}
.. toctree::
:hidden:

{% if "inherited-members" in autoapi_options %}
{% set all_visible_methods = obj.methods|selectattr("display")|list %}
{% else %}
{% set all_visible_methods = obj.methods|rejectattr("inherited")|selectattr("display")|list %}
{% endif %}
{% for child in own_page_children %}
{{ child.include_path }}
{% endfor %}

{% set visible_abstract_methods = [] %}
{% set visible_constructor_methods = [] %}
{% set visible_instance_methods = [] %}
{% set visible_special_methods = [] %}
{% set visible_static_methods = [] %}
{% endif %}
.. py:{{ obj.type }}:: {% if is_own_page %}{{ obj.id }}{% else %}{{ obj.short_name }}{% endif %}{% if obj.args %}({{ obj.args }}){% endif %}
{% for element in all_visible_methods %}
{% if "abstractmethod" in element.properties %}
{% set _ = visible_abstract_methods.append(element) %}
{% for (args, return_annotation) in obj.overloads %}
{{ " " * (obj.type | length) }} {{ obj.short_name }}{% if args %}({{ args }}){% endif %}

{% elif "staticmethod" in element.properties %}
{% set _ = visible_static_methods.append(element) %}
{% endfor %}
{% if obj.bases %}
{% if "show-inheritance" in autoapi_options %}

{% elif "classmethod" in element.properties or element.name in ["__new__", "__init__"] %}
{% set _ = visible_constructor_methods.append(element) %}
Bases: {% for base in obj.bases %}{{ base|link_objs }}{% if not loop.last %}, {% endif %}{% endfor %}
{% endif %}

{% elif element.name.startswith("__") and element.name.endswith("__") and element.name not in ["__new__", "__init__"] %}
{% set _ = visible_special_methods.append(element) %}

{% else %}
{% set _ = visible_instance_methods.append(element) %}
{% if "show-inheritance-diagram" in autoapi_options and obj.bases != ["object"] %}
.. autoapi-inheritance-diagram:: {{ obj.obj["full_name"] }}
:parts: 1
{% if "private-members" in autoapi_options %}
:private-bases:
{% endif %}

{% endif %}
{% endif %}
{% endfor %}

{% if obj.docstring %}

{% set class_objects = visible_properties + visible_attributes + all_visible_methods %}
{{ obj.docstring|indent(3) }}
{% endif %}
{% set this_page_children = visible_children|rejectattr("type", "in", own_page_types)|list %}
{% set visible_abstract_methods = [] %}
{% set visible_constructor_methods = [] %}
{% set visible_instance_methods = [] %}
{% set visible_special_methods = [] %}
{% set visible_static_methods = [] %}
{% set visible_properties = this_page_children|selectattr("type", "equalto", "property")|list %}
{% set visible_attributes = this_page_children|selectattr("type", "equalto", "attribute")|list %}
{% set all_visible_methods = this_page_children|selectattr("type", "equalto", "method")|list %}
{% if all_visible_methods %}
{% for element in all_visible_methods %}
{% if "abstractmethod" in element.properties %}
{% set _ = visible_abstract_methods.append(element) %}

{% elif "staticmethod" in element.properties %}
{% set _ = visible_static_methods.append(element) %}

{% elif "classmethod" in element.properties or element.name in ["__new__", "__init__"] %}
{% set _ = visible_constructor_methods.append(element) %}

{% elif element.name.startswith("__") and element.name.endswith("__") and element.name not in ["__new__", "__init__"] %}
{% set _ = visible_special_methods.append(element) %}

{% else %}
{% set _ = visible_instance_methods.append(element) %}
{% endif %}
{% endfor %}
{% endif %}

{# ------------------------ Begin tabset definition ----------------------- #}
{% if this_page_children %}

{% if class_objects %}
.. py:currentmodule:: {{ obj.short_name }}
{# ------------------------- Begin tab-set definition ----------------------- #}

{% if own_page_types and obj["type"] in own_page_types %}
Overview
--------
.. py:currentmodule:: {{ obj.short_name }}
{% endif %}

.. tab-set::

{% if visible_abstract_methods %}
{{ tab_item_from_objects_list(visible_abstract_methods, "Abstract methods") }}
{% endif %}
{% if visible_abstract_methods %}
{{ tab_item_from_objects_list(visible_abstract_methods, "Abstract methods") }}
{% endif %}

{% if visible_constructor_methods %}
{{ tab_item_from_objects_list(visible_constructor_methods, "Constructors") }}
{% endif %}
{% if visible_constructor_methods %}
{{ tab_item_from_objects_list(visible_constructor_methods, "Constructors") }}
{% endif %}

{% if visible_instance_methods %}
{{ tab_item_from_objects_list(visible_instance_methods, "Methods") }}
{% endif %}
{% if visible_instance_methods %}
{{ tab_item_from_objects_list(visible_instance_methods, "Methods") }}
{% endif %}

{% if visible_properties %}
{{ tab_item_from_objects_list(visible_properties, "Properties") }}
{% endif %}
{% if visible_properties %}
{{ tab_item_from_objects_list(visible_properties, "Properties") }}
{% endif %}

{% if visible_attributes %}
{{ tab_item_from_objects_list(visible_attributes, "Attributes") }}
{% endif %}
{% if visible_attributes %}
{{ tab_item_from_objects_list(visible_attributes, "Attributes") }}
{% endif %}

{% if visible_static_methods %}
{{ tab_item_from_objects_list(visible_static_methods, "Static methods") }}
{% endif %}
{% if visible_static_methods %}
{{ tab_item_from_objects_list(visible_static_methods, "Static methods") }}
{% endif %}

{% if visible_special_methods %}
{{ tab_item_from_objects_list(visible_special_methods, "Special methods") }}
{% endif %}
{% if visible_special_methods %}
{{ tab_item_from_objects_list(visible_special_methods, "Special methods") }}
{% endif %}

{% endif %}
{% endif %}
{% endif %}
{# ---------------------- End class tabset -------------------- #}
{# ---------------------- Begin class datails -------------------- #}

{# ---------------------- Begin class details -------------------- #}

Import detail
-------------
Expand All @@ -162,30 +139,85 @@ Import detail
from {{ joined_parts }} import {{ obj["short_name"] }}
{% if visible_properties %}

{% if visible_properties %}
Property detail
---------------
{% for property in visible_properties %}
{% for property in visible_properties %}
{{ property.render() }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}


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


{% if all_visible_methods %}
{% if all_visible_methods %}
Method detail
-------------
{% for method in all_visible_methods %}
{% for method in all_visible_methods %}
{{ method.render() }}
{% endfor %}
{% endif %}
{% endfor %}
{% 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
-------

.. autoapisummary::

{% for method in visible_methods %}
{{ method.id }}
{% endfor %}


{% endif %}
{% endif %}

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

0 comments on commit 47c3745

Please sign in to comment.