diff options
author | shimizukawa <shimizukawa@gmail.com> | 2014-07-13 11:43:12 +0900 |
---|---|---|
committer | shimizukawa <shimizukawa@gmail.com> | 2014-07-13 11:43:12 +0900 |
commit | 0d0ef6ba440fbaabcf637a8d19af3a8dfe053efc (patch) | |
tree | f05f325d853a6e12a2448ea70a3b2838bec2b485 /tests/test_autodoc.py | |
parent | a632422226137c0fcce4a84f71d9e0ee95a65d0a (diff) | |
parent | 77b701dd73708baa1b2aae70a097fdb5ed64ed70 (diff) | |
download | sphinx-0d0ef6ba440fbaabcf637a8d19af3a8dfe053efc.tar.gz |
merge with stable
Diffstat (limited to 'tests/test_autodoc.py')
-rw-r--r-- | tests/test_autodoc.py | 62 |
1 files changed, 51 insertions, 11 deletions
diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index a7b2cee0..e0d39f09 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -10,13 +10,11 @@ :license: BSD, see LICENSE for details. """ -import sys -from StringIO import StringIO - # "raises" imported for usage by autodoc from util import TestApp, Struct, raises from nose.tools import with_setup +from six import StringIO from docutils.statemachine import ViewList from sphinx.ext.autodoc import AutoDirective, add_documenter, \ @@ -424,6 +422,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' @@ -776,12 +807,8 @@ def _funky_classmethod(name, b, c, d, docstring=None): some arguments.""" def template(cls, a, b, c, d=4, e=5, f=6): return a, b, c, d, e, f - if sys.version_info >= (2, 5): - from functools import partial - function = partial(template, b=b, c=c, d=d) - else: - def function(cls, a, e=5, f=6): - return template(a, b, c, d, e, f) + from functools import partial + function = partial(template, b=b, c=c, d=d) function.__name__ = name function.__doc__ = docstring return classmethod(function) @@ -813,10 +840,9 @@ class Class(Base): #: should be documented -- süß attr = 'bar' + @property def prop(self): """Property.""" - # stay 2.4 compatible (docstring!) - prop = property(prop, doc="Property.") docattr = 'baz' """should likewise be documented -- süß""" @@ -886,6 +912,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 |