mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #4696 from tk0miya/4685_autosummary_warning
Fix #4685: autosummary emits meaningless warnings
This commit is contained in:
commit
3efadc63cc
1
CHANGES
1
CHANGES
@ -17,6 +17,7 @@ Bugs fixed
|
||||
----------
|
||||
|
||||
* #4669: sphinx.build_main and sphinx.make_main throw NameError
|
||||
* #4685: autosummary emits meaningless warnings
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user