mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-11-02 20:30:30 -06:00
Fix a logic error that causes annotations not to be shown for descriptors
This `if not self._datadescriptor` was originally here before type annotations were supported, to prevent showing `descr4 = <_Descriptor ...>` in the docs. When type annotations were added, the support for appending `:type:` was put in the wrong place. It should have been outside this if, not within it.
This commit is contained in:
1 parent
21ca43719a
commit
b7ce4a4c13
3 files changed
+28
-11
No files matched your search
@@ -6,11 +6,20 @@ attr2: str
|
||||
attr3 = '' # type: str
|
||||
|
||||
|
||||
class _Descriptor:
|
||||
def __init__(self, name):
|
||||
self.__doc__ = "This is {}".format(name)
|
||||
def __get__(self):
|
||||
pass
|
||||
|
||||
|
||||
class Class:
|
||||
attr1: int = 0
|
||||
attr2: int
|
||||
attr3 = 0 # type: int
|
||||
|
||||
descr4: int = _Descriptor("descr4")
|
||||
|
||||
def __init__(self):
|
||||
self.attr4: int = 0 #: attr4
|
||||
self.attr5: int #: attr5
|
||||
|
||||
@@ -1518,6 +1518,13 @@ def test_autodoc_typed_instance_variables(app):
|
||||
' attr6',
|
||||
'',
|
||||
'',
|
||||
' .. py:attribute:: Class.descr4',
|
||||
' :module: target.typed_vars',
|
||||
' :type: int',
|
||||
'',
|
||||
' This is descr4',
|
||||
'',
|
||||
'',
|
||||
'.. py:data:: attr1',
|
||||
' :module: target.typed_vars',
|
||||
' :type: str',
|
||||
|
||||
Reference in new issue
Block a user