Skip to content

Commit

Permalink
Merge pull request #5883 from tk0miya/remove_use_of_deprecated_apis
Browse files Browse the repository at this point in the history
Remove use of deprecated APIs
  • Loading branch information
tk0miya authored Jan 3, 2019
2 parents 7b91a24 + a0e1390 commit b04bfcf
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 135 deletions.
6 changes: 4 additions & 2 deletions sphinx/builders/changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ def write(self, *ignored):
libchanges = {} # type: Dict[str, List[Tuple[str, str, int]]]
apichanges = [] # type: List[Tuple[str, str, int]]
otherchanges = {} # type: Dict[Tuple[str, str], List[Tuple[str, str, int]]]
if version not in self.env.versionchanges:

changesets = domain.get_changesets_for(version)
if not changesets:
logger.info(bold(__('no changes in version %s.') % version))
return
logger.info(bold('writing summary file...'))
for changeset in domain.get_changesets_for(version):
for changeset in changesets:
if isinstance(changeset.descname, tuple):
descname = changeset.descname[0]
else:
Expand Down
12 changes: 5 additions & 7 deletions sphinx/ext/autosummary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,9 @@ def run(self):
docname = posixpath.normpath(posixpath.join(dirname, docname))
if docname not in self.env.found_docs:
if excluded(self.env.doc2path(docname, None)):
self.warn('toctree references excluded document %r'
% docname)
logger.warning('toctree references excluded document %r' % docname)
else:
self.warn('toctree references unknown document %r'
% docname)
logger.warning('toctree references unknown document %r' % docname)
docnames.append(docname)

tocnode = addnodes.toctree()
Expand Down Expand Up @@ -290,7 +288,7 @@ def get_items(self, names):
try:
real_name, obj, parent, modname = import_by_name(name, prefixes=prefixes)
except ImportError:
self.warn('failed to import %s' % name)
logger.warning('failed to import %s' % name)
items.append((name, '', '', name))
continue

Expand All @@ -305,11 +303,11 @@ def get_items(self, names):
doccls = get_documenter(self.env.app, obj, parent)
documenter = doccls(self.bridge, full_name)
if not documenter.parse_name():
self.warn('failed to parse name %s' % real_name)
logger.warning('failed to parse name %s' % real_name)
items.append((display_name, '', '', real_name))
continue
if not documenter.import_object():
self.warn('failed to import object %s' % real_name)
logger.warning('failed to import object %s' % real_name)
items.append((display_name, '', '', real_name))
continue
if documenter.options.members and not documenter.check_module():
Expand Down
2 changes: 1 addition & 1 deletion sphinx/testing/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def build(self, *args, **kw):
def remove_unicode_literals(s):
# type: (str) -> str
warnings.warn('remove_unicode_literals() is deprecated.',
RemovedInSphinx40Warning)
RemovedInSphinx40Warning, stacklevel=2)
return _unicode_literals_re.sub(lambda x: x.group(1) or x.group(2), s)


Expand Down
10 changes: 4 additions & 6 deletions tests/test_ext_apidoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import pytest

from sphinx.ext.apidoc import main as apidoc_main
from sphinx.testing.util import remove_unicode_literals


@pytest.fixture()
Expand Down Expand Up @@ -278,11 +277,10 @@ def test_multibyte_parameters(make_app, apidoc):
assert (outdir / 'index.rst').isfile()

conf_py = (outdir / 'conf.py').text()
conf_py_ = remove_unicode_literals(conf_py)
assert "project = 'プロジェクト名'" in conf_py_
assert "author = '著者名'" in conf_py_
assert "version = 'バージョン'" in conf_py_
assert "release = 'リリース'" in conf_py_
assert "project = 'プロジェクト名'" in conf_py
assert "author = '著者名'" in conf_py
assert "version = 'バージョン'" in conf_py
assert "release = 'リリース'" in conf_py

app = make_app('text', srcdir=outdir)
app.build()
Expand Down
118 changes: 0 additions & 118 deletions tests/test_io.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ForgivingLaTeXTranslator(LaTeXTranslator, ForgivingTranslator):
def verify_re_html(app, parse):
def verify(rst, html_expected):
document = parse(rst)
html_translator = ForgivingHTMLTranslator(app.builder, document)
html_translator = ForgivingHTMLTranslator(document, app.builder)
document.walkabout(html_translator)
html_translated = ''.join(html_translator.fragment).strip()
assert re.match(html_expected, html_translated), 'from ' + rst
Expand Down

0 comments on commit b04bfcf

Please sign in to comment.