diff --git a/CHANGES b/CHANGES index fef9a2113..d5a67ac27 100644 --- a/CHANGES +++ b/CHANGES @@ -33,6 +33,12 @@ 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 +* #5076: napoleon raises RuntimeError with python 3.7 +* #5125: sphinx-build: Interface of ``sphinx:main()`` has changed +* sphinx-build: ``sphinx.cmd.build.main()`` refers ``sys.argv`` instead of given + argument +* #5146: autosummary: warning is emitted when the first line of docstring ends + with literal notation * autosummary: warnings of autosummary indicates wrong location (refs: #5146) Testing diff --git a/sphinx/__init__.py b/sphinx/__init__.py index c81166603..34bd365bc 100644 --- a/sphinx/__init__.py +++ b/sphinx/__init__.py @@ -60,15 +60,15 @@ if __version__.endswith('+'): pass -def main(*args, **kwargs): +def main(argv=sys.argv): from .cmd import build warnings.warn( '`sphinx.main()` has moved to `sphinx.cmd.build.main()`.', RemovedInSphinx20Warning, stacklevel=2, ) - args = args[1:] # skip first argument to adjust arguments (refs: #4615) - return build.main(*args, **kwargs) + argv = argv[1:] # skip first argument to adjust arguments (refs: #4615) + return build.main(argv) def build_main(argv=sys.argv): diff --git a/sphinx/cmd/build.py b/sphinx/cmd/build.py index c0c31ae67..1add951ca 100644 --- a/sphinx/cmd/build.py +++ b/sphinx/cmd/build.py @@ -32,7 +32,7 @@ def make_main(argv=sys.argv[1:]): def main(argv=sys.argv[1:]): # type: (List[str]) -> int - if sys.argv[1:2] == ['-M']: + if argv[:1] == ['-M']: return make_main(argv) else: return build_main(argv) diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py index 84ef340f7..c1c6a9fb0 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 ------------------------------------------------------ @@ -486,6 +487,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/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py index b349c761f..64107d8fb 100644 --- a/sphinx/ext/napoleon/docstring.py +++ b/sphinx/ext/napoleon/docstring.py @@ -527,7 +527,14 @@ class GoogleDocstring(UnicodeMixin): self._parsed_lines = self._consume_empty() if self._name and (self._what == 'attribute' or self._what == 'data'): - self._parsed_lines.extend(self._parse_attribute_docstring()) + # Implicit stop using StopIteration no longer allowed in + # Python 3.7; see PEP 479 + res = [] # type: List[unicode] + try: + res = self._parse_attribute_docstring() + except StopIteration: + pass + self._parsed_lines.extend(res) return while self._line_iter.has_next(): 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 == ''