From a35a47adf84699b767da7ceaa7825beb5cf53042 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Wed, 20 Nov 2024 12:49:28 +0100 Subject: [PATCH 1/3] Add more autosummary templates --- doc/_templates/autosummary/attribute.rst | 13 ++++ doc/_templates/autosummary/base.rst | 17 +++++ doc/_templates/autosummary/class.rst | 68 ++++++------------- doc/_templates/autosummary/member.rst | 13 ++++ doc/_templates/autosummary/method.rst | 13 ++++ doc/_templates/autosummary/minimal_module.rst | 6 ++ doc/_templates/autosummary/module.rst | 41 +++++++++++ 7 files changed, 124 insertions(+), 47 deletions(-) create mode 100644 doc/_templates/autosummary/attribute.rst create mode 100644 doc/_templates/autosummary/base.rst create mode 100644 doc/_templates/autosummary/member.rst create mode 100644 doc/_templates/autosummary/method.rst create mode 100644 doc/_templates/autosummary/minimal_module.rst create mode 100644 doc/_templates/autosummary/module.rst diff --git a/doc/_templates/autosummary/attribute.rst b/doc/_templates/autosummary/attribute.rst new file mode 100644 index 000000000000..ca01b03ddf56 --- /dev/null +++ b/doc/_templates/autosummary/attribute.rst @@ -0,0 +1,13 @@ +:orphan: + +{{ fullname | escape | underline}} + +.. currentmodule:: {{ module }} + +attribute + +.. auto{{ objtype }}:: {{ fullname | replace("dpnp.", "dpnp::") }} + +{# In the fullname (e.g. ``dpnp.ndarray.methodname``), the module name is + ambiguous. Using a ``::`` separator (e.g. ``dpnp::ndarray.methodname``) + specifies ``dpnp`` as the module name. #} diff --git a/doc/_templates/autosummary/base.rst b/doc/_templates/autosummary/base.rst new file mode 100644 index 000000000000..52bc873092b0 --- /dev/null +++ b/doc/_templates/autosummary/base.rst @@ -0,0 +1,17 @@ +{% if objtype == 'property' %} +:orphan: +{% endif %} + +{{ fullname | escape | underline}} + +.. currentmodule:: {{ module }} + +{% if objtype == 'property' %} +property +{% endif %} + +.. auto{{ objtype }}:: {{ fullname | replace("dpnp.", "dpnp::") }} + +{# In the fullname (e.g. ``dpnp.ndarray.methodname``), the module name is + ambiguous. Using a ``::`` separator (e.g. ``dpnp::ndarray.methodname``) + specifies ``dpnp`` as the module name. #} diff --git a/doc/_templates/autosummary/class.rst b/doc/_templates/autosummary/class.rst index 1016b42d3361..64c1b11e9f8b 100644 --- a/doc/_templates/autosummary/class.rst +++ b/doc/_templates/autosummary/class.rst @@ -1,53 +1,27 @@ -{{ fullname }} -{{ underline }} - -.. currentmodule:: {{ module }} - -.. autoclass:: {{ objname }} - - .. - Methods +{% extends "!autosummary/class.rst" %} {% block methods %} - - .. rubric:: Methods - - .. - Special methods - -{% for item in ('__getitem__', '__setitem__', '__len__', '__next__', '__iter__') %} -{% if item in all_methods or item in all_attributes %} - .. automethod:: {{ item }} +{% if methods %} + .. HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages. + .. autosummary:: + :toctree: + {% for item in all_methods %} + {%- if not item.startswith('_') or item in ['__call__'] %} + {{ name }}.{{ item }} + {%- endif -%} + {%- endfor %} {% endif %} -{%- endfor %} - - .. - Ordinary methods - -{% for item in methods %} -{% if item not in ('__init__',) %} - .. automethod:: {{ item }} -{% endif %} -{%- endfor %} - - .. - Special methods +{% endblock %} -{% for item in ('__eq__', '__ne__', '__lt__', '__le__', '__gt__', '__ge__') %} -{% if item in all_methods %} - .. automethod:: {{ item }} +{% block attributes %} +{% if attributes %} + .. HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages. + .. autosummary:: + :toctree: + {% for item in all_attributes %} + {%- if not item.startswith('_') %} + {{ name }}.{{ item }} + {%- endif -%} + {%- endfor %} {% endif %} -{%- endfor %} {% endblock %} - - .. - Attributes - -{% block attributes %} {% if attributes %} - - .. rubric:: Attributes - -{% for item in attributes %} - .. autoattribute:: {{ item }} -{%- endfor %} -{% endif %} {% endblock %} diff --git a/doc/_templates/autosummary/member.rst b/doc/_templates/autosummary/member.rst new file mode 100644 index 000000000000..2c001f7b6fd6 --- /dev/null +++ b/doc/_templates/autosummary/member.rst @@ -0,0 +1,13 @@ +:orphan: + +{{ fullname | escape | underline}} + +.. currentmodule:: {{ module }} + +member + +.. auto{{ objtype }}:: {{ fullname | replace("dpnp.", "dpnp::") }} + +{# In the fullname (e.g. ``dpnp.ndarray.methodname``), the module name is + ambiguous. Using a ``::`` separator (e.g. ``dpnp::ndarray.methodname``) + specifies ``dpnp`` as the module name. #} diff --git a/doc/_templates/autosummary/method.rst b/doc/_templates/autosummary/method.rst new file mode 100644 index 000000000000..572de53908c9 --- /dev/null +++ b/doc/_templates/autosummary/method.rst @@ -0,0 +1,13 @@ +:orphan: + +{{ fullname | escape | underline}} + +.. currentmodule:: {{ module }} + +method + +.. auto{{ objtype }}:: {{ fullname | replace("dpnp.", "dpnp::") }} + +{# In the fullname (e.g. ``dpnp.ndarray.methodname``), the module name is + ambiguous. Using a ``::`` separator (e.g. ``dpnp::ndarray.methodname``) + specifies ``dpnp`` as the module name. #} diff --git a/doc/_templates/autosummary/minimal_module.rst b/doc/_templates/autosummary/minimal_module.rst new file mode 100644 index 000000000000..b192459c0d12 --- /dev/null +++ b/doc/_templates/autosummary/minimal_module.rst @@ -0,0 +1,6 @@ +{{ fullname | escape | underline}} + +.. automodule:: {{ fullname }} + + {% block docstring %} + {% endblock %} diff --git a/doc/_templates/autosummary/module.rst b/doc/_templates/autosummary/module.rst new file mode 100644 index 000000000000..66b2fb5e040f --- /dev/null +++ b/doc/_templates/autosummary/module.rst @@ -0,0 +1,41 @@ +{% extends "!autosummary/module.rst" %} + +{# This file is almost the same as the default, but adds :toctree: to the + autosummary directives. The original can be found at + ``sphinx/ext/autosummary/templates/autosummary/module.rst``. #} + +{% block attributes %} +{% if attributes %} + .. rubric:: Module Attributes + + .. autosummary:: + :toctree: + {% for item in attributes %} + {{ item }} + {%- endfor %} +{% endif %} +{% endblock %} + +{% block functions %} +{% if functions %} + .. rubric:: Functions + + .. autosummary:: + :toctree: + {% for item in functions %} + {{ item }} + {%- endfor %} +{% endif %} +{% endblock %} + +{% block classes %} +{% if classes %} + .. rubric:: Classes + + .. autosummary:: + :toctree: + {% for item in classes %} + {{ item }} + {%- endfor %} +{% endif %} +{% endblock %} From 37f8d637824fac52a7b710d97f002c29779fbd43 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Wed, 20 Nov 2024 12:52:01 +0100 Subject: [PATCH 2/3] Add automatic update of copyright year --- doc/conf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 081070a5e59b..413f3d0ac399 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -6,6 +6,8 @@ # full list see the documentation: # http://www.sphinx-doc.org/en/master/config +from datetime import datetime + from sphinx.ext.autodoc import FunctionDocumenter from dpnp.dpnp_algo.dpnp_elementwise_common import DPNPBinaryFunc, DPNPUnaryFunc @@ -32,7 +34,8 @@ # -- Project information ----------------------------------------------------- project = "Data Parallel Extension for NumPy" -copyright = "2020-2024, Intel Corporation" +year = datetime.now().year +copyright = f"2020-{year}, Intel Corporation" author = "Intel" version = dpnp.__version__.strip(".dirty") From 6efd45ce92744bf23ac15f7cdc4ccf8068055991 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Wed, 20 Nov 2024 14:04:04 +0100 Subject: [PATCH 3/3] No need to support masked array, so removing replacing in full name --- doc/_templates/autosummary/attribute.rst | 6 +----- doc/_templates/autosummary/base.rst | 6 +----- doc/_templates/autosummary/member.rst | 6 +----- doc/_templates/autosummary/method.rst | 6 +----- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/doc/_templates/autosummary/attribute.rst b/doc/_templates/autosummary/attribute.rst index ca01b03ddf56..053ef2e599bc 100644 --- a/doc/_templates/autosummary/attribute.rst +++ b/doc/_templates/autosummary/attribute.rst @@ -6,8 +6,4 @@ attribute -.. auto{{ objtype }}:: {{ fullname | replace("dpnp.", "dpnp::") }} - -{# In the fullname (e.g. ``dpnp.ndarray.methodname``), the module name is - ambiguous. Using a ``::`` separator (e.g. ``dpnp::ndarray.methodname``) - specifies ``dpnp`` as the module name. #} +.. auto{{ objtype }}:: {{ objname }} diff --git a/doc/_templates/autosummary/base.rst b/doc/_templates/autosummary/base.rst index 52bc873092b0..a39b883d7da9 100644 --- a/doc/_templates/autosummary/base.rst +++ b/doc/_templates/autosummary/base.rst @@ -10,8 +10,4 @@ property {% endif %} -.. auto{{ objtype }}:: {{ fullname | replace("dpnp.", "dpnp::") }} - -{# In the fullname (e.g. ``dpnp.ndarray.methodname``), the module name is - ambiguous. Using a ``::`` separator (e.g. ``dpnp::ndarray.methodname``) - specifies ``dpnp`` as the module name. #} +.. auto{{ objtype }}:: {{ objname }} diff --git a/doc/_templates/autosummary/member.rst b/doc/_templates/autosummary/member.rst index 2c001f7b6fd6..aff1005ece71 100644 --- a/doc/_templates/autosummary/member.rst +++ b/doc/_templates/autosummary/member.rst @@ -6,8 +6,4 @@ member -.. auto{{ objtype }}:: {{ fullname | replace("dpnp.", "dpnp::") }} - -{# In the fullname (e.g. ``dpnp.ndarray.methodname``), the module name is - ambiguous. Using a ``::`` separator (e.g. ``dpnp::ndarray.methodname``) - specifies ``dpnp`` as the module name. #} +.. auto{{ objtype }}:: {{ objname }} diff --git a/doc/_templates/autosummary/method.rst b/doc/_templates/autosummary/method.rst index 572de53908c9..cdf7bc566a17 100644 --- a/doc/_templates/autosummary/method.rst +++ b/doc/_templates/autosummary/method.rst @@ -6,8 +6,4 @@ method -.. auto{{ objtype }}:: {{ fullname | replace("dpnp.", "dpnp::") }} - -{# In the fullname (e.g. ``dpnp.ndarray.methodname``), the module name is - ambiguous. Using a ``::`` separator (e.g. ``dpnp::ndarray.methodname``) - specifies ``dpnp`` as the module name. #} +.. auto{{ objtype }}:: {{ objname }}