From 0046711a15efc7fa8330826542cdf7967c4a9eb1 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Mon, 25 Dec 2023 09:15:54 +0300 Subject: [PATCH 1/3] gh-101100: fix sphinx warnings in reference/datamodel.rst --- Doc/library/stdtypes.rst | 11 +++++++++++ Doc/reference/datamodel.rst | 16 ++++++++-------- Doc/tools/.nitignore | 1 - 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 9028ff5c134fa9..bcd5ad7f3ee31c 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -5492,6 +5492,17 @@ types, where they are relevant. Some of these are not reported by the The tuple of base classes of a class object. +.. attribute:: definition.__module__ + + The name of the module in which the class or function was defined. + + +.. attribute:: definition.__doc__ + + The documentation string of the class, function, method, descriptor, + generator instance, or ``None`` if undefined. + + .. attribute:: definition.__name__ The name of the class, function, method, descriptor, or diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index ca29a3712dfa38..b6745f97990be1 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -441,7 +441,7 @@ Sets These represent a mutable set. They are created by the built-in :func:`set` constructor and can be modified afterwards by several methods, such as - :meth:`~set.add`. + :meth:`~frozenset.add`. Frozen sets @@ -885,7 +885,7 @@ Predefined (writable) attributes: :attr:`__name__` The module's name. - :attr:`__doc__` + :attr:`~definition.__doc__` The module's documentation string, or ``None`` if unavailable. @@ -976,7 +976,7 @@ Special attributes: :attr:`~definition.__name__` The class name. - :attr:`__module__` + :attr:`~definition.__module__` The name of the module in which the class was defined. :attr:`~object.__dict__` @@ -986,7 +986,7 @@ Special attributes: A tuple containing the base classes, in the order of their occurrence in the base class list. - :attr:`__doc__` + :attr:`~definition.__doc__` The class's documentation string, or ``None`` if undefined. :attr:`__annotations__` @@ -996,7 +996,7 @@ Special attributes: working with :attr:`__annotations__`, please see :ref:`annotations-howto`. - :attr:`__type_params__` + :attr:`~definition.__type_params__` A tuple containing the :ref:`type parameters ` of a :ref:`generic class `. @@ -1563,8 +1563,8 @@ When implementing a class that emulates any built-in type, it is important that the emulation only be implemented to the degree that it makes sense for the object being modelled. For example, some sequences may work well with retrieval of individual elements, but extracting a slice may not make sense. (One example -of this is the :class:`~xml.dom.NodeList` interface in the W3C's Document -Object Model.) +of this is the class ``NodeList`` interface in the W3C's Document +Object Model, see :ref:`dom-nodelist-objects`.) .. _customization: @@ -2334,7 +2334,7 @@ class defining the method. .. versionadded:: 3.6 -When a class is created, :meth:`type.__new__` scans the class variables +When a class is created, ``type.__new__`` scans the class variables and makes callbacks to those with a :meth:`~object.__set_name__` hook. .. method:: object.__set_name__(self, owner, name) diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore index 5935d059877a91..bad501774553ae 100644 --- a/Doc/tools/.nitignore +++ b/Doc/tools/.nitignore @@ -95,7 +95,6 @@ Doc/library/xmlrpc.client.rst Doc/library/xmlrpc.server.rst Doc/library/zlib.rst Doc/reference/compound_stmts.rst -Doc/reference/datamodel.rst Doc/reference/expressions.rst Doc/reference/import.rst Doc/tutorial/datastructures.rst From d1fd6e8600a35f312ce06cf4843b66f27351f55a Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Fri, 19 Jan 2024 14:15:06 +0300 Subject: [PATCH 2/3] address review: revert set.add --- Doc/conf.py | 1 + Doc/reference/datamodel.rst | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/conf.py b/Doc/conf.py index dc09b0b51ca84c..5e3706ae346344 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -251,6 +251,7 @@ ('py:meth', '__missing__'), ('py:attr', '__wrapped__'), ('py:meth', 'index'), # list.index, tuple.index, etc. + ('py:meth', 'set.add'), ] # gh-106948: Copy standard C types declared in the "c:type" domain to the diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index b6745f97990be1..04ae574fc08fff 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -441,7 +441,7 @@ Sets These represent a mutable set. They are created by the built-in :func:`set` constructor and can be modified afterwards by several methods, such as - :meth:`~frozenset.add`. + :meth:`~set.add`. Frozen sets From 4adf825ffb93abe8791d377f80ea2977e30aa581 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Fri, 19 Jan 2024 14:25:58 +0300 Subject: [PATCH 3/3] Update Doc/reference/datamodel.rst Co-authored-by: Alex Waygood --- Doc/reference/datamodel.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 04ae574fc08fff..df7930508a2009 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -2334,7 +2334,7 @@ class defining the method. .. versionadded:: 3.6 -When a class is created, ``type.__new__`` scans the class variables +When a class is created, :meth:`!type.__new__` scans the class variables and makes callbacks to those with a :meth:`~object.__set_name__` hook. .. method:: object.__set_name__(self, owner, name)