mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Test for bug #2298: automodule fails to document a class attribute
This test case demonstrates a bug, where automodule:: with option :members: fails to document a class attribute of a class, that was imported into the documented module. This commit extends test_ext_viewcode, instead of creating a separate test module, because the development guide recommends it for performance reasons.
This commit is contained in:
parent
50951bdc98
commit
de356149cd
@ -28,6 +28,11 @@ viewcode
|
||||
:language: python
|
||||
:pyobject: func1
|
||||
|
||||
.. autoclass:: spam.mod3.Class3
|
||||
:members:
|
||||
|
||||
.. automodule:: spam.mod3
|
||||
:members:
|
||||
|
||||
.. toctree::
|
||||
|
||||
|
@ -13,3 +13,10 @@ class Class1(object):
|
||||
"""
|
||||
this is Class1
|
||||
"""
|
||||
|
||||
class Class3(object):
|
||||
"""
|
||||
this is Class3
|
||||
"""
|
||||
class_attr = 42
|
||||
"""this is the class attribute class_attr"""
|
||||
|
2
tests/roots/test-ext-viewcode/spam/mod3.py
Normal file
2
tests/roots/test-ext-viewcode/spam/mod3.py
Normal file
@ -0,0 +1,2 @@
|
||||
from spam.mod1 import Class3
|
||||
__all__ = ('Class3',)
|
@ -31,6 +31,12 @@ def test_viewcode(app, status, warning):
|
||||
assert result.count('href="_modules/spam/mod1.html#Class1"') == 2
|
||||
assert result.count('href="_modules/spam/mod2.html#Class2"') == 2
|
||||
|
||||
# test that the class attribute is correctly documented
|
||||
assert result.count('this is Class3') == 2
|
||||
assert 'this is the class attribute class_attr' in result
|
||||
# the next assert fails, until the autodoc bug gets fixed
|
||||
assert result.count('this is the class attribute class_attr') == 2
|
||||
|
||||
|
||||
@with_app(testroot='ext-viewcode', tags=['test_linkcode'])
|
||||
def test_linkcode(app, status, warning):
|
||||
|
Loading…
Reference in New Issue
Block a user