diff options
| -rw-r--r-- | CHANGES | 3 | ||||
| -rw-r--r-- | sphinx/ext/autodoc.py | 2 | ||||
| -rw-r--r-- | tests/test_autodoc.py | 15 |
3 files changed, 18 insertions, 2 deletions
@@ -1,6 +1,9 @@ Release 0.5.1 (in development) ============================== +* Fix a bug in autodoc when documenting classes with the option. + ``autoclass_content = "both"`` set. + * Don't crash on empty index entries, only emit a warning. * Fix a typo in the search JavaScript code, leading to unusable diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 6d62c23c..bb7af93c 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -244,7 +244,7 @@ class RstGenerator(object): if content == 'init': docstrings = [initdocstring] else: - docstrings.append('\n\n' + initdocstring) + docstrings.append(initdocstring) # the default is only the class docstring # decode the docstrings using the module's source encoding diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index f3920ff0..ee3fdf1d 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -215,11 +215,24 @@ def test_get_doc(): assert getdocl('class', 'C', C) == ['Class docstring', '', 'Init docstring'] class D: + """Class docstring""" + def __init__(self): + """Init docstring + + Other + lines + """ + + # Indentation is normalized for 'both' + assert getdocl('class', 'D', D) == ['Class docstring', '', 'Init docstring', + '', 'Other', ' lines'] + + class E: def __init__(self): """Init docstring""" # docstring processing by event handler - assert getdocl('class', 'bar', D) == ['Init docstring', '', '42'] + assert getdocl('class', 'bar', E) == ['Init docstring', '', '42'] def test_docstring_processing_functions(): |
