summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Bell <peterbell10@live.co.uk>2020-07-16 15:48:51 +0100
committerPeter Bell <peterbell10@live.co.uk>2020-07-16 15:48:51 +0100
commit00002397764b391b0ebf737bbe47202ed4c98fff (patch)
tree1c4378850ab1461ac189e0690aceb88e59c44a04
parentea0fbd21d5e0c498cf13e338a1ed3dd64d15d4f3 (diff)
downloadsphinx-git-00002397764b391b0ebf737bbe47202ed4c98fff.tar.gz
Preserve backwards compatibility
-rw-r--r--sphinx/builders/applehelp.py20
-rw-r--r--sphinx/builders/devhelp.py8
-rw-r--r--sphinx/builders/dirhtml.py8
-rw-r--r--sphinx/builders/htmlhelp.py21
-rw-r--r--sphinx/builders/qthelp.py10
-rw-r--r--sphinx/builders/singlehtml.py10
-rw-r--r--sphinx/deprecation.py59
-rw-r--r--sphinx/directives/__init__.py65
-rw-r--r--sphinx/directives/other.py7
-rw-r--r--sphinx/ext/apidoc.py12
-rw-r--r--sphinx/ext/autodoc/importer.py19
-rw-r--r--sphinx/ext/imgmath.py16
-rw-r--r--sphinx/io.py11
-rw-r--r--sphinx/transforms/__init__.py16
-rw-r--r--sphinx/util/pycompat.py28
-rw-r--r--sphinx/util/texescape.py14
-rw-r--r--sphinx/writers/latex.py49
17 files changed, 204 insertions, 169 deletions
diff --git a/sphinx/builders/applehelp.py b/sphinx/builders/applehelp.py
index 1e7fb870b..82a74f4b6 100644
--- a/sphinx/builders/applehelp.py
+++ b/sphinx/builders/applehelp.py
@@ -23,16 +23,18 @@ from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
deprecated_alias('sphinx.builders.applehelp',
{
- 'AppleHelpCodeSigningFailed': (
- 'sphinxcontrib.applehelp.AppleHelpCodeSigningFailed',
- AppleHelpCodeSigningFailed),
- 'AppleHelpIndexerFailed': (
- 'sphinxcontrib.applehelp.AppleHelpIndexerFailed',
- AppleHelpIndexerFailed),
- 'AppleHelpBuilder': (
- 'sphinxcontrib.applehelp.AppleHelpBuilder', AppleHelpBuilder),
+ 'AppleHelpCodeSigningFailed': AppleHelpCodeSigningFailed,
+ 'AppleHelpIndexerFailed': AppleHelpIndexerFailed,
+ 'AppleHelpBuilder': AppleHelpBuilder,
},
- RemovedInSphinx40Warning)
+ RemovedInSphinx40Warning,
+ {
+ 'AppleHelpCodeSigningFailed':
+ 'sphinxcontrib.applehelp.AppleHelpCodeSigningFailed',
+ 'AppleHelpIndexerFailed':
+ 'sphinxcontrib.applehelp.AppleHelpIndexerFailed',
+ 'AppleHelpBuilder': 'sphinxcontrib.applehelp.AppleHelpBuilder',
+ })
def setup(app: Sphinx) -> Dict[str, Any]:
diff --git a/sphinx/builders/devhelp.py b/sphinx/builders/devhelp.py
index 4f019b4a0..3e402690a 100644
--- a/sphinx/builders/devhelp.py
+++ b/sphinx/builders/devhelp.py
@@ -21,10 +21,12 @@ from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
deprecated_alias('sphinx.builders.devhelp',
{
- 'DevhelpBuilder': (
- 'sphinxcontrib.devhelp.DevhelpBuilder', DevhelpBuilder),
+ 'DevhelpBuilder': DevhelpBuilder,
},
- RemovedInSphinx40Warning)
+ RemovedInSphinx40Warning,
+ {
+ 'DevhelpBuilder': 'sphinxcontrib.devhelp.DevhelpBuilder'
+ })
def setup(app: Sphinx) -> Dict[str, Any]:
diff --git a/sphinx/builders/dirhtml.py b/sphinx/builders/dirhtml.py
index b0c9d5a90..6fab8cf82 100644
--- a/sphinx/builders/dirhtml.py
+++ b/sphinx/builders/dirhtml.py
@@ -49,10 +49,12 @@ class DirectoryHTMLBuilder(StandaloneHTMLBuilder):
# for compatibility
deprecated_alias('sphinx.builders.html',
{
- 'DirectoryHTMLBuilder': (
- 'sphinx.builders.dirhtml.DirectoryHTMLBuilder', DirectoryHTMLBuilder),
+ 'DirectoryHTMLBuilder': DirectoryHTMLBuilder,
},
- RemovedInSphinx40Warning)
+ RemovedInSphinx40Warning,
+ {
+ 'DirectoryHTMLBuilder': 'sphinx.builders.dirhtml.DirectoryHTMLBuilder',
+ })
def setup(app: Sphinx) -> Dict[str, Any]:
diff --git a/sphinx/builders/htmlhelp.py b/sphinx/builders/htmlhelp.py
index a8f891087..d30f9805a 100644
--- a/sphinx/builders/htmlhelp.py
+++ b/sphinx/builders/htmlhelp.py
@@ -22,16 +22,19 @@ from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
deprecated_alias('sphinx.builders.htmlhelp',
{
- 'chm_locales': ('sphinxcontrib.htmlhelp.chm_locales', chm_locales),
- 'chm_htmlescape': (
- 'sphinxcontrib.htmlhelp.chm_htmlescape', chm_htmlescape),
- 'HTMLHelpBuilder': (
- 'sphinxcontrib.htmlhelp.HTMLHelpBuilder', HTMLHelpBuilder),
- 'default_htmlhelp_basename': (
- 'sphinxcontrib.htmlhelp.default_htmlhelp_basename',
- default_htmlhelp_basename),
+ 'chm_locales': chm_locales,
+ 'chm_htmlescape': chm_htmlescape,
+ 'HTMLHelpBuilder': HTMLHelpBuilder,
+ 'default_htmlhelp_basename': default_htmlhelp_basename,
},
- RemovedInSphinx40Warning)
+ RemovedInSphinx40Warning,
+ {
+ 'chm_locales': 'sphinxcontrib.htmlhelp.chm_locales',
+ 'chm_htmlescape': 'sphinxcontrib.htmlhelp.chm_htmlescape',
+ 'HTMLHelpBuilder': 'sphinxcontrib.htmlhelp.HTMLHelpBuilder',
+ 'default_htmlhelp_basename':
+ 'sphinxcontrib.htmlhelp.default_htmlhelp_basename',
+ })
def setup(app: Sphinx) -> Dict[str, Any]:
diff --git a/sphinx/builders/qthelp.py b/sphinx/builders/qthelp.py
index a2e130a63..cec4d338e 100644
--- a/sphinx/builders/qthelp.py
+++ b/sphinx/builders/qthelp.py
@@ -20,10 +20,14 @@ from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
deprecated_alias('sphinx.builders.qthelp',
{
- 'render_file': ('sphinxcontrib.qthelp.render_file', render_file),
- 'QtHelpBuilder': ('sphinxcontrib.qthelp.QtHelpBuilder', QtHelpBuilder),
+ 'render_file': render_file,
+ 'QtHelpBuilder': QtHelpBuilder,
},
- RemovedInSphinx40Warning)
+ RemovedInSphinx40Warning,
+ {
+ 'render_file': 'sphinxcontrib.qthelp.render_file',
+ 'QtHelpBuilder': 'sphinxcontrib.qthelp.QtHelpBuilder',
+ })
def setup(app: Sphinx) -> Dict[str, Any]:
diff --git a/sphinx/builders/singlehtml.py b/sphinx/builders/singlehtml.py
index dff84c510..df90b4c73 100644
--- a/sphinx/builders/singlehtml.py
+++ b/sphinx/builders/singlehtml.py
@@ -191,11 +191,13 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
# for compatibility
deprecated_alias('sphinx.builders.html',
{
- 'SingleFileHTMLBuilder': (
- 'sphinx.builders.singlehtml.SingleFileHTMLBuilder',
- SingleFileHTMLBuilder),
+ 'SingleFileHTMLBuilder': SingleFileHTMLBuilder,
},
- RemovedInSphinx40Warning)
+ RemovedInSphinx40Warning,
+ {
+ 'SingleFileHTMLBuilder':
+ 'sphinx.builders.singlehtml.SingleFileHTMLBuilder',
+ })
def setup(app: Sphinx) -> Dict[str, Any]:
diff --git a/sphinx/deprecation.py b/sphinx/deprecation.py
index 5baac8cf5..48db97760 100644
--- a/sphinx/deprecation.py
+++ b/sphinx/deprecation.py
@@ -11,7 +11,7 @@
import sys
import warnings
from importlib import import_module
-from typing import Any, Dict, Tuple
+from typing import Any, Dict
if False:
# For type annotation
@@ -29,62 +29,39 @@ class RemovedInSphinx50Warning(PendingDeprecationWarning):
RemovedInNextVersionWarning = RemovedInSphinx40Warning
-def deprecated_alias(modname: str, objects: Dict[str, Tuple[str, object]],
- warning: "Type[Warning]") -> None:
+def deprecated_alias(modname: str, objects: Dict[str, object],
+ warning: "Type[Warning]", names: Dict[str, str] = None) -> None:
module = import_module(modname)
- sys.modules[modname] = _ModuleWrapperDeprecatedAlias( # type: ignore
- module, modname, objects, warning)
+ sys.modules[modname] = _ModuleWrapper( # type: ignore
+ module, modname, objects, warning, names)
-class _ModuleWrapperDeprecatedAlias:
+class _ModuleWrapper:
def __init__(self, module: Any, modname: str,
- aliases: Dict[str, Tuple[str, object]],
- warning: "Type[Warning]") -> None:
- if not all(isinstance(v, tuple) for v in aliases.values()):
- raise TypeError('deprecated_alias expects aliases to be a dict mapping: '
- 'name -> tuple[canonical name, object]')
-
+ objects: Dict[str, object],
+ warning: "Type[Warning]",
+ names: Dict[str, str]) -> None:
self._module = module
self._modname = modname
- self._aliases = aliases
+ self._objects = objects
self._warning = warning
+ self._names = names
def __getattr__(self, name: str) -> Any:
- if name in self._aliases:
- canonical_name, obj = self._aliases[name]
+ if name not in self._objects:
+ return getattr(self._module, name)
+
+ canonical_name = self._names.get(name, None)
+ if canonical_name is not None:
warnings.warn(
"The alias '{}.{}' is deprecated, use '{}' instead. Check CHANGES for "
"Sphinx API modifications.".format(self._modname, name, canonical_name),
self._warning, stacklevel=3)
- return obj
-
- return getattr(self._module, name)
-
-
-def deprecated_attribute(modname: str, objects: Dict[str, object],
- warning: "Type[Warning]") -> None:
- module = import_module(modname)
- sys.modules[modname] = _ModuleWrapperDeprecatedAttr( # type: ignore
- module, modname, objects, warning)
-
-
-class _ModuleWrapperDeprecatedAttr:
- def __init__(self, module: Any, modname: str,
- objects: Dict[str, object],
- warning: "Type[Warning]") -> None:
- self._module = module
- self._modname = modname
- self._objects = objects
- self._warning = warning
-
- def __getattr__(self, name: str) -> Any:
- if name in self._objects:
+ else:
warnings.warn("{}.{} is deprecated. Check CHANGES for Sphinx "
"API modifications.".format(self._modname, name),
self._warning, stacklevel=3)
- return self._objects[name]
-
- return getattr(self._module, name)
+ return self._objects[name]
class DeprecatedDict(dict):
diff --git a/sphinx/directives/__init__.py b/sphinx/directives/__init__.py
index 7dbdcccef..e6313ddab 100644
--- a/sphinx/directives/__init__.py
+++ b/sphinx/directives/__init__.py
@@ -280,34 +280,53 @@ from sphinx.domains.index import IndexDirective # noqa
deprecated_alias('sphinx.directives',
{
- 'Highlight': ('sphinx.directives.code.Highlight', Highlight),
- 'CodeBlock': ('sphinx.directives.code.CodeBlock', CodeBlock),
- 'LiteralInclude': (
- 'sphinx.directives.code.LiteralInclude', LiteralInclude),
- 'TocTree': ('sphinx.directives.other.TocTree', TocTree),
- 'Author': ('sphinx.directives.other.Author', Author),
- 'Index': ('sphinx.directives.other.IndexDirective', IndexDirective),
- 'VersionChange': ('sphinx.directives.other.VersionChange', VersionChange),
- 'SeeAlso': ('sphinx.directives.other.SeeAlso', SeeAlso),
- 'TabularColumns': (
- 'sphinx.directives.other.TabularColumns', TabularColumns),
- 'Centered': ('sphinx.directives.other.Centered', Centered),
- 'Acks': ('sphinx.directives.other.Acks', Acks),
- 'HList': ('sphinx.directives.other.HList', HList),
- 'Only': ('sphinx.directives.other.Only', Only),
- 'Include': ('sphinx.directives.other.Include', Include),
- 'Class': ('sphinx.directives.other.Class', Class),
- 'Figure': ('sphinx.directives.patches.Figure', Figure),
- 'Meta': ('sphinx.directives.patches.Meta', Meta),
+ 'Highlight': Highlight,
+ 'CodeBlock': CodeBlock,
+ 'LiteralInclude': LiteralInclude,
+ 'TocTree': TocTree,
+ 'Author': Author,
+ 'Index': IndexDirective,
+ 'VersionChange': VersionChange,
+ 'SeeAlso': SeeAlso,
+ 'TabularColumns': TabularColumns,
+ 'Centered': Centered,
+ 'Acks': Acks,
+ 'HList': HList,
+ 'Only': Only,
+ 'Include': Include,
+ 'Class': Class,
+ 'Figure': Figure,
+ 'Meta': Meta,
},
- RemovedInSphinx40Warning)
+ RemovedInSphinx40Warning,
+ {
+ 'Highlight': 'sphinx.directives.code.Highlight',
+ 'CodeBlock': 'sphinx.directives.code.CodeBlock',
+ 'LiteralInclude': 'sphinx.directives.code.LiteralInclude',
+ 'TocTree': 'sphinx.directives.other.TocTree',
+ 'Author': 'sphinx.directives.other.Author',
+ 'Index': 'sphinx.directives.other.IndexDirective',
+ 'VersionChange': 'sphinx.directives.other.VersionChange',
+ 'SeeAlso': 'sphinx.directives.other.SeeAlso',
+ 'TabularColumns': 'sphinx.directives.other.TabularColumns',
+ 'Centered': 'sphinx.directives.other.Centered',
+ 'Acks': 'sphinx.directives.other.Acks',
+ 'HList': 'sphinx.directives.other.HList',
+ 'Only': 'sphinx.directives.other.Only',
+ 'Include': 'sphinx.directives.other.Include',
+ 'Class': 'sphinx.directives.other.Class',
+ 'Figure': 'sphinx.directives.patches.Figure',
+ 'Meta': 'sphinx.directives.patches.Meta',
+ })
deprecated_alias('sphinx.directives',
{
- 'DescDirective': (
- 'sphinx.directives.ObjectDescription', ObjectDescription),
+ 'DescDirective': ObjectDescription,
},
- RemovedInSphinx50Warning)
+ RemovedInSphinx50Warning,
+ {
+ 'DescDirective': 'sphinx.directives.ObjectDescription',
+ })
def setup(app: "Sphinx") -> Dict[str, Any]:
diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py
index bc75ce147..f55f95219 100644
--- a/sphinx/directives/other.py
+++ b/sphinx/directives/other.py
@@ -366,9 +366,12 @@ from sphinx.domains.index import IndexDirective # NOQA
deprecated_alias('sphinx.directives.other',
{
- 'Index': ('sphinx.domains.index.IndexDirective', IndexDirective),
+ 'Index': IndexDirective,
},
- RemovedInSphinx40Warning)
+ RemovedInSphinx40Warning,
+ {
+ 'Index': 'sphinx.domains.index.IndexDirective',
+ })
def setup(app: "Sphinx") -> Dict[str, Any]:
diff --git a/sphinx/ext/apidoc.py b/sphinx/ext/apidoc.py
index 5c2796821..b01604617 100644
--- a/sphinx/ext/apidoc.py
+++ b/sphinx/ext/apidoc.py
@@ -29,7 +29,7 @@ from typing import Any, List, Tuple
import sphinx.locale
from sphinx import __display_version__, package_dir
from sphinx.cmd.quickstart import EXTENSIONS
-from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_attribute
+from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
from sphinx.locale import __
from sphinx.util import rst
from sphinx.util.osutil import FileAvoidWrite, ensuredir
@@ -516,11 +516,11 @@ def main(argv: List[str] = sys.argv[1:]) -> int:
return 0
-deprecated_attribute('sphinx.ext.apidoc',
- {
- 'INITPY': '__init__.py',
- },
- RemovedInSphinx40Warning)
+deprecated_alias('sphinx.ext.apidoc',
+ {
+ 'INITPY': '__init__.py',
+ },
+ RemovedInSphinx40Warning)
# So program can be started with "python -m sphinx.apidoc ..."
diff --git a/sphinx/ext/autodoc/importer.py b/sphinx/ext/autodoc/importer.py
index 04fb39c70..b5d9ab8f6 100644
--- a/sphinx/ext/autodoc/importer.py
+++ b/sphinx/ext/autodoc/importer.py
@@ -188,10 +188,17 @@ from sphinx.ext.autodoc.mock import ( # NOQA
deprecated_alias('sphinx.ext.autodoc.importer',
{
- '_MockModule': ('sphinx.ext.autodoc.mock._MockModule', _MockModule),
- '_MockObject': ('sphinx.ext.autodoc.mock._MockObject', _MockObject),
- 'MockFinder': ('sphinx.ext.autodoc.mock.MockFinder', MockFinder),
- 'MockLoader': ('sphinx.ext.autodoc.mock.MockLoader', MockLoader),
- 'mock': ('sphinx.ext.autodoc.mock.mock', mock),
+ '_MockModule': _MockModule,
+ '_MockObject': _MockObject,
+ 'MockFinder': MockFinder,
+ 'MockLoader': MockLoader,
+ 'mock': mock,
},
- RemovedInSphinx40Warning)
+ RemovedInSphinx40Warning,
+ {
+ '_MockModule': 'sphinx.ext.autodoc.mock._MockModule',
+ '_MockObject': 'sphinx.ext.autodoc.mock._MockObject',
+ 'MockFinder': 'sphinx.ext.autodoc.mock.MockFinder',
+ 'MockLoader': 'sphinx.ext.autodoc.mock.MockLoader',
+ 'mock': 'sphinx.ext.autodoc.mock.mock',
+ })
diff --git a/sphinx/ext/imgmath.py b/sphinx/ext/imgmath.py
index f04eba91b..d11c5d7c5 100644
--- a/sphinx/ext/imgmath.py
+++ b/sphinx/ext/imgmath.py
@@ -26,7 +26,7 @@ from sphinx import package_dir
from sphinx.application import Sphinx
from sphinx.builders import Builder
from sphinx.config import Config
-from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_attribute
+from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
from sphinx.errors import SphinxError
from sphinx.locale import _, __
from sphinx.util import logging, sha1
@@ -370,13 +370,13 @@ def html_visit_displaymath(self: HTMLTranslator, node: nodes.math_block) -> None
raise nodes.SkipNode
-deprecated_attribute('sphinx.ext.imgmath',
- {
- 'DOC_BODY': DOC_BODY,
- 'DOC_BODY_PREVIEW': DOC_BODY_PREVIEW,
- 'DOC_HEAD': DOC_HEAD,
- },
- RemovedInSphinx40Warning)
+deprecated_alias('sphinx.ext.imgmath',
+ {
+ 'DOC_BODY': DOC_BODY,
+ 'DOC_BODY_PREVIEW': DOC_BODY_PREVIEW,
+ 'DOC_HEAD': DOC_HEAD,
+ },
+ RemovedInSphinx40Warning)
def setup(app: Sphinx) -> Dict[str, Any]:
diff --git a/sphinx/io.py b/sphinx/io.py
index d6dd29b1d..fd30b86a9 100644
--- a/sphinx/io.py
+++ b/sphinx/io.py
@@ -226,8 +226,11 @@ def read_doc(app: "Sphinx", env: BuildEnvironment, filename: str) -> nodes.docum
deprecated_alias('sphinx.io',
{
- 'FiletypeNotFoundError': (
- 'sphinx.errors.FiletypeNotFoundError', FiletypeNotFoundError),
- 'get_filetype': ('sphinx.util.get_filetype', get_filetype),
+ 'FiletypeNotFoundError': FiletypeNotFoundError,
+ 'get_filetype': get_filetype,
},
- RemovedInSphinx40Warning)
+ RemovedInSphinx40Warning,
+ {
+ 'FiletypeNotFoundError': 'sphinx.errors.FiletypeNotFoundError',
+ 'get_filetype': 'sphinx.util.get_filetype',
+ })
diff --git a/sphinx/transforms/__init__.py b/sphinx/transforms/__init__.py
index 166ad8916..beb983f2a 100644
--- a/sphinx/transforms/__init__.py
+++ b/sphinx/transforms/__init__.py
@@ -407,14 +407,16 @@ from sphinx.domains.citation import ( # NOQA
deprecated_alias('sphinx.transforms',
{
- 'CitationReferences': (
- 'sphinx.domains.citation.CitationReferenceTransform',
- CitationReferenceTransform),
- 'SmartQuotesSkipper': (
- 'sphinx.domains.citation.CitationDefinitionTransform',
- CitationDefinitionTransform),
+ 'CitationReferences': CitationReferenceTransform,
+ 'SmartQuotesSkipper': CitationDefinitionTransform,
},
- RemovedInSphinx40Warning)
+ RemovedInSphinx40Warning,
+ {
+ 'CitationReferences':
+ 'sphinx.domains.citation.CitationReferenceTransform',
+ 'SmartQuotesSkipper':
+ 'sphinx.domains.citation.CitationDefinitionTransform',
+ })
def setup(app: "Sphinx") -> Dict[str, Any]:
diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py
index 6ec180f0b..50eee5ce3 100644
--- a/sphinx/util/pycompat.py
+++ b/sphinx/util/pycompat.py
@@ -15,8 +15,7 @@ import textwrap
import warnings
from typing import Any, Callable
-from sphinx.deprecation import (
- RemovedInSphinx40Warning, deprecated_alias, deprecated_attribute)
+from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
from sphinx.locale import __
from sphinx.util import logging
from sphinx.util.console import terminal_safe
@@ -92,13 +91,20 @@ def execfile_(filepath: str, _globals: Any, open: Callable = open) -> None:
deprecated_alias('sphinx.util.pycompat',
{
- 'NoneType': ('sphinx.util.typing.NoneType', NoneType),
- 'TextIOWrapper': ('io.TextIOWrapper', io.TextIOWrapper),
- 'htmlescape': ('html.escape', html.escape),
- 'indent': ('textwrap.indent', textwrap.indent),
- 'terminal_safe': ('sphinx.util.console.terminal_safe', terminal_safe),
- 'sys_encoding': ('sys.getdefaultencoding', sys.getdefaultencoding()),
+ 'NoneType': NoneType,
+ 'TextIOWrapper': io.TextIOWrapper,
+ 'htmlescape': html.escape,
+ 'indent': textwrap.indent,
+ 'terminal_safe': terminal_safe,
+ 'sys_encoding': sys.getdefaultencoding(),
+ 'u': '',
},
- RemovedInSphinx40Warning)
-
-deprecated_attribute('sphinx.util.pycompat', {'u': ''}, RemovedInSphinx40Warning)
+ RemovedInSphinx40Warning,
+ {
+ 'NoneType': 'sphinx.util.typing.NoneType',
+ 'TextIOWrapper': 'io.TextIOWrapper',
+ 'htmlescape': 'html.escape',
+ 'indent': 'textwrap.indent',
+ 'terminal_safe': 'sphinx.util.console.terminal_safe',
+ 'sys_encoding': 'sys.getdefaultencoding',
+ })
diff --git a/sphinx/util/texescape.py b/sphinx/util/texescape.py
index a581a4295..afa1c349e 100644
--- a/sphinx/util/texescape.py
+++ b/sphinx/util/texescape.py
@@ -11,7 +11,7 @@
import re
from typing import Dict
-from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_attribute
+from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
tex_replacements = [
@@ -109,12 +109,12 @@ _tex_hlescape_map = {} # type: Dict[int, str]
_tex_hlescape_map_without_unicode = {} # type: Dict[int, str]
-deprecated_attribute('sphinx.util.texescape',
- {
- 'tex_escape_map': _tex_escape_map,
- 'tex_hl_escape_map_new': _tex_hlescape_map,
- },
- RemovedInSphinx40Warning)
+deprecated_alias('sphinx.util.texescape',
+ {
+ 'tex_escape_map': _tex_escape_map,
+ 'tex_hl_escape_map_new': _tex_hlescape_map,
+ },
+ RemovedInSphinx40Warning)
def escape(s: str, latex_engine: str = None) -> str:
diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py
index 22f5f17aa..73a22a76b 100644
--- a/sphinx/writers/latex.py
+++ b/sphinx/writers/latex.py
@@ -2131,30 +2131,33 @@ from sphinx.builders.latex.util import ExtBabel # NOQA
deprecated_alias('sphinx.writers.latex',
{
- 'ADDITIONAL_SETTINGS': (
- 'sphinx.builders.latex.constants.ADDITIONAL_SETTINGS',
- constants.ADDITIONAL_SETTINGS),
- 'DEFAULT_SETTINGS': (
- 'sphinx.builders.latex.constants.DEFAULT_SETTINGS',
- constants.DEFAULT_SETTINGS),
- 'LUALATEX_DEFAULT_FONTPKG': (
- 'sphinx.builders.latex.constants.LUALATEX_DEFAULT_FONTPKG',
- constants.LUALATEX_DEFAULT_FONTPKG),
- 'PDFLATEX_DEFAULT_FONTPKG': (
- 'sphinx.builders.latex.constants.PDFLATEX_DEFAULT_FONTPKG',
- constants.PDFLATEX_DEFAULT_FONTPKG),
- 'SHORTHANDOFF': (
- 'sphinx.builders.latex.constants.SHORTHANDOFF',
- constants.SHORTHANDOFF),
- 'XELATEX_DEFAULT_FONTPKG': (
- 'sphinx.builders.latex.constants.XELATEX_DEFAULT_FONTPKG',
- constants.XELATEX_DEFAULT_FONTPKG),
- 'XELATEX_GREEK_DEFAULT_FONTPKG': (
- 'sphinx.builders.latex.constants.XELATEX_GREEK_DEFAULT_FONTPKG',
- constants.XELATEX_GREEK_DEFAULT_FONTPKG),
- 'ExtBabel': ('sphinx.builders.latex.util.ExtBabel', ExtBabel),
+ 'ADDITIONAL_SETTINGS': constants.ADDITIONAL_SETTINGS,
+ 'DEFAULT_SETTINGS': constants.DEFAULT_SETTINGS,
+ 'LUALATEX_DEFAULT_FONTPKG': constants.LUALATEX_DEFAULT_FONTPKG,
+ 'PDFLATEX_DEFAULT_FONTPKG': constants.PDFLATEX_DEFAULT_FONTPKG,
+ 'SHORTHANDOFF': constants.SHORTHANDOFF,
+ 'XELATEX_DEFAULT_FONTPKG': constants.XELATEX_DEFAULT_FONTPKG,
+ 'XELATEX_GREEK_DEFAULT_FONTPKG': constants.XELATEX_GREEK_DEFAULT_FONTPKG,
+ 'ExtBabel': ExtBabel,
},
- RemovedInSphinx40Warning)
+ RemovedInSphinx40Warning,
+ {
+ 'ADDITIONAL_SETTINGS':
+ 'sphinx.builders.latex.constants.ADDITIONAL_SETTINGS',
+ 'DEFAULT_SETTINGS':
+ 'sphinx.builders.latex.constants.DEFAULT_SETTINGS',
+ 'LUALATEX_DEFAULT_FONTPKG':
+ 'sphinx.builders.latex.constants.LUALATEX_DEFAULT_FONTPKG',
+ 'PDFLATEX_DEFAULT_FONTPKG':
+ 'sphinx.builders.latex.constants.PDFLATEX_DEFAULT_FONTPKG',
+ 'SHORTHANDOFF':
+ 'sphinx.builders.latex.constants.SHORTHANDOFF',
+ 'XELATEX_DEFAULT_FONTPKG':
+ 'sphinx.builders.latex.constants.XELATEX_DEFAULT_FONTPKG',
+ 'XELATEX_GREEK_DEFAULT_FONTPKG':
+ 'sphinx.builders.latex.constants.XELATEX_GREEK_DEFAULT_FONTPKG',
+ 'ExtBabel': 'sphinx.builders.latex.util.ExtBabel',
+ })
# FIXME: Workaround to avoid circular import
# refs: https://github.com/sphinx-doc/sphinx/issues/5433