Skip to content

Commit

Permalink
Merge pull request sphinx-doc#9978 from tk0miya/deprecate_LaTeXWriter…
Browse files Browse the repository at this point in the history
….docclasses

Deprecate sphinx.writers.latex.LaTeXWriter.docclasses
  • Loading branch information
tk0miya committed Dec 19, 2021
2 parents eb1a8a3 + 26cd8f1 commit 2d1ed64
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -4,6 +4,8 @@ Release 5.0.0 (in development)
Dependencies
------------

* ``sphinx.writers.latex.LaTeXWriter.docclasses``

Incompatible changes
--------------------

Expand Down
5 changes: 5 additions & 0 deletions doc/extdev/deprecated.rst
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions sphinx/deprecation.py
Expand Up @@ -22,6 +22,10 @@ class RemovedInSphinx60Warning(PendingDeprecationWarning):
pass


class RemovedInSphinx70Warning(PendingDeprecationWarning):
pass


RemovedInNextVersionWarning = RemovedInSphinx50Warning


Expand Down
12 changes: 9 additions & 3 deletions sphinx/writers/latex.py
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2d1ed64

Please sign in to comment.