mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Close #8924: autodoc: Support bound argument for TypeVar
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -55,6 +55,7 @@ Deprecated
|
|||||||
Features added
|
Features added
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
* #8924: autodoc: Support ``bound`` argument for TypeVar
|
||||||
* #4826: py domain: Add ``:canonical:`` option to python directives to describe
|
* #4826: py domain: Add ``:canonical:`` option to python directives to describe
|
||||||
the location where the object is defined
|
the location where the object is defined
|
||||||
* #7784: i18n: The alt text for image is translated by default (without
|
* #7784: i18n: The alt text for image is translated by default (without
|
||||||
|
|||||||
@@ -1812,6 +1812,8 @@ class TypeVarMixin(DataDocumenterMixinBase):
|
|||||||
attrs = [repr(self.object.__name__)]
|
attrs = [repr(self.object.__name__)]
|
||||||
for constraint in self.object.__constraints__:
|
for constraint in self.object.__constraints__:
|
||||||
attrs.append(stringify_typehint(constraint))
|
attrs.append(stringify_typehint(constraint))
|
||||||
|
if self.object.__bound__:
|
||||||
|
attrs.append(r"bound=\ " + restify(self.object.__bound__))
|
||||||
if self.object.__covariant__:
|
if self.object.__covariant__:
|
||||||
attrs.append("covariant=True")
|
attrs.append("covariant=True")
|
||||||
if self.object.__contravariant__:
|
if self.object.__contravariant__:
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ T5 = TypeVar("T5", contravariant=True)
|
|||||||
#: T6
|
#: T6
|
||||||
T6 = NewType("T6", int)
|
T6 = NewType("T6", int)
|
||||||
|
|
||||||
|
#: T7
|
||||||
|
T7 = TypeVar("T7", bound=int)
|
||||||
|
|
||||||
|
|
||||||
class Class:
|
class Class:
|
||||||
#: T1
|
#: T1
|
||||||
|
|||||||
@@ -1993,6 +1993,14 @@ def test_autodoc_TypeVar(app):
|
|||||||
'',
|
'',
|
||||||
' alias of :class:`int`',
|
' alias of :class:`int`',
|
||||||
'',
|
'',
|
||||||
|
'',
|
||||||
|
'.. py:data:: T7',
|
||||||
|
' :module: target.typevar',
|
||||||
|
'',
|
||||||
|
' T7',
|
||||||
|
'',
|
||||||
|
" alias of TypeVar('T7', bound=\\ :class:`int`)",
|
||||||
|
'',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user