mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
* add test and code comment for pull request #157
This commit is contained in:
parent
2274bfc38b
commit
0fb938ad38
2
CHANGES
2
CHANGES
@ -149,6 +149,8 @@ Bugs fixed
|
||||
"variadic templates" declarations. Thanks to Victor Zverovich.
|
||||
* #1459,PR#244: Fix default mathjax js path point to `http://` that cause
|
||||
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
|
||||
-------------
|
||||
|
@ -982,7 +982,10 @@ class DocstringStripSignatureMixin(DocstringSignatureMixin):
|
||||
# the feature is enabled
|
||||
result = self._find_signature()
|
||||
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)
|
||||
|
||||
|
||||
|
@ -415,6 +415,39 @@ def test_docstring_processing():
|
||||
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)
|
||||
def test_new_documenter():
|
||||
class MyDocumenter(ModuleLevelDocumenter):
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user