Fix #4689: autosummary: unexpectedly strips docstrings containing "i.e."

This commit is contained in:
Takeshi KOMIYA
2018-03-01 17:37:16 +09:00
parent 8e0cca01e5
commit fdefe987d5
3 changed files with 9 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ Bugs fixed
* #4685: autosummary emits meaningless warnings
* autodoc: crashed when invalid options given
* pydomain: always strip parenthesis if empty (refs: #1042)
* #4689: autosummary: unexpectedly strips docstrings containing "i.e."
Testing
--------

View File

@@ -90,6 +90,9 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
periods_re = re.compile('\.(?:\s+)')
# -- autosummary_toc node ------------------------------------------------------
class autosummary_toc(nodes.comment):
@@ -466,7 +469,7 @@ def extract_summary(doc, document):
break
# Try to find the "first sentence", which may span multiple lines
sentences = " ".join(doc).split('.')
sentences = periods_re.split(" ".join(doc)) # type: ignore
if len(sentences) == 1:
summary = sentences[0].strip()
else:

View File

@@ -77,6 +77,10 @@ def test_extract_summary(capsys):
'it does not break sentence.']
assert extract_summary(doc, document) == ' '.join(doc)
# abbreviations
doc = ['Blabla, i.e. bla.']
assert extract_summary(doc, document) == 'Blabla, i.e.'
_, err = capsys.readouterr()
assert err == ''