diff options
author | Jon Waltman <jonathan.waltman@gmail.com> | 2012-11-08 21:19:47 -0600 |
---|---|---|
committer | Jon Waltman <jonathan.waltman@gmail.com> | 2012-11-08 21:19:47 -0600 |
commit | 756b3be391b3d831b979db6cfaab1cf491ba3cac (patch) | |
tree | e4ddcf1a388b5503a9f1ad4bf8e8c6ac44e30d10 /tests | |
parent | 31e79621182adf735cbbd3929aed708fbd34a7bd (diff) | |
download | sphinx-756b3be391b3d831b979db6cfaab1cf491ba3cac.tar.gz |
autodoc: Handle explicit instance attributes in :members: (re #904)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/root/autodoc.txt | 13 | ||||
-rw-r--r-- | tests/test_autodoc.py | 45 |
2 files changed, 58 insertions, 0 deletions
diff --git a/tests/root/autodoc.txt b/tests/root/autodoc.txt index 5c03f947..d4b3404c 100644 --- a/tests/root/autodoc.txt +++ b/tests/root/autodoc.txt @@ -32,3 +32,16 @@ Just testing a few autodoc possibilities... :noindex: .. autoclass:: MarkupError + + +.. currentmodule:: test_autodoc + +.. autoclass:: InstAttCls + :members: + + All members (5 total) + +.. autoclass:: InstAttCls + :members: ca1, ia1 + + Specific members (2 total) diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 6dedaad8..642b9141 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -540,6 +540,32 @@ def test_generate(): assert_result_contains( ' :annotation: = None', 'attribute', 'AttCls.a2') + # test explicit members with instance attributes + del directive.env.temp_data['autodoc:class'] + del directive.env.temp_data['autodoc:module'] + directive.env.temp_data['py:module'] = 'test_autodoc' + options.inherited_members = False + options.undoc_members = False + options.members = ALL + assert_processes([ + ('class', 'test_autodoc.InstAttCls'), + ('attribute', 'test_autodoc.InstAttCls.ca1'), + ('attribute', 'test_autodoc.InstAttCls.ca2'), + ('attribute', 'test_autodoc.InstAttCls.ca3'), + ('attribute', 'test_autodoc.InstAttCls.ia1'), + ('attribute', 'test_autodoc.InstAttCls.ia2'), + ], 'class', 'InstAttCls') + del directive.env.temp_data['autodoc:class'] + del directive.env.temp_data['autodoc:module'] + options.members = ['ca1', 'ia1'] + assert_processes([ + ('class', 'test_autodoc.InstAttCls'), + ('attribute', 'test_autodoc.InstAttCls.ca1'), + ('attribute', 'test_autodoc.InstAttCls.ia1'), + ], 'class', 'InstAttCls') + del directive.env.temp_data['autodoc:class'] + del directive.env.temp_data['autodoc:module'] + del directive.env.temp_data['py:module'] # --- generate fodder ------------ @@ -680,3 +706,22 @@ class StrRepr(str): class AttCls(object): a1 = StrRepr('hello\nworld') a2 = None + +class InstAttCls(object): + """Class with documented class and instance attributes.""" + + #: Doc comment for class attribute InstAttCls.ca1. + #: It can have multiple lines. + ca1 = 'a' + + ca2 = 'b' #: Doc comment for InstAttCls.ca2. One line only. + + ca3 = 'c' + """Docstring for class attribute InstAttCls.ca3.""" + + def __init__(self): + #: Doc comment for instance attribute InstAttCls.ia1 + self.ia1 = 'd' + + self.ia2 = 'e' + """Docstring for instance attribute InstAttCls.ia2.""" |