* add test and code comment for pull request #157

This commit is contained in:
Takayuki Shimizukawa 2014-06-14 17:03:57 +09:00
parent 2274bfc38b
commit 0fb938ad38
3 changed files with 53 additions and 1 deletions

View File

@ -149,6 +149,8 @@ Bugs fixed
"variadic templates" declarations. Thanks to Victor Zverovich. "variadic templates" declarations. Thanks to Victor Zverovich.
* #1459,PR#244: Fix default mathjax js path point to `http://` that cause * #1459,PR#244: Fix default mathjax js path point to `http://` that cause
mixed-content error on HTTPS server. Thanks to sbrandtb and robo9k. mixed-content error on HTTPS server. Thanks to sbrandtb and robo9k.
* PR#157: autodoc remove spurious signatures from @property decorated
attributes. Thanks to David Ham.
Documentation Documentation
------------- -------------

View File

@ -982,7 +982,10 @@ class DocstringStripSignatureMixin(DocstringSignatureMixin):
# the feature is enabled # the feature is enabled
result = self._find_signature() result = self._find_signature()
if result is not None: if result is not None:
self.retann = result[1] # Discarding _args is a only difference with
# DocstringSignatureMixin.format_signature.
# Documenter.format_signature use self.args value to format.
_args, self.retann = result
return Documenter.format_signature(self) return Documenter.format_signature(self)

View File

@ -415,6 +415,39 @@ def test_docstring_processing():
app.disconnect(lid) app.disconnect(lid)
@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) @with_setup(setup_test)
def test_new_documenter(): def test_new_documenter():
class MyDocumenter(ModuleLevelDocumenter): class MyDocumenter(ModuleLevelDocumenter):
@ -873,6 +906,20 @@ First line of docstring
indented line 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): class StrRepr(str):
def __repr__(self): def __repr__(self):
return self return self