From d210da96f69b7fba198bfdd248a4c71abcabb660 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 16 Dec 2018 13:37:47 -0800 Subject: [PATCH 1/3] Fix invalid escape sequence in test_directive_code.py Fixes error when running tests: tests/test_directive_code.py:359 sphinx/tests/test_directive_code.py:359: DeprecationWarning: invalid escape sequence \s includes = '\\end{sphinxVerbatim}\n\sphinxresetverbatimhllines\n' --- tests/test_directive_code.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_directive_code.py b/tests/test_directive_code.py index 34e3e525c..43d9ff99c 100644 --- a/tests/test_directive_code.py +++ b/tests/test_directive_code.py @@ -356,7 +356,7 @@ def test_code_block_emphasize_latex(app, status, warning): latex = (app.outdir / 'Python.tex').text(encoding='utf-8').replace('\r\n', '\n') includes = '\\fvset{hllines={, 5, 6, 13, 14, 15, 24, 25, 26, 27,}}%\n' assert includes in latex - includes = '\\end{sphinxVerbatim}\n\sphinxresetverbatimhllines\n' + includes = '\\end{sphinxVerbatim}\n\\sphinxresetverbatimhllines\n' assert includes in latex From c4baa7234e5a8dac57c2929dac8f809e35c830ca Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 16 Dec 2018 13:32:00 -0800 Subject: [PATCH 2/3] Deprecate the old IndexBuilder.feed() method signature The method signature changed in commit d27386cc95772a7e7cc47941a0c08b27e0272f67 (Jun 8, 2016). --- CHANGES | 2 ++ doc/extdev/index.rst | 6 ++++++ sphinx/builders/html.py | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 5ae30ab92..205b89927 100644 --- a/CHANGES +++ b/CHANGES @@ -51,6 +51,8 @@ Deprecated is_meta_keywords()`` * The ``suffix`` argument of ``env.doc2path()`` is deprecated. * The string style ``base`` argument of ``env.doc2path()`` is deprecated. +* The fallback to allow omitting the ``filename`` argument from an overridden + ``IndexBuilder.feed()`` method is deprecated. * ``sphinx.addnodes.abbreviation`` * ``sphinx.application.Sphinx._setting_up_extension`` * ``sphinx.config.check_unicode()`` diff --git a/doc/extdev/index.rst b/doc/extdev/index.rst index 3dc3cf5e6..0128872ed 100644 --- a/doc/extdev/index.rst +++ b/doc/extdev/index.rst @@ -237,6 +237,12 @@ The following is a list of deprecated interfaces. - 4.0 - N/A + * - Omitting the ``filename`` argument in an overriddent + ``IndexBuilder.feed()`` method. + - 2.0 + - 4.0 + - ``IndexBuilder.feed(docname, filename, title, doctree)`` + * - ``sphinx.writers.latex.LaTeXTranslator.babel_defmacro()`` - 2.0 - 4.0 diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 175820116..2f9a8b976 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -32,7 +32,7 @@ from sphinx import package_dir, __display_version__ from sphinx.application import ENV_PICKLE_FILENAME from sphinx.builders import Builder from sphinx.config import string_classes -from sphinx.deprecation import RemovedInSphinx30Warning +from sphinx.deprecation import RemovedInSphinx30Warning, RemovedInSphinx40Warning from sphinx.environment.adapters.asset import ImageAdapter from sphinx.environment.adapters.indexentries import IndexEntries from sphinx.environment.adapters.toctree import TocTree @@ -977,6 +977,12 @@ class StandaloneHTMLBuilder(Builder): except TypeError: # fallback for old search-adapters self.indexer.feed(pagename, title, doctree) # type: ignore + indexer_name = self.indexer.__class__.__name__ + warnings.warn( + 'The %s.feed() method signature is deprecated. Update to ' + '%s.feed(docname, filename, title, doctree).' % ( + indexer_name, indexer_name), + RemovedInSphinx40Warning) def _get_local_toctree(self, docname, collapse=True, **kwds): # type: (str, bool, Any) -> str From 90b44f4d8620639ac142028daaf67124d8c80902 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 16 Dec 2018 15:01:43 -0800 Subject: [PATCH 3/3] Remove Python 2 monkey patch for Unicode ugettext In Python 3, gettext always returns a Unicode text string. --- sphinx/locale/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py index 9e78879d0..42b8d06c0 100644 --- a/sphinx/locale/__init__.py +++ b/sphinx/locale/__init__.py @@ -190,8 +190,6 @@ def init(locale_dirs, language, catalog='sphinx', namespace='general'): translator = NullTranslations() has_translation = False translators[(namespace, catalog)] = translator - if hasattr(translator, 'ugettext'): - translator.gettext = translator.ugettext # type: ignore return translator, has_translation