Merge branch '1.7' into 5146_wrong_location_for_autosummary_warning

This commit is contained in:
Takeshi KOMIYA 2018-07-13 01:57:57 +09:00 committed by GitHub
commit e222b38d85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 5 deletions

View File

@ -33,6 +33,12 @@ Bugs fixed
* #5091: latex: curly braces in index entries are not handled correctly * #5091: latex: curly braces in index entries are not handled correctly
* #5070: epub: Wrong internal href fragment links * #5070: epub: Wrong internal href fragment links
* #5104: apidoc: Interface of ``sphinx.apidoc:main()`` has changed * #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) * autosummary: warnings of autosummary indicates wrong location (refs: #5146)
Testing Testing

View File

@ -60,15 +60,15 @@ if __version__.endswith('+'):
pass pass
def main(*args, **kwargs): def main(argv=sys.argv):
from .cmd import build from .cmd import build
warnings.warn( warnings.warn(
'`sphinx.main()` has moved to `sphinx.cmd.build.main()`.', '`sphinx.main()` has moved to `sphinx.cmd.build.main()`.',
RemovedInSphinx20Warning, RemovedInSphinx20Warning,
stacklevel=2, stacklevel=2,
) )
args = args[1:] # skip first argument to adjust arguments (refs: #4615) argv = argv[1:] # skip first argument to adjust arguments (refs: #4615)
return build.main(*args, **kwargs) return build.main(argv)
def build_main(argv=sys.argv): def build_main(argv=sys.argv):

View File

@ -32,7 +32,7 @@ def make_main(argv=sys.argv[1:]):
def main(argv=sys.argv[1:]): def main(argv=sys.argv[1:]):
# type: (List[str]) -> int # type: (List[str]) -> int
if sys.argv[1:2] == ['-M']: if argv[:1] == ['-M']:
return make_main(argv) return make_main(argv)
else: else:
return build_main(argv) return build_main(argv)

View File

@ -91,6 +91,7 @@ logger = logging.getLogger(__name__)
periods_re = re.compile(r'\.(?:\s+)') periods_re = re.compile(r'\.(?:\s+)')
literal_re = re.compile(r'::\s*$')
# -- autosummary_toc node ------------------------------------------------------ # -- autosummary_toc node ------------------------------------------------------
@ -486,6 +487,9 @@ def extract_summary(doc, document):
# considered as that splitting by period does not break inline markups # considered as that splitting by period does not break inline markups
break break
# strip literal notation mark ``::`` from tail of summary
summary = literal_re.sub('.', summary)
return summary return summary

View File

@ -527,7 +527,14 @@ class GoogleDocstring(UnicodeMixin):
self._parsed_lines = self._consume_empty() self._parsed_lines = self._consume_empty()
if self._name and (self._what == 'attribute' or self._what == 'data'): 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 return
while self._line_iter.has_next(): while self._line_iter.has_next():

View File

@ -81,6 +81,10 @@ def test_extract_summary(capsys):
doc = ['Blabla, i.e. bla.'] doc = ['Blabla, i.e. bla.']
assert extract_summary(doc, document) == 'Blabla, i.e.' assert extract_summary(doc, document) == 'Blabla, i.e.'
# literal
doc = ['blah blah::']
assert extract_summary(doc, document) == 'blah blah.'
_, err = capsys.readouterr() _, err = capsys.readouterr()
assert err == '' assert err == ''