Skip to content

Commit 8556c08

Browse files
Move methods into class pages for docs (#1290)
### Summary Moved all the methods and attributes into class pages to speed up the building process of the documentation with the new ecosystem sphinx theme. This PR continues the work done by @Eric-Arellano in #1231. See Qiskit/qiskit#10455 for more information. --------- Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
1 parent f16be3b commit 8556c08

File tree

6 files changed

+84
-70
lines changed

6 files changed

+84
-70
lines changed

docs/_templates/autosummary/analysis.rst

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717

1818
.. rubric:: Attributes
1919

20-
.. autosummary::
21-
:toctree: ../stubs/
2220
{% for item in all_attributes %}
2321
{%- if not item.startswith('_') %}
24-
{{ name }}.{{ item }}
22+
.. autoattribute:: {{ name }}.{{ item }}
2523
{%- endif -%}
2624
{%- endfor %}
2725
{% endif %}
@@ -32,16 +30,14 @@
3230

3331
.. rubric:: Methods
3432

35-
.. autosummary::
36-
:toctree: ../stubs/
3733
{% for item in all_methods %}
3834
{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
39-
{{ name }}.{{ item }}
35+
.. automethod:: {{ name }}.{{ item }}
4036
{%- endif -%}
4137
{%- endfor %}
4238
{% for item in inherited_members %}
4339
{%- if item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
44-
{{ name }}.{{ item }}
40+
.. automethod:: {{ name }}.{{ item }}
4541
{%- endif -%}
4642
{%- endfor %}
4743

docs/_templates/autosummary/class.rst

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,58 +12,37 @@
1212
:no-inherited-members:
1313
:no-special-members:
1414

15-
{% block attributes_summary %}
16-
{% if attributes %}
15+
{% block attributes_summary %}
1716

18-
{# This counter lets us only render the heading if there's at least
19-
one valid entry. #}
20-
{% set count = namespace(value=0) %}
17+
{% set wanted_attributes = [] %}
18+
{% for item in attributes%}
19+
{%- if not item.startswith('_') %}
20+
{% set _ = wanted_attributes.append(item)%}
21+
{%- endif -%}
22+
{%- endfor %}
2123

22-
{% for item in attributes %}
23-
{% if not item.startswith('_') %}
24-
{% set count.value = count.value + 1 %}
25-
{% if count.value == 1 %}
24+
{% if wanted_attributes %}
2625
.. rubric:: Attributes
27-
28-
.. autosummary::
29-
:toctree: ../stubs/
30-
{% endif %}
31-
32-
{{ name }}.{{ item }}
33-
{% endif %}
34-
{% endfor %}
26+
{% for item in wanted_attributes %}
27+
.. autoattribute:: {{ name }}.{{ item }}
28+
{%- endfor %}
3529
{% endif %}
36-
{% endblock %}
30+
{% endblock %}
3731

38-
{% block methods_summary %}
39-
{% if methods %}
32+
{% block methods_summary %}
4033

41-
{% set count = namespace(value=0) %}
34+
{% set wanted_methods = [] %}
4235
{% for item in all_methods %}
43-
4436
{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
45-
{% set count.value = count.value + 1 %}
46-
{% if count.value == 1 %}
47-
.. rubric:: Methods
48-
49-
.. autosummary::
50-
:toctree: ../stubs/
51-
{% endif %}
52-
{{ name }}.{{ item }}
37+
{% set _ = wanted_methods.append(item)%}
5338
{%- endif -%}
5439
{%- endfor %}
55-
{% for item in inherited_members %}
56-
{%- if item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
57-
{% set count.value = count.value + 1 %}
58-
{% if count.value == 1 %}
59-
.. rubric:: Methods
6040

61-
.. autosummary::
62-
:toctree: ../stubs/
63-
{% endif %}
64-
{{ name }}.{{ item }}
65-
{%- endif -%}
41+
{% if wanted_methods%}
42+
.. rubric:: Methods
43+
{% for item in wanted_methods %}
44+
.. automethod:: {{ name }}.{{ item }}
6645
{%- endfor %}
6746

6847
{% endif %}
69-
{% endblock %}
48+
{% endblock %}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{# This is identical to class.rst, except for the filtering of the inherited_members. -#}
2+
3+
{% if referencefile %}
4+
.. include:: {{ referencefile }}
5+
{% endif %}
6+
7+
{{ objname }}
8+
{{ underline }}
9+
10+
.. currentmodule:: {{ module }}
11+
12+
.. autoclass:: {{ objname }}
13+
:no-members:
14+
:no-inherited-members:
15+
:no-special-members:
16+
17+
{% block attributes_summary %}
18+
19+
{% set wanted_attributes = [] %}
20+
{% for item in attributes%}
21+
{%- if not item.startswith('_') %}
22+
{% set _ = wanted_attributes.append(item)%}
23+
{%- endif -%}
24+
{%- endfor %}
25+
26+
{% if wanted_attributes%}
27+
.. rubric:: Attributes
28+
{% for item in wanted_attributes %}
29+
.. autoattribute:: {{ name }}.{{ item }}
30+
{%- endfor %}
31+
{% endif %}
32+
{% endblock %}
33+
34+
{% block methods_summary %}
35+
36+
{% set wanted_methods = [] %}
37+
{% for item in all_methods %}
38+
{%- if item not in inherited_members %}
39+
{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
40+
{% set _ = wanted_methods.append(item)%}
41+
{%- endif -%}
42+
{%- endif -%}
43+
{%- endfor %}
44+
45+
{% if wanted_methods %}
46+
.. rubric:: Methods
47+
{% for item in wanted_methods %}
48+
.. automethod:: {{ name }}.{{ item }}
49+
{%- endfor %}
50+
51+
{% endif %}
52+
{% endblock %}

docs/_templates/autosummary/drawer.rst

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717

1818
.. rubric:: Attributes
1919

20-
.. autosummary::
21-
:toctree: ../stubs/
2220
{% for item in all_attributes %}
2321
{%- if not item.startswith('_') %}
24-
{{ name }}.{{ item }}
22+
.. autoattribute:: {{ name }}.{{ item }}
2523
{%- endif -%}
2624
{%- endfor %}
2725
{% endif %}
@@ -32,16 +30,14 @@
3230

3331
.. rubric:: Methods
3432

35-
.. autosummary::
36-
:toctree: ../stubs/
3733
{% for item in all_methods %}
3834
{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
39-
{{ name }}.{{ item }}
35+
.. automethod:: {{ name }}.{{ item }}
4036
{%- endif -%}
4137
{%- endfor %}
4238
{% for item in inherited_members %}
4339
{%- if item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
44-
{{ name }}.{{ item }}
40+
.. automethod:: {{ name }}.{{ item }}
4541
{%- endif -%}
4642
{%- endfor %}
4743

docs/_templates/autosummary/experiment.rst

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717

1818
.. rubric:: Attributes
1919

20-
.. autosummary::
21-
:toctree: ../stubs/
2220
{% for item in all_attributes %}
2321
{%- if not item.startswith('_') %}
24-
{{ name }}.{{ item }}
22+
.. autoattribute:: {{ name }}.{{ item }}
2523
{%- endif -%}
2624
{%- endfor %}
2725
{% endif %}
@@ -32,16 +30,14 @@
3230

3331
.. rubric:: Methods
3432

35-
.. autosummary::
36-
:toctree: ../stubs/
3733
{% for item in all_methods %}
3834
{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
39-
{{ name }}.{{ item }}
35+
.. automethod:: {{ name }}.{{ item }}
4036
{%- endif -%}
4137
{%- endfor %}
4238
{% for item in inherited_members %}
4339
{%- if item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
44-
{{ name }}.{{ item }}
40+
.. automethod:: {{ name }}.{{ item }}
4541
{%- endif -%}
4642
{%- endfor %}
4743

docs/_templates/autosummary/plotter.rst

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717

1818
.. rubric:: Attributes
1919

20-
.. autosummary::
21-
:toctree: ../stubs/
2220
{% for item in all_attributes %}
2321
{%- if not item.startswith('_') %}
24-
{{ name }}.{{ item }}
22+
.. autoattribute:: {{ name }}.{{ item }}
2523
{%- endif -%}
2624
{%- endfor %}
2725
{% endif %}
@@ -32,17 +30,14 @@
3230

3331
.. rubric:: Methods
3432

35-
.. autosummary::
36-
:toctree: ../stubs/
37-
3833
{% for item in all_methods %}
3934
{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
40-
{{ name }}.{{ item }}
35+
.. automethod:: {{ name }}.{{ item }}
4136
{%- endif -%}
4237
{%- endfor %}
4338
{% for item in inherited_members %}
4439
{%- if item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
45-
{{ name }}.{{ item }}
40+
.. automethod:: {{ name }}.{{ item }}
4641
{%- endif -%}
4742
{%- endfor %}
4843

0 commit comments

Comments
 (0)