From a2f6de88c1285b3826a257f02d61b393467c44ed Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 8 Jul 2018 21:14:01 +0900 Subject: [PATCH] Fix #5146: autosummary: warning is emitted when the first line of docstring ends with literal notation --- CHANGES | 2 ++ sphinx/ext/autosummary/__init__.py | 4 ++++ tests/test_ext_autosummary.py | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/CHANGES b/CHANGES index b860e53ed..c1bd68e00 100644 --- a/CHANGES +++ b/CHANGES @@ -33,6 +33,8 @@ Bugs fixed * #5091: latex: curly braces in index entries are not handled correctly * #5070: epub: Wrong internal href fragment links * #5104: apidoc: Interface of ``sphinx.apidoc:main()`` has changed +* #5146: autosummary: warning is emitted when the first line of docstring ends + with literal notation Testing -------- diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py index a1b468a69..733e81ca5 100644 --- a/sphinx/ext/autosummary/__init__.py +++ b/sphinx/ext/autosummary/__init__.py @@ -91,6 +91,7 @@ logger = logging.getLogger(__name__) periods_re = re.compile(r'\.(?:\s+)') +literal_re = re.compile(r'::\s*$') # -- autosummary_toc node ------------------------------------------------------ @@ -484,6 +485,9 @@ def extract_summary(doc, document): # considered as that splitting by period does not break inline markups break + # strip literal notation mark ``::`` from tail of summary + summary = literal_re.sub('.', summary) + return summary diff --git a/tests/test_ext_autosummary.py b/tests/test_ext_autosummary.py index 1138fe4a6..fba0ae33c 100644 --- a/tests/test_ext_autosummary.py +++ b/tests/test_ext_autosummary.py @@ -81,6 +81,10 @@ def test_extract_summary(capsys): doc = ['Blabla, i.e. bla.'] assert extract_summary(doc, document) == 'Blabla, i.e.' + # literal + doc = ['blah blah::'] + assert extract_summary(doc, document) == 'blah blah.' + _, err = capsys.readouterr() assert err == ''