From 3a19adb976393dc4066def880d0db11e2f7378d7 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 15 Dec 2013 14:16:53 +0900 Subject: Drop python-2.5 and remove 2.4,2.5 support codes --- tests/test_autodoc.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'tests/test_autodoc.py') diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 63c341f1..7e60c5fb 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -737,12 +737,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) @@ -774,10 +770,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üß""" -- cgit v1.2.1 From fb6c6f5bfe4379c6e680a9757c84b7eebc8443d3 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Mon, 20 Jan 2014 11:54:51 -0500 Subject: Fix an exception introduced by b69b59480cba for __init__ with no docstring. --- tests/test_autodoc.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/test_autodoc.py') diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 82eb0f71..3d30d0dd 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -348,6 +348,22 @@ def test_get_doc(): directive.env.config.autoclass_content = 'both' assert getdocl('class', F) == ['Class docstring'] + # class has __init__ method with no docstring + class G(object): + """Class docstring""" + def __init__(self): + pass + + # docstring in the __init__ method of base class will not be used + for f in (False, True): + directive.env.config.autodoc_docstring_signature = f + directive.env.config.autoclass_content = 'class' + assert getdocl('class', G) == ['Class docstring'] + directive.env.config.autoclass_content = 'init' + assert getdocl('class', G) == ['Class docstring'] + directive.env.config.autoclass_content = 'both' + assert getdocl('class', G) == ['Class docstring'] + @with_setup(setup_test) def test_docstring_processing(): -- cgit v1.2.1 From 5e9df0d136140d5b2aba94319ecba7ec541c7446 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Tue, 29 Apr 2014 11:46:47 +0900 Subject: introduce the six module and reduce sphinx.util.pycompat implementation. refs #1350. --- tests/test_autodoc.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tests/test_autodoc.py') diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 30de8790..7b6c017e 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 +import six from docutils.statemachine import ViewList from sphinx.ext.autodoc import AutoDirective, add_documenter, \ @@ -811,7 +809,7 @@ class Class(Base): u"""should be documented as well - süß""" # initialized to any class imported from another module - mdocattr = StringIO() + mdocattr = six.StringIO() """should be documented as well - süß""" roger = _funky_classmethod("roger", 2, 3, 4) -- cgit v1.2.1 From 222ea07f270e7ae292cbe7a9a364f721aa494258 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Wed, 30 Apr 2014 21:30:46 +0900 Subject: remove 'six' name except importing line. --- tests/test_autodoc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_autodoc.py') diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 7b6c017e..b85aee78 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -14,7 +14,7 @@ from util import TestApp, Struct, raises from nose.tools import with_setup -import six +from six import StringIO from docutils.statemachine import ViewList from sphinx.ext.autodoc import AutoDirective, add_documenter, \ @@ -809,7 +809,7 @@ class Class(Base): u"""should be documented as well - süß""" # initialized to any class imported from another module - mdocattr = six.StringIO() + mdocattr = StringIO() """should be documented as well - süß""" roger = _funky_classmethod("roger", 2, 3, 4) -- cgit v1.2.1 From d96e615c53369170745422ae853ff901ea782945 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sat, 14 Jun 2014 17:03:57 +0900 Subject: * add test and code comment for pull request #157 --- tests/test_autodoc.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'tests/test_autodoc.py') diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 06b86568..d100b555 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -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 -- cgit v1.2.1