diff --git a/CHANGES b/CHANGES index 009b96d6d..af265c3ce 100644 --- a/CHANGES +++ b/CHANGES @@ -96,6 +96,7 @@ Deprecated * ``sphinx.writers.latex.LaTeXTranslator.unrestrict_footnote()`` is deprecated * ``sphinx.writers.latex.LaTeXTranslator.push_hyperlink_ids()`` is deprecated * ``sphinx.writers.latex.LaTeXTranslator.pop_hyperlink_ids()`` is deprecated +* ``sphinx.writers.latex.LaTeXTranslator.check_latex_elements()`` is deprecated * ``sphinx.writers.latex.LaTeXTranslator.bibitems`` is deprecated * ``sphinx.writers.latex.LaTeXTranslator.hlsettingstack`` is deprecated * ``sphinx.writers.latex.ExtBabel.get_shorthandoff()`` is deprecated diff --git a/doc/extdev/index.rst b/doc/extdev/index.rst index 0002af853..7bdcc4a9c 100644 --- a/doc/extdev/index.rst +++ b/doc/extdev/index.rst @@ -282,6 +282,11 @@ The following is a list of deprecated interface. - 3.0 - N/A + * - ``sphinx.writers.latex.LaTeXTranslator.check_latex_elements()`` + - 1.8 + - 3.0 + - Nothing + * - ``sphinx.application.CONFIG_FILENAME`` - 1.8 - 3.0 diff --git a/sphinx/builders/latex/__init__.py b/sphinx/builders/latex/__init__.py index c4e92ae5b..bbbcce0dc 100644 --- a/sphinx/builders/latex/__init__.py +++ b/sphinx/builders/latex/__init__.py @@ -34,7 +34,7 @@ from sphinx.util.docutils import SphinxFileOutput, new_document from sphinx.util.fileutil import copy_asset_file from sphinx.util.nodes import inline_all_toctrees from sphinx.util.osutil import SEP, make_filename -from sphinx.writers.latex import LaTeXWriter, LaTeXTranslator +from sphinx.writers.latex import DEFAULT_SETTINGS, LaTeXWriter, LaTeXTranslator if False: # For type annotation @@ -373,6 +373,12 @@ def validate_config_values(app, config): 'Please use u"..." notation instead): %r') % (document,) ) + for key in list(config.latex_elements): + if key not in DEFAULT_SETTINGS: + msg = __("Unknown configure key: latex_elements[%r]. ignored.") + logger.warning(msg % key) + config.latex_elements.pop(key) + def default_latex_engine(config): # type: (Config) -> unicode diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index b7d80860b..20d03df69 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -494,7 +494,6 @@ class LaTeXTranslator(nodes.NodeVisitor): 'babel': '\\usepackage{babel}', }) # allow the user to override them all - self.check_latex_elements() self.elements.update(builder.config.latex_elements) # but some have other interface in config file @@ -719,13 +718,6 @@ class LaTeXTranslator(nodes.NodeVisitor): self.body = self.bodystack.pop() return body - def check_latex_elements(self): - # type: () -> None - for key in self.builder.config.latex_elements: - if key not in self.elements: - msg = __("Unknown configure key: latex_elements[%r] is ignored.") - logger.warning(msg % key) - def restrict_footnote(self, node): # type: (nodes.Node) -> None warnings.warn('LaTeXWriter.restrict_footnote() is deprecated.', @@ -2625,6 +2617,16 @@ class LaTeXTranslator(nodes.NodeVisitor): RemovedInSphinx30Warning) return [[self.builder.config.highlight_language, sys.maxsize]] + def check_latex_elements(self): + # type: () -> None + warnings.warn('check_latex_elements() is deprecated.', + RemovedInSphinx30Warning) + + for key in self.builder.config.latex_elements: + if key not in self.elements: + msg = __("Unknown configure key: latex_elements[%r] is ignored.") + logger.warning(msg % key) + # Import old modules here for compatibility # They should be imported after `LaTeXTranslator` to avoid recursive import. diff --git a/tests/test_config.py b/tests/test_config.py index 0f0246c0b..5dd05550c 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -22,7 +22,7 @@ from sphinx.testing.path import path @pytest.mark.sphinx(testroot='config', confoverrides={ 'master_doc': 'master', 'nonexisting_value': 'True', - 'latex_elements.docclass': 'scrartcl', + 'latex_elements.maketitle': 'blah blah blah', 'modindex_common_prefix': 'path1,path2'}) def test_core_config(app, status, warning): cfg = app.config @@ -34,7 +34,7 @@ def test_core_config(app, status, warning): # overrides assert cfg.master_doc == 'master' - assert cfg.latex_elements['docclass'] == 'scrartcl' + assert cfg.latex_elements['maketitle'] == 'blah blah blah' assert cfg.modindex_common_prefix == ['path1', 'path2'] # simple default values