File: class.rst

package info (click to toggle)
python-skbio 0.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,924 kB
  • sloc: python: 67,527; ansic: 672; makefile: 225
file content (154 lines) | stat: -rw-r--r-- 3,471 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
{# This template was modified from autosummary's default template. #}
{{ fullname | escape | underline}}


{# Identify special methods (i.e., dunder or magic methods) that are relevant. #}

{% set methods_to_ignore = [
   '__class__',
   '__delattr__',
   '__getattribute__',
   '__init__',
   '__dir__',
   '__format__',
   '__new__',
   '__reduce__',
   '__reduce_ex__',
   '__repr__',
   '__setattr__',
   '__sizeof__',
   '__subclasshook__',
   '__init_subclass__',
   '__class_getitem__',
] %}
{% set special_methods = [] %}
{% for item in all_methods %}
   {% if item.startswith('__') and item not in methods_to_ignore %}
      {{ special_methods.append(item) or '' }}
   {% endif %}
{% endfor %}


{# Distinguish inherited and own members. #}

{% set inherited_attributes = [] %}
{% set own_attributes = [] %}
{% for item in attributes %}
   {% if item in inherited_members %}
      {{ inherited_attributes.append(item) or '' }}
   {% else %}
      {{ own_attributes.append(item) or '' }}
   {% endif %}
{% endfor %}

{% set inherited_methods = [] %}
{% set own_methods = [] %}
{% for item in methods %}
   {% if item != '__init__' %}
      {% if item in inherited_members %}
         {{ inherited_methods.append(item) or '' }}
      {% else %}
         {{ own_methods.append(item) or '' }}
      {% endif %}
   {% endif %}
{% endfor %}

{% set inherited_special_methods = [] %}
{% set own_special_methods = [] %}
{% for item in special_methods %}
   {% if item in inherited_members %}
      {{ inherited_special_methods.append(item) or '' }}
   {% else %}
      {{ own_special_methods.append(item) or '' }}
   {% endif %}
{% endfor %}


{# Class name, signatures, superclass (if any) and docstring. #}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}


{# Table of contents #}

   {% block attributes %}
   {% if own_attributes %}
   .. rubric:: Attributes

   .. autosummary::
   {% for item in own_attributes %}
      ~{{ name }}.{{ item }}
   {%- endfor %}
   {% endif %}

   {% if inherited_attributes %}
   .. rubric:: Attributes (inherited)

   .. autoinherit::
   {% for item in inherited_attributes %}
      ~{{ name }}.{{ item }}
   {%- endfor %}
   {% endif %}
   {% endblock %}

   {% block methods %}
   {% if own_methods %}
   .. rubric:: Methods

   .. autosummary::
      :toctree:
   {% for item in own_methods %}
      ~{{ name }}.{{ item }}
   {% endfor %}
   {% endif %}

   {% if inherited_methods %}
   .. rubric:: Methods (inherited)

   .. autoinherit::
   {%- for item in inherited_methods %}
      ~{{ name }}.{{ item }}
   {%- endfor %}
   {% endif %}
   {% endblock %}

   {% block special_methods %}
   {% if own_special_methods %}
   .. rubric:: Special methods

   .. autosummary::
   {% for item in own_special_methods %}
      ~{{ name }}.{{ item }}
   {%- endfor %}
   {% endif %}

   {% if inherited_special_methods %}
   .. rubric:: Special methods (inherited)

   .. autoinherit::
   {% for item in inherited_special_methods %}
      ~{{ name }}.{{ item }}
   {%- endfor %}
   {% endif %}
   {% endblock %}


{# Detailed documentation #}

   {% block details %}
   .. rubric:: Details

   {% for item in own_attributes %}
   {% if item not in inherited_members %}
   .. autoattribute:: {{ name }}.{{ item }}
   {% endif %}
   {% endfor %}

   {% for item in own_special_methods %}
   {% if item not in inherited_members %}
   .. automethod:: {{ name }}.{{ item }}
   {% endif %}
   {% endfor %}
   {% endblock %}