Skip to content

Commit

Permalink
Fix in sphinx directive: an empty line must separate the original doc…
Browse files Browse the repository at this point in the history
…string and the directive.
  • Loading branch information
tantale committed Feb 12, 2018
1 parent 34bc062 commit 30d6ae2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deprecated/sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __call__(self, wrapped):
for line in reason.splitlines()).strip()
docstring = textwrap.dedent(wrapped.__doc__ or "")
if docstring:
docstring += "\n"
docstring += "\n\n"
if self.version:
docstring += ".. {directive}:: {version}\n".format(directive=self.directive, version=self.version)
else:
Expand Down
13 changes: 10 additions & 3 deletions tests/test_sphinx.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# coding: utf-8
from __future__ import print_function

import re
import sys
import textwrap
import warnings
Expand Down Expand Up @@ -46,9 +47,9 @@ def directive(request):
('A good reason',
None,
textwrap.dedent("""\
.. {directive}::
{reason}
""")),
.. {directive}::
{reason}
""")),
])
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
Expand All @@ -69,6 +70,12 @@ def foo(x, y):
current = textwrap.dedent(foo.__doc__)
assert current.endswith(expected)

# An empty line must separate the original docstring and the directive.
current = current.replace(expected, '')
if current:
assert re.search("\n[ ]*\n$", current, flags=re.DOTALL)



class MyDeprecationWarning(DeprecationWarning):
pass
Expand Down

0 comments on commit 30d6ae2

Please sign in to comment.