Skip to content

Commit 81e7e29

Browse files
authored
Update autosummary templates (#2187)
* Add more autosummary templates * Add automatic update of copyright year * No need to support masked array, so removing replacing in full name
1 parent 488bdb5 commit 81e7e29

File tree

8 files changed

+112
-48
lines changed

8 files changed

+112
-48
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
:orphan:
2+
3+
{{ fullname | escape | underline}}
4+
5+
.. currentmodule:: {{ module }}
6+
7+
attribute
8+
9+
.. auto{{ objtype }}:: {{ objname }}

doc/_templates/autosummary/base.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{% if objtype == 'property' %}
2+
:orphan:
3+
{% endif %}
4+
5+
{{ fullname | escape | underline}}
6+
7+
.. currentmodule:: {{ module }}
8+
9+
{% if objtype == 'property' %}
10+
property
11+
{% endif %}
12+
13+
.. auto{{ objtype }}:: {{ objname }}

doc/_templates/autosummary/class.rst

Lines changed: 21 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,27 @@
1-
{{ fullname }}
2-
{{ underline }}
3-
4-
.. currentmodule:: {{ module }}
5-
6-
.. autoclass:: {{ objname }}
7-
8-
..
9-
Methods
1+
{% extends "!autosummary/class.rst" %}
102

113
{% block methods %}
12-
13-
.. rubric:: Methods
14-
15-
..
16-
Special methods
17-
18-
{% for item in ('__getitem__', '__setitem__', '__len__', '__next__', '__iter__') %}
19-
{% if item in all_methods or item in all_attributes %}
20-
.. automethod:: {{ item }}
4+
{% if methods %}
5+
.. HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages.
6+
.. autosummary::
7+
:toctree:
8+
{% for item in all_methods %}
9+
{%- if not item.startswith('_') or item in ['__call__'] %}
10+
{{ name }}.{{ item }}
11+
{%- endif -%}
12+
{%- endfor %}
2113
{% endif %}
22-
{%- endfor %}
23-
24-
..
25-
Ordinary methods
26-
27-
{% for item in methods %}
28-
{% if item not in ('__init__',) %}
29-
.. automethod:: {{ item }}
30-
{% endif %}
31-
{%- endfor %}
32-
33-
..
34-
Special methods
14+
{% endblock %}
3515

36-
{% for item in ('__eq__', '__ne__', '__lt__', '__le__', '__gt__', '__ge__') %}
37-
{% if item in all_methods %}
38-
.. automethod:: {{ item }}
16+
{% block attributes %}
17+
{% if attributes %}
18+
.. HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages.
19+
.. autosummary::
20+
:toctree:
21+
{% for item in all_attributes %}
22+
{%- if not item.startswith('_') %}
23+
{{ name }}.{{ item }}
24+
{%- endif -%}
25+
{%- endfor %}
3926
{% endif %}
40-
{%- endfor %}
4127
{% endblock %}
42-
43-
..
44-
Attributes
45-
46-
{% block attributes %} {% if attributes %}
47-
48-
.. rubric:: Attributes
49-
50-
{% for item in attributes %}
51-
.. autoattribute:: {{ item }}
52-
{%- endfor %}
53-
{% endif %} {% endblock %}

doc/_templates/autosummary/member.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
:orphan:
2+
3+
{{ fullname | escape | underline}}
4+
5+
.. currentmodule:: {{ module }}
6+
7+
member
8+
9+
.. auto{{ objtype }}:: {{ objname }}

doc/_templates/autosummary/method.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
:orphan:
2+
3+
{{ fullname | escape | underline}}
4+
5+
.. currentmodule:: {{ module }}
6+
7+
method
8+
9+
.. auto{{ objtype }}:: {{ objname }}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{{ fullname | escape | underline}}
2+
3+
.. automodule:: {{ fullname }}
4+
5+
{% block docstring %}
6+
{% endblock %}

doc/_templates/autosummary/module.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{% extends "!autosummary/module.rst" %}
2+
3+
{# This file is almost the same as the default, but adds :toctree: to the
4+
autosummary directives. The original can be found at
5+
``sphinx/ext/autosummary/templates/autosummary/module.rst``. #}
6+
7+
{% block attributes %}
8+
{% if attributes %}
9+
.. rubric:: Module Attributes
10+
11+
.. autosummary::
12+
:toctree:
13+
{% for item in attributes %}
14+
{{ item }}
15+
{%- endfor %}
16+
{% endif %}
17+
{% endblock %}
18+
19+
{% block functions %}
20+
{% if functions %}
21+
.. rubric:: Functions
22+
23+
.. autosummary::
24+
:toctree:
25+
{% for item in functions %}
26+
{{ item }}
27+
{%- endfor %}
28+
{% endif %}
29+
{% endblock %}
30+
31+
{% block classes %}
32+
{% if classes %}
33+
.. rubric:: Classes
34+
35+
.. autosummary::
36+
:toctree:
37+
{% for item in classes %}
38+
{{ item }}
39+
{%- endfor %}
40+
{% endif %}
41+
{% endblock %}

doc/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# full list see the documentation:
77
# http://www.sphinx-doc.org/en/master/config
88

9+
from datetime import datetime
10+
911
from sphinx.ext.autodoc import FunctionDocumenter
1012

1113
from dpnp.dpnp_algo.dpnp_elementwise_common import DPNPBinaryFunc, DPNPUnaryFunc
@@ -32,7 +34,8 @@
3234
# -- Project information -----------------------------------------------------
3335

3436
project = "Data Parallel Extension for NumPy"
35-
copyright = "2020-2024, Intel Corporation"
37+
year = datetime.now().year
38+
copyright = f"2020-{year}, Intel Corporation"
3639
author = "Intel"
3740

3841
version = dpnp.__version__.strip(".dirty")

0 commit comments

Comments
 (0)