Merge pull request #4696 from tk0miya/4685_autosummary_warning

Fix #4685: autosummary emits meaningless warnings
This commit is contained in:
Takeshi KOMIYA 2018-03-03 01:34:30 +09:00 committed by GitHub
commit 3efadc63cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 2 deletions

View File

@ -17,6 +17,7 @@ Bugs fixed
----------
* #4669: sphinx.build_main and sphinx.make_main throw NameError
* #4685: autosummary emits meaningless warnings
Testing
--------

View File

@ -78,7 +78,7 @@ from sphinx.ext.autodoc.directive import DocumenterBridge, Options
from sphinx.ext.autodoc.importer import import_module
from sphinx.pycode import ModuleAnalyzer, PycodeError
from sphinx.util import import_object, rst, logging
from sphinx.util.docutils import new_document
from sphinx.util.docutils import NullReporter, new_document
if TYPE_CHECKING:
from typing import Any, Dict, List, Tuple, Type, Union # NOQA
@ -475,6 +475,7 @@ def extract_summary(doc, document):
while sentences:
summary += sentences.pop(0) + '.'
node = new_document('', document.settings)
node.reporter = NullReporter()
state_machine.run([summary], node)
if not node.traverse(nodes.system_message):
# considered as that splitting by period does not break inline markups

View File

@ -185,6 +185,14 @@ class LoggingReporter(Reporter):
stream, debug, error_handler=error_handler)
class NullReporter(Reporter):
"""A dummy reporter; write nothing."""
def __init__(self):
# type: () -> None
Reporter.__init__(self, '', 999, 4)
def is_html5_writer_available():
# type: () -> bool
return __version_info__ > (0, 13, 0)

View File

@ -55,7 +55,7 @@ def test_mangle_signature():
assert res == outp, (u"'%s' -> '%s' != '%s'" % (inp, res, outp))
def test_extract_summary():
def test_extract_summary(capsys):
from sphinx.util.docutils import new_document
from mock import Mock
settings = Mock(language_code='',
@ -77,6 +77,9 @@ def test_extract_summary():
'it does not break sentence.']
assert extract_summary(doc, document) == ' '.join(doc)
_, err = capsys.readouterr()
assert err == ''
@pytest.mark.sphinx('dummy', **default_kw)
def test_get_items_summary(make_app, app_params):