mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #8534: autoattribute failed to document a commented attribute in alias class
So far, autoattribute uses "given class name" to fetch comments of uninitialized instance attributes. But pycode expects to use "real" class name on searching attribute comments. This adds UninitializedInstanceAttributeMixin to handle it simply.
This commit is contained in:
@@ -29,3 +29,6 @@ class Class:
|
||||
|
||||
class Derived(Class):
|
||||
attr7: int
|
||||
|
||||
|
||||
Alias = Class
|
||||
|
||||
@@ -1561,6 +1561,11 @@ def test_autodoc_typed_instance_variables(app):
|
||||
'.. py:module:: target.typed_vars',
|
||||
'',
|
||||
'',
|
||||
'.. py:attribute:: Alias',
|
||||
' :module: target.typed_vars',
|
||||
'',
|
||||
' alias of :class:`target.typed_vars.Class`',
|
||||
'',
|
||||
'.. py:class:: Class()',
|
||||
' :module: target.typed_vars',
|
||||
'',
|
||||
|
||||
@@ -57,6 +57,19 @@ def test_autoattribute_typed_variable(app):
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 6), reason='python 3.6+ is required.')
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_typed_variable_in_alias(app):
|
||||
actual = do_autodoc(app, 'attribute', 'target.typed_vars.Alias.attr2')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:attribute:: Alias.attr2',
|
||||
' :module: target.typed_vars',
|
||||
' :type: int',
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 6), reason='python 3.6+ is required.')
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_instance_variable(app):
|
||||
@@ -72,6 +85,21 @@ def test_autoattribute_instance_variable(app):
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 6), reason='python 3.6+ is required.')
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_instance_variable_in_alias(app):
|
||||
actual = do_autodoc(app, 'attribute', 'target.typed_vars.Alias.attr4')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:attribute:: Alias.attr4',
|
||||
' :module: target.typed_vars',
|
||||
' :type: int',
|
||||
'',
|
||||
' attr4',
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_slots_variable_list(app):
|
||||
actual = do_autodoc(app, 'attribute', 'target.slots.Foo.attr')
|
||||
|
||||
Reference in New Issue
Block a user