summaryrefslogtreecommitdiff
path: root/sphinx/builders
diff options
context:
space:
mode:
authorAdam Turner <9087854+AA-Turner@users.noreply.github.com>2023-01-08 00:27:19 +0000
committerGitHub <noreply@github.com>2023-01-08 00:27:19 +0000
commit67291f414e1b259d6b65bc66ea2874c7131e09bf (patch)
tree40b023c4978f4d04df9ba1852bb1a8f0d865643b /sphinx/builders
parentf022db3e8ab195e21ce899283f9c9a4e3b99da6b (diff)
downloadsphinx-git-67291f414e1b259d6b65bc66ea2874c7131e09bf.tar.gz
Replace deprecation tooling with module level ``__getattr__`` (#11054)
Diffstat (limited to 'sphinx/builders')
-rw-r--r--sphinx/builders/html/__init__.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py
index 063d19471..e67934591 100644
--- a/sphinx/builders/html/__init__.py
+++ b/sphinx/builders/html/__init__.py
@@ -26,7 +26,6 @@ from sphinx import version_info as sphinx_version
from sphinx.application import Sphinx
from sphinx.builders import Builder
from sphinx.config import ENUM, Config
-from sphinx.deprecation import RemovedInSphinx70Warning, deprecated_alias
from sphinx.domains import Domain, Index, IndexEntry
from sphinx.environment import BuildEnvironment
from sphinx.environment.adapters.asset import ImageAdapter
@@ -1329,16 +1328,6 @@ import sphinxcontrib.serializinghtml # noqa: E402,F401
import sphinx.builders.dirhtml # noqa: E402,F401,RUF100
import sphinx.builders.singlehtml # noqa: E402,F401
-deprecated_alias('sphinx.builders.html',
- {
- 'html5_ready': True,
- 'HTMLTranslator': HTML4Translator,
- },
- RemovedInSphinx70Warning,
- {
- 'HTMLTranslator': 'sphinx.writers.html.HTML5Translator',
- })
-
def setup(app: Sphinx) -> dict[str, Any]:
# builders
@@ -1418,3 +1407,21 @@ def setup(app: Sphinx) -> dict[str, Any]:
'parallel_read_safe': True,
'parallel_write_safe': True,
}
+
+
+# deprecated name -> (object to return, canonical path or empty string)
+_DEPRECATED_OBJECTS = {
+ 'html5_ready': (True, ''),
+ 'HTMLTranslator': (HTML4Translator, 'sphinx.writers.html.HTML5Translator'),
+}
+
+
+def __getattr__(name):
+ if name not in _DEPRECATED_OBJECTS:
+ raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
+
+ from sphinx.deprecation import _deprecation_warning
+
+ deprecated_object, canonical_name = _DEPRECATED_OBJECTS[name]
+ _deprecation_warning(__name__, name, canonical_name, remove=(7, 0))
+ return deprecated_object