From 26cd8f100c5001b6775d5451ff826440ec697475 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 16 Dec 2021 02:01:15 +0900 Subject: [PATCH] Deprecate sphinx.writers.latex.LaTeXWriter.docclasses --- CHANGES | 2 ++ doc/extdev/deprecated.rst | 5 +++++ sphinx/deprecation.py | 4 ++++ sphinx/writers/latex.py | 12 +++++++++--- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 328b38e432c..f95a500b2da 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,8 @@ Release 5.0.0 (in development) Dependencies ------------ +* ``sphinx.writers.latex.LaTeXWriter.docclasses`` + Incompatible changes -------------------- diff --git a/doc/extdev/deprecated.rst b/doc/extdev/deprecated.rst index 8c3576b2cc0..ef675b9b3f8 100644 --- a/doc/extdev/deprecated.rst +++ b/doc/extdev/deprecated.rst @@ -22,6 +22,11 @@ The following is a list of deprecated interfaces. - (will be) Removed - Alternatives + * - ``sphinx.writers.latex.LaTeXWriter.docclasses`` + - 5.0 + - 7.0 + - N/A + * - ``sphinx.ext.autodoc.AttributeDocumenter._datadescriptor`` - 4.3 - 6.0 diff --git a/sphinx/deprecation.py b/sphinx/deprecation.py index 3963e63615f..ae837746010 100644 --- a/sphinx/deprecation.py +++ b/sphinx/deprecation.py @@ -22,6 +22,10 @@ class RemovedInSphinx60Warning(PendingDeprecationWarning): pass +class RemovedInSphinx70Warning(PendingDeprecationWarning): + pass + + RemovedInNextVersionWarning = RemovedInSphinx50Warning diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 0b67ebf77cc..e90fc1fb62c 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -12,6 +12,7 @@ """ import re +import warnings from collections import defaultdict from os import path from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Set, Tuple, cast @@ -20,6 +21,7 @@ from docutils.nodes import Element, Node, Text from sphinx import addnodes, highlighting +from sphinx.deprecation import RemovedInSphinx70Warning from sphinx.domains import IndexEntry from sphinx.domains.std import StandardDomain from sphinx.errors import SphinxError @@ -268,9 +270,6 @@ class LaTeXTranslator(SphinxTranslator): # default is originally 3. For book/report, 2 is already LaTeX default. ignore_missing_images = False - # sphinx specific document classes - docclasses = ('howto', 'manual') - def __init__(self, document: nodes.document, builder: "LaTeXBuilder", theme: "Theme") -> None: super().__init__(document, builder) @@ -2038,6 +2037,13 @@ def depart_math_reference(self, node: Element) -> None: def unknown_visit(self, node: Node) -> None: raise NotImplementedError('Unknown node: ' + node.__class__.__name__) + @property + def docclasses(self) -> Tuple[str, str]: + """Prepends prefix to sphinx document classes""" + warnings.warn('LaTeXWriter.docclasses() is deprecated.', + RemovedInSphinx70Warning, stacklevel=2) + return ('howto', 'manual') + # FIXME: Workaround to avoid circular import # refs: https://github.com/sphinx-doc/sphinx/issues/5433