summaryrefslogtreecommitdiff
path: root/tests/test_autodoc.py
diff options
context:
space:
mode:
authorTakayuki Shimizukawa <shimizukawa@gmail.com>2014-06-14 17:03:57 +0900
committerTakayuki Shimizukawa <shimizukawa@gmail.com>2014-06-14 17:03:57 +0900
commit0fb938ad38ef1599085323ac54721daa1ddf661c (patch)
treea9d74c3bdaa613eb297050e535f389d4024e755c /tests/test_autodoc.py
parent2274bfc38bb777c6014733c9edc6022a8373268c (diff)
downloadsphinx-git-0fb938ad38ef1599085323ac54721daa1ddf661c.tar.gz
* add test and code comment for pull request #157
Diffstat (limited to 'tests/test_autodoc.py')
-rw-r--r--tests/test_autodoc.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py
index 06b86568c..d100b5550 100644
--- a/tests/test_autodoc.py
+++ b/tests/test_autodoc.py
@@ -416,6 +416,39 @@ def test_docstring_processing():
@with_setup(setup_test)
+def test_docstring_property_processing():
+ def genarate_docstring(objtype, name, **kw):
+ del processed_docstrings[:]
+ del processed_signatures[:]
+ inst = AutoDirective._registry[objtype](directive, name)
+ inst.generate(**kw)
+ results = list(directive.result)
+ docstrings = inst.get_doc()[0]
+ del directive.result[:]
+ return results, docstrings
+
+ directive.env.config.autodoc_docstring_signature = False
+ results, docstrings = genarate_docstring('attribute', 'test_autodoc.DocstringSig.prop1')
+ assert '.. py:attribute:: DocstringSig.prop1' in results
+ assert 'First line of docstring' in docstrings
+ assert 'DocstringSig.prop1(self)' in docstrings
+ results, docstrings = genarate_docstring('attribute', 'test_autodoc.DocstringSig.prop2')
+ assert '.. py:attribute:: DocstringSig.prop2' in results
+ assert 'First line of docstring' in docstrings
+ assert 'Second line of docstring' in docstrings
+
+ directive.env.config.autodoc_docstring_signature = True
+ results, docstrings = genarate_docstring('attribute', 'test_autodoc.DocstringSig.prop1')
+ assert '.. py:attribute:: DocstringSig.prop1' in results
+ assert 'First line of docstring' in docstrings
+ assert 'DocstringSig.prop1(self)' not in docstrings
+ results, docstrings = genarate_docstring('attribute', 'test_autodoc.DocstringSig.prop2')
+ assert '.. py:attribute:: DocstringSig.prop2' in results
+ assert 'First line of docstring' in docstrings
+ assert 'Second line of docstring' in docstrings
+
+
+@with_setup(setup_test)
def test_new_documenter():
class MyDocumenter(ModuleLevelDocumenter):
objtype = 'integer'
@@ -873,6 +906,20 @@ First line of docstring
indented line
"""
+ @property
+ def prop1(self):
+ """DocstringSig.prop1(self)
+ First line of docstring
+ """
+ return 123
+
+ @property
+ def prop2(self):
+ """First line of docstring
+ Second line of docstring
+ """
+ return 456
+
class StrRepr(str):
def __repr__(self):
return self