|
| 1 | +{# ------------------------- Begin macros definition ----------------------- #} |
| 2 | + |
| 3 | +{% macro tab_item_from_objects_list(objects_list, title="") -%} |
| 4 | + |
| 5 | + .. tab-item:: {{ title }} |
| 6 | + |
| 7 | + .. list-table:: |
| 8 | + :header-rows: 0 |
| 9 | + :widths: auto |
| 10 | + |
| 11 | + {% for obj in objects_list %} |
| 12 | + * - :py:attr:`~{{ obj.name }}` |
| 13 | + - {{ obj.summary }} |
| 14 | + {% endfor %} |
| 15 | +{%- endmacro %} |
| 16 | + |
| 17 | +{# --------------------------- End macros definition ----------------------- #} |
| 18 | + |
| 19 | +{% if obj.display %} |
| 20 | + |
| 21 | +{% if render_in_single_page and obj["type"] in render_in_single_page %} |
| 22 | +{{ obj.short_name }} |
| 23 | +{{"=" * obj.name|length }} |
| 24 | +{% endif %} |
| 25 | + |
| 26 | +.. py:{{ obj["type"] }}:: {{ obj["short_name"] }}{% if obj["args"] %}({{ obj["args"] }}){% endif %} |
| 27 | +
|
| 28 | +{% if render_in_single_page and obj["type"] in render_in_single_page %} |
| 29 | + :canonical: {{ obj["obj"]["full_name"] }} |
| 30 | +{% endif %} |
| 31 | + |
| 32 | +{% for (args, return_annotation) in obj.overloads %} |
| 33 | + {{ " " * (obj.type | length) }} {{ obj.short_name }}{% if args %}({{ args }}){% endif %} |
| 34 | +{% endfor %} |
| 35 | + |
| 36 | + |
| 37 | +{% if obj.bases %} |
| 38 | +{% if "show-inheritance" in autoapi_options %} |
| 39 | +Bases: {% for base in obj.bases %}{{ base|link_objs }}{% if not loop.last %}, {% endif %}{% endfor %} |
| 40 | +{% endif %} |
| 41 | + |
| 42 | +{% if "show-inheritance-diagram" in autoapi_options and obj.bases != ["object"] %} |
| 43 | +.. autoapi-inheritance-diagram:: {{ obj.obj["full_name"] }} |
| 44 | + :parts: 1 |
| 45 | + {% if "private-members" in autoapi_options %} |
| 46 | + :private-bases: |
| 47 | + {% endif %} |
| 48 | + |
| 49 | +{% endif %} |
| 50 | +{% endif %} |
| 51 | + |
| 52 | +{% if obj.docstring -%} |
| 53 | +{{ obj.summary|indent(3) }} |
| 54 | +{% endif %} |
| 55 | + |
| 56 | +{% if "inherited-members" in autoapi_options %} |
| 57 | +{% set visible_classes = obj.classes|selectattr("display")|list %} |
| 58 | +{% else %} |
| 59 | +{% set visible_classes = obj.classes|rejectattr("inherited")|selectattr("display")|list %} |
| 60 | +{% endif %} |
| 61 | + |
| 62 | +{% for klass in visible_classes %} |
| 63 | +{{ klass.render()|indent(3) }} |
| 64 | +{% endfor %} |
| 65 | + |
| 66 | +{% if "inherited-members" in autoapi_options %} |
| 67 | +{% set visible_properties = obj.properties|selectattr("display")|list %} |
| 68 | +{% else %} |
| 69 | +{% set visible_properties = obj.properties|rejectattr("inherited")|selectattr("display")|list %} |
| 70 | +{% endif %} |
| 71 | + |
| 72 | +{% if "inherited-members" in autoapi_options %} |
| 73 | +{% set visible_attributes = obj.attributes|selectattr("display")|list %} |
| 74 | +{% else %} |
| 75 | +{% set visible_attributes = obj.attributes|rejectattr("inherited")|selectattr("display")|list %} |
| 76 | +{% endif %} |
| 77 | + |
| 78 | +{% if "inherited-members" in autoapi_options %} |
| 79 | +{% set all_visible_methods = obj.methods|selectattr("display")|list %} |
| 80 | +{% else %} |
| 81 | +{% set all_visible_methods = obj.methods|rejectattr("inherited")|selectattr("display")|list %} |
| 82 | +{% endif %} |
| 83 | + |
| 84 | +{% set visible_abstract_methods = [] %} |
| 85 | +{% set visible_constructor_methods = [] %} |
| 86 | +{% set visible_instance_methods = [] %} |
| 87 | +{% set visible_special_methods = [] %} |
| 88 | +{% set visible_static_methods = [] %} |
| 89 | + |
| 90 | +{% for element in all_visible_methods %} |
| 91 | + {% if "abstractmethod" in element.properties %} |
| 92 | + {% set _ = visible_abstract_methods.append(element) %} |
| 93 | + |
| 94 | + {% elif "staticmethod" in element.properties %} |
| 95 | + {% set _ = visible_static_methods.append(element) %} |
| 96 | + |
| 97 | + {% elif "classmethod" in element.properties or element.name in ["__new__", "__init__"] %} |
| 98 | + {% set _ = visible_constructor_methods.append(element) %} |
| 99 | + |
| 100 | + {% elif element.name.startswith("__") and element.name.endswith("__") and element.name not in ["__new__", "__init__"] %} |
| 101 | + {% set _ = visible_special_methods.append(element) %} |
| 102 | + |
| 103 | + {% else %} |
| 104 | + {% set _ = visible_instance_methods.append(element) %} |
| 105 | + |
| 106 | + {% endif %} |
| 107 | +{% endfor %} |
| 108 | + |
| 109 | + |
| 110 | +{% set class_objects = visible_properties + visible_attributes + all_visible_methods %} |
| 111 | + |
| 112 | +{# ------------------------ Begin tabset definition ----------------------- #} |
| 113 | + |
| 114 | +{% if class_objects %} |
| 115 | + |
| 116 | +{% if render_in_single_page and obj["type"] in render_in_single_page %} |
| 117 | +Overview |
| 118 | +-------- |
| 119 | +.. py:currentmodule:: {{ obj.short_name }} |
| 120 | +{% endif %} |
| 121 | +.. tab-set:: |
| 122 | + |
| 123 | +{% if visible_abstract_methods %} |
| 124 | + {{ tab_item_from_objects_list(visible_abstract_methods, "Abstract methods") }} |
| 125 | +{% endif %} |
| 126 | + |
| 127 | +{% if visible_constructor_methods %} |
| 128 | + {{ tab_item_from_objects_list(visible_constructor_methods, "Constructors") }} |
| 129 | +{% endif %} |
| 130 | + |
| 131 | +{% if visible_instance_methods %} |
| 132 | + {{ tab_item_from_objects_list(visible_instance_methods, "Methods") }} |
| 133 | +{% endif %} |
| 134 | + |
| 135 | +{% if visible_properties %} |
| 136 | + {{ tab_item_from_objects_list(visible_properties, "Properties") }} |
| 137 | +{% endif %} |
| 138 | + |
| 139 | +{% if visible_attributes %} |
| 140 | + {{ tab_item_from_objects_list(visible_attributes, "Attributes") }} |
| 141 | +{% endif %} |
| 142 | + |
| 143 | +{% if visible_static_methods %} |
| 144 | + {{ tab_item_from_objects_list(visible_static_methods, "Static methods") }} |
| 145 | +{% endif %} |
| 146 | + |
| 147 | +{% if visible_special_methods %} |
| 148 | + {{ tab_item_from_objects_list(visible_special_methods, "Special methods") }} |
| 149 | +{% endif %} |
| 150 | + |
| 151 | +{% endif %} |
| 152 | +{% endif %} |
| 153 | +{# ---------------------- End class tabset -------------------- #} |
| 154 | +{# ---------------------- Begin class datails -------------------- #} |
| 155 | + |
| 156 | +Import detail |
| 157 | +------------- |
| 158 | +{% set split_parts = obj.obj["full_name"].split('.') %} |
| 159 | +{% set joined_parts = '.'.join(split_parts[:-1]) %} |
| 160 | + |
| 161 | +.. code-block:: python |
| 162 | +
|
| 163 | + from {{ joined_parts }} import {{ obj["short_name"] }} |
| 164 | +
|
| 165 | +{% if visible_properties %} |
| 166 | + |
| 167 | +Property detail |
| 168 | +--------------- |
| 169 | +{% for property in visible_properties %} |
| 170 | +{{ property.render() }} |
| 171 | +{% endfor %} |
| 172 | +{% endif %} |
| 173 | + |
| 174 | + |
| 175 | +{% if visible_attributes %} |
| 176 | +Attribute detail |
| 177 | +---------------- |
| 178 | +{% for attribute in visible_attributes %} |
| 179 | +{{ attribute.render() }} |
| 180 | +{% endfor %} |
| 181 | +{% endif %} |
| 182 | + |
| 183 | +{% if all_visible_methods %} |
| 184 | +Method detail |
| 185 | +------------- |
| 186 | +{% for method in all_visible_methods %} |
| 187 | +{{ method.render() }} |
| 188 | +{% endfor %} |
| 189 | +{% endif %} |
| 190 | + |
| 191 | +{# ---------------------- End class details -------------------- #} |
0 commit comments