mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
refactor: Remove RemovedInSphinx50Warning (partially)
This commit is contained in:
parent
0e51ddef34
commit
5b7f7f825d
@ -9,7 +9,6 @@
|
||||
"""
|
||||
|
||||
import os
|
||||
import warnings
|
||||
from os import path
|
||||
from typing import Any, Dict, Iterable, List, Tuple, Union
|
||||
|
||||
@ -24,7 +23,6 @@ from sphinx.builders.latex.constants import ADDITIONAL_SETTINGS, DEFAULT_SETTING
|
||||
from sphinx.builders.latex.theming import Theme, ThemeFactory
|
||||
from sphinx.builders.latex.util import ExtBabel
|
||||
from sphinx.config import ENUM, Config
|
||||
from sphinx.deprecation import RemovedInSphinx50Warning
|
||||
from sphinx.environment.adapters.asset import ImageAdapter
|
||||
from sphinx.errors import NoUri, SphinxError
|
||||
from sphinx.locale import _, __
|
||||
@ -449,18 +447,6 @@ class LaTeXBuilder(Builder):
|
||||
filename = path.join(package_dir, 'templates', 'latex', 'sphinxmessages.sty_t')
|
||||
copy_asset_file(filename, self.outdir, context=context, renderer=LaTeXRenderer())
|
||||
|
||||
@property
|
||||
def usepackages(self) -> List[Tuple[str, str]]:
|
||||
warnings.warn('LaTeXBuilder.usepackages is deprecated.',
|
||||
RemovedInSphinx50Warning, stacklevel=2)
|
||||
return self.app.registry.latex_packages
|
||||
|
||||
@property
|
||||
def usepackages_after_hyperref(self) -> List[Tuple[str, str]]:
|
||||
warnings.warn('LaTeXBuilder.usepackages_after_hyperref is deprecated.',
|
||||
RemovedInSphinx50Warning, stacklevel=2)
|
||||
return self.app.registry.latex_packages_after_hyperref
|
||||
|
||||
|
||||
def validate_config_values(app: Sphinx, config: Config) -> None:
|
||||
for key in list(config.latex_elements):
|
||||
|
@ -17,7 +17,6 @@ from docutils.parsers.rst import directives, roles
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.addnodes import desc_signature
|
||||
from sphinx.deprecation import RemovedInSphinx50Warning, deprecated_alias
|
||||
from sphinx.util import docutils
|
||||
from sphinx.util.docfields import DocFieldTransformer, Field, TypedField
|
||||
from sphinx.util.docutils import SphinxDirective
|
||||
@ -266,16 +265,6 @@ class DefaultDomain(SphinxDirective):
|
||||
return []
|
||||
|
||||
|
||||
deprecated_alias('sphinx.directives',
|
||||
{
|
||||
'DescDirective': ObjectDescription,
|
||||
},
|
||||
RemovedInSphinx50Warning,
|
||||
{
|
||||
'DescDirective': 'sphinx.directives.ObjectDescription',
|
||||
})
|
||||
|
||||
|
||||
def setup(app: "Sphinx") -> Dict[str, Any]:
|
||||
app.add_config_value("strip_signature_backslash", False, 'env')
|
||||
directives.register_directive('default-role', DefaultRole)
|
||||
|
@ -26,7 +26,7 @@ from sphinx import addnodes
|
||||
from sphinx.addnodes import desc_signature, pending_xref, pending_xref_condition
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.deprecation import RemovedInSphinx50Warning, RemovedInSphinx60Warning
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
from sphinx.directives import ObjectDescription
|
||||
from sphinx.domains import Domain, Index, IndexEntry, ObjType
|
||||
from sphinx.environment import BuildEnvironment
|
||||
@ -122,7 +122,7 @@ def type_to_xref(target: str, env: BuildEnvironment = None, suppress_prefix: boo
|
||||
refspecific=refspecific, **kwargs)
|
||||
|
||||
|
||||
def _parse_annotation(annotation: str, env: BuildEnvironment = None) -> List[Node]:
|
||||
def _parse_annotation(annotation: str, env: BuildEnvironment) -> List[Node]:
|
||||
"""Parse type annotation."""
|
||||
def unparse(node: ast.AST) -> List[Node]:
|
||||
if isinstance(node, ast.Attribute):
|
||||
@ -210,10 +210,6 @@ def _parse_annotation(annotation: str, env: BuildEnvironment = None) -> List[Nod
|
||||
|
||||
raise SyntaxError # unsupported syntax
|
||||
|
||||
if env is None:
|
||||
warnings.warn("The env parameter for _parse_annotation becomes required now.",
|
||||
RemovedInSphinx50Warning, stacklevel=2)
|
||||
|
||||
try:
|
||||
tree = ast_parse(annotation)
|
||||
result: List[Node] = []
|
||||
@ -979,29 +975,6 @@ class PyProperty(PyObject):
|
||||
return _('%s (%s property)') % (attrname, clsname)
|
||||
|
||||
|
||||
class PyDecoratorMixin:
|
||||
"""
|
||||
Mixin for decorator directives.
|
||||
"""
|
||||
def handle_signature(self, sig: str, signode: desc_signature) -> Tuple[str, str]:
|
||||
for cls in self.__class__.__mro__:
|
||||
if cls.__name__ != 'DirectiveAdapter':
|
||||
warnings.warn('PyDecoratorMixin is deprecated. '
|
||||
'Please check the implementation of %s' % cls,
|
||||
RemovedInSphinx50Warning, stacklevel=2)
|
||||
break
|
||||
else:
|
||||
warnings.warn('PyDecoratorMixin is deprecated',
|
||||
RemovedInSphinx50Warning, stacklevel=2)
|
||||
|
||||
ret = super().handle_signature(sig, signode) # type: ignore
|
||||
signode.insert(0, addnodes.desc_addname('@', '@'))
|
||||
return ret
|
||||
|
||||
def needs_arglist(self) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
class PyModule(SphinxDirective):
|
||||
"""
|
||||
Directive to mark description of a new module.
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
import re
|
||||
import unicodedata
|
||||
import warnings
|
||||
from copy import copy
|
||||
from typing import (TYPE_CHECKING, Any, Callable, Dict, Iterable, Iterator, List, Optional,
|
||||
Tuple, Type, Union, cast)
|
||||
@ -22,7 +21,6 @@ from docutils.statemachine import StringList
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.addnodes import desc_signature, pending_xref
|
||||
from sphinx.deprecation import RemovedInSphinx50Warning
|
||||
from sphinx.directives import ObjectDescription
|
||||
from sphinx.domains import Domain, ObjType
|
||||
from sphinx.locale import _, __
|
||||
@ -675,11 +673,6 @@ class StandardDomain(Domain):
|
||||
objtype, name, docname, location=location)
|
||||
self.objects[objtype, name] = (self.env.docname, labelid)
|
||||
|
||||
def add_object(self, objtype: str, name: str, docname: str, labelid: str) -> None:
|
||||
warnings.warn('StandardDomain.add_object() is deprecated.',
|
||||
RemovedInSphinx50Warning, stacklevel=2)
|
||||
self.objects[objtype, name] = (docname, labelid)
|
||||
|
||||
@property
|
||||
def _terms(self) -> Dict[str, Tuple[str, str]]:
|
||||
""".. note:: Will be removed soon. internal use only."""
|
||||
|
@ -17,7 +17,6 @@ import sys
|
||||
import tempfile
|
||||
import traceback
|
||||
import unicodedata
|
||||
import warnings
|
||||
from datetime import datetime
|
||||
from importlib import import_module
|
||||
from os import path
|
||||
@ -26,7 +25,6 @@ from typing import (IO, TYPE_CHECKING, Any, Callable, Dict, Iterable, Iterator,
|
||||
Pattern, Set, Tuple, Type)
|
||||
from urllib.parse import parse_qsl, quote_plus, urlencode, urlsplit, urlunsplit
|
||||
|
||||
from sphinx.deprecation import RemovedInSphinx50Warning
|
||||
from sphinx.errors import ExtensionError, FiletypeNotFoundError, SphinxParallelError
|
||||
from sphinx.locale import __
|
||||
from sphinx.util import logging
|
||||
@ -37,7 +35,7 @@ from sphinx.util.nodes import (caption_ref_re, explicit_title_re, # noqa
|
||||
# import other utilities; partly for backwards compatibility, so don't
|
||||
# prune unused ones indiscriminately
|
||||
from sphinx.util.osutil import (SEP, copyfile, copytimes, ensuredir, make_filename, # noqa
|
||||
movefile, mtimes_of_files, os_path, relative_uri)
|
||||
mtimes_of_files, os_path, relative_uri)
|
||||
from sphinx.util.typing import PathMatcher
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@ -337,32 +335,6 @@ def parselinenos(spec: str, total: int) -> List[int]:
|
||||
return items
|
||||
|
||||
|
||||
def force_decode(string: str, encoding: str) -> str:
|
||||
"""Forcibly get a unicode string out of a bytestring."""
|
||||
warnings.warn('force_decode() is deprecated.',
|
||||
RemovedInSphinx50Warning, stacklevel=2)
|
||||
if isinstance(string, bytes):
|
||||
try:
|
||||
if encoding:
|
||||
string = string.decode(encoding)
|
||||
else:
|
||||
# try decoding with utf-8, should only work for real UTF-8
|
||||
string = string.decode()
|
||||
except UnicodeError:
|
||||
# last resort -- can't fail
|
||||
string = string.decode('latin1')
|
||||
return string
|
||||
|
||||
|
||||
def rpartition(s: str, t: str) -> Tuple[str, str]:
|
||||
"""Similar to str.rpartition from 2.5, but doesn't return the separator."""
|
||||
warnings.warn('rpartition() is now deprecated.', RemovedInSphinx50Warning, stacklevel=2)
|
||||
i = s.rfind(t)
|
||||
if i != -1:
|
||||
return s[:i], s[i + len(t):]
|
||||
return '', s
|
||||
|
||||
|
||||
def split_into(n: int, type: str, value: str) -> List[str]:
|
||||
"""Split an index entry into a given number of parts at semicolons."""
|
||||
parts = [x.strip() for x in value.split(';', n - 1)]
|
||||
|
@ -16,7 +16,6 @@ import re
|
||||
import sys
|
||||
import types
|
||||
import typing
|
||||
import warnings
|
||||
from functools import partial, partialmethod
|
||||
from importlib import import_module
|
||||
from inspect import Parameter, isclass, ismethod, ismethoddescriptor, ismodule # NOQA
|
||||
@ -24,7 +23,6 @@ from io import StringIO
|
||||
from types import ModuleType
|
||||
from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple, Type, cast
|
||||
|
||||
from sphinx.deprecation import RemovedInSphinx50Warning
|
||||
from sphinx.pycode.ast import ast # for py36-37
|
||||
from sphinx.pycode.ast import unparse as ast_unparse
|
||||
from sphinx.util import logging
|
||||
@ -47,69 +45,6 @@ logger = logging.getLogger(__name__)
|
||||
memory_address_re = re.compile(r' at 0x[0-9a-f]{8,16}(?=>)', re.IGNORECASE)
|
||||
|
||||
|
||||
# Copied from the definition of inspect.getfullargspec from Python master,
|
||||
# and modified to remove the use of special flags that break decorated
|
||||
# callables and bound methods in the name of backwards compatibility. Used
|
||||
# under the terms of PSF license v2, which requires the above statement
|
||||
# and the following:
|
||||
#
|
||||
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
||||
# 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Python Software
|
||||
# Foundation; All Rights Reserved
|
||||
def getargspec(func: Callable) -> Any:
|
||||
"""Like inspect.getfullargspec but supports bound methods, and wrapped
|
||||
methods."""
|
||||
warnings.warn('sphinx.ext.inspect.getargspec() is deprecated',
|
||||
RemovedInSphinx50Warning, stacklevel=2)
|
||||
|
||||
sig = inspect.signature(func)
|
||||
|
||||
args = []
|
||||
varargs = None
|
||||
varkw = None
|
||||
kwonlyargs = []
|
||||
defaults = ()
|
||||
annotations = {}
|
||||
defaults = ()
|
||||
kwdefaults = {}
|
||||
|
||||
if sig.return_annotation is not sig.empty:
|
||||
annotations['return'] = sig.return_annotation
|
||||
|
||||
for param in sig.parameters.values():
|
||||
kind = param.kind
|
||||
name = param.name
|
||||
|
||||
if kind is Parameter.POSITIONAL_ONLY:
|
||||
args.append(name)
|
||||
elif kind is Parameter.POSITIONAL_OR_KEYWORD:
|
||||
args.append(name)
|
||||
if param.default is not param.empty:
|
||||
defaults += (param.default,) # type: ignore
|
||||
elif kind is Parameter.VAR_POSITIONAL:
|
||||
varargs = name
|
||||
elif kind is Parameter.KEYWORD_ONLY:
|
||||
kwonlyargs.append(name)
|
||||
if param.default is not param.empty:
|
||||
kwdefaults[name] = param.default
|
||||
elif kind is Parameter.VAR_KEYWORD:
|
||||
varkw = name
|
||||
|
||||
if param.annotation is not param.empty:
|
||||
annotations[name] = param.annotation
|
||||
|
||||
if not kwdefaults:
|
||||
# compatibility with 'func.__kwdefaults__'
|
||||
kwdefaults = None
|
||||
|
||||
if not defaults:
|
||||
# compatibility with 'func.__defaults__'
|
||||
defaults = None
|
||||
|
||||
return inspect.FullArgSpec(args, varargs, varkw, defaults,
|
||||
kwonlyargs, kwdefaults, annotations)
|
||||
|
||||
|
||||
def unwrap(obj: Any) -> Any:
|
||||
"""Get an original object from wrapped object (wrapped functions)."""
|
||||
try:
|
||||
@ -623,26 +558,19 @@ def _should_unwrap(subject: Callable) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def signature(subject: Callable, bound_method: bool = False, follow_wrapped: bool = None,
|
||||
type_aliases: Dict = {}) -> inspect.Signature:
|
||||
def signature(subject: Callable, bound_method: bool = False, type_aliases: Dict = {}
|
||||
) -> inspect.Signature:
|
||||
"""Return a Signature object for the given *subject*.
|
||||
|
||||
:param bound_method: Specify *subject* is a bound method or not
|
||||
:param follow_wrapped: Same as ``inspect.signature()``.
|
||||
"""
|
||||
|
||||
if follow_wrapped is None:
|
||||
follow_wrapped = True
|
||||
else:
|
||||
warnings.warn('The follow_wrapped argument of sphinx.util.inspect.signature() is '
|
||||
'deprecated', RemovedInSphinx50Warning, stacklevel=2)
|
||||
|
||||
try:
|
||||
try:
|
||||
if _should_unwrap(subject):
|
||||
signature = inspect.signature(subject)
|
||||
else:
|
||||
signature = inspect.signature(subject, follow_wrapped=follow_wrapped)
|
||||
signature = inspect.signature(subject, follow_wrapped=True)
|
||||
except ValueError:
|
||||
# follow built-in wrappers up (ex. functools.lru_cache)
|
||||
signature = inspect.signature(subject)
|
||||
|
@ -14,13 +14,10 @@ import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import warnings
|
||||
from io import StringIO
|
||||
from os import path
|
||||
from typing import Any, Generator, Iterator, List, Optional, Type
|
||||
|
||||
from sphinx.deprecation import RemovedInSphinx50Warning
|
||||
|
||||
try:
|
||||
# for ALT Linux (#6712)
|
||||
from sphinx.testing.path import path as Path
|
||||
@ -84,19 +81,6 @@ def mtimes_of_files(dirnames: List[str], suffix: str) -> Iterator[float]:
|
||||
pass
|
||||
|
||||
|
||||
def movefile(source: str, dest: str) -> None:
|
||||
"""Move a file, removing the destination if it exists."""
|
||||
warnings.warn('sphinx.util.osutil.movefile() is deprecated for removal. '
|
||||
'Please use os.replace() instead.',
|
||||
RemovedInSphinx50Warning, stacklevel=2)
|
||||
if os.path.exists(dest):
|
||||
try:
|
||||
os.unlink(dest)
|
||||
except OSError:
|
||||
pass
|
||||
os.rename(source, dest)
|
||||
|
||||
|
||||
def copytimes(source: str, dest: str) -> None:
|
||||
"""Copy a file's modification times."""
|
||||
st = os.stat(source)
|
||||
|
@ -18,14 +18,6 @@ import requests
|
||||
|
||||
import sphinx
|
||||
from sphinx.config import Config
|
||||
from sphinx.deprecation import RemovedInSphinx50Warning
|
||||
|
||||
try:
|
||||
from requests.packages.urllib3.exceptions import SSLError
|
||||
except ImportError:
|
||||
# python-requests package in Debian jessie does not provide ``requests.packages.urllib3``.
|
||||
# So try to import the exceptions from urllib3 package.
|
||||
from urllib3.exceptions import SSLError # type: ignore
|
||||
|
||||
try:
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
@ -42,22 +34,6 @@ useragent_header = [('User-Agent',
|
||||
'Mozilla/5.0 (X11; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0')]
|
||||
|
||||
|
||||
def is_ssl_error(exc: Exception) -> bool:
|
||||
"""Check an exception is SSLError."""
|
||||
warnings.warn(
|
||||
"is_ssl_error() is outdated and likely returns incorrect results "
|
||||
"for modern versions of Requests.",
|
||||
RemovedInSphinx50Warning)
|
||||
if isinstance(exc, SSLError):
|
||||
return True
|
||||
else:
|
||||
args = getattr(exc, 'args', [])
|
||||
if args and isinstance(args[0], SSLError):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
@contextmanager
|
||||
def ignore_insecure_warning(**kwargs: Any) -> Generator[None, None, None]:
|
||||
with warnings.catch_warnings():
|
||||
|
@ -23,7 +23,7 @@ from docutils.writers.html4css1 import Writer
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.deprecation import RemovedInSphinx50Warning, RemovedInSphinx60Warning
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
from sphinx.locale import _, __, admonitionlabels
|
||||
from sphinx.util import logging
|
||||
from sphinx.util.docutils import SphinxTranslator
|
||||
@ -879,12 +879,6 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
||||
def unknown_visit(self, node: Node) -> None:
|
||||
raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
|
||||
|
||||
@property
|
||||
def permalink_text(self) -> str:
|
||||
warnings.warn('HTMLTranslator.permalink_text is deprecated.',
|
||||
RemovedInSphinx50Warning, stacklevel=2)
|
||||
return self.config.html_permalinks_icon
|
||||
|
||||
@property
|
||||
def _fieldlist_row_index(self):
|
||||
warnings.warn('_fieldlist_row_index is deprecated',
|
||||
|
@ -21,7 +21,7 @@ from docutils.writers.html5_polyglot import HTMLTranslator as BaseTranslator
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.deprecation import RemovedInSphinx50Warning, RemovedInSphinx60Warning
|
||||
from sphinx.deprecation import RemovedInSphinx60Warning
|
||||
from sphinx.locale import _, __, admonitionlabels
|
||||
from sphinx.util import logging
|
||||
from sphinx.util.docutils import SphinxTranslator
|
||||
@ -814,12 +814,6 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
||||
def unknown_visit(self, node: Node) -> None:
|
||||
raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
|
||||
|
||||
@property
|
||||
def permalink_text(self) -> str:
|
||||
warnings.warn('HTMLTranslator.permalink_text is deprecated.',
|
||||
RemovedInSphinx50Warning, stacklevel=2)
|
||||
return self.config.html_permalinks_icon
|
||||
|
||||
def generate_targets_for_table(self, node: Element) -> None:
|
||||
"""Generate hyperlink targets for tables.
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
"""
|
||||
|
||||
import re
|
||||
import warnings
|
||||
from collections import defaultdict
|
||||
from os import path
|
||||
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Set, Tuple, cast
|
||||
@ -21,7 +20,6 @@ from docutils import nodes, writers
|
||||
from docutils.nodes import Element, Node, Text
|
||||
|
||||
from sphinx import addnodes, highlighting
|
||||
from sphinx.deprecation import RemovedInSphinx50Warning
|
||||
from sphinx.domains import IndexEntry
|
||||
from sphinx.domains.std import StandardDomain
|
||||
from sphinx.errors import SphinxError
|
||||
@ -89,13 +87,7 @@ class LaTeXWriter(writers.Writer):
|
||||
self.theme: Theme = None
|
||||
|
||||
def translate(self) -> None:
|
||||
try:
|
||||
visitor = self.builder.create_translator(self.document, self.builder, self.theme)
|
||||
except TypeError:
|
||||
warnings.warn('LaTeXTranslator now takes 3rd argument; "theme".',
|
||||
RemovedInSphinx50Warning, stacklevel=2)
|
||||
visitor = self.builder.create_translator(self.document, self.builder)
|
||||
|
||||
visitor = self.builder.create_translator(self.document, self.builder, self.theme)
|
||||
self.document.walkabout(visitor)
|
||||
self.output = cast(LaTeXTranslator, visitor).astext()
|
||||
|
||||
@ -280,15 +272,11 @@ class LaTeXTranslator(SphinxTranslator):
|
||||
docclasses = ('howto', 'manual')
|
||||
|
||||
def __init__(self, document: nodes.document, builder: "LaTeXBuilder",
|
||||
theme: "Theme" = None) -> None:
|
||||
theme: "Theme") -> None:
|
||||
super().__init__(document, builder)
|
||||
self.body: List[str] = []
|
||||
self.theme = theme
|
||||
|
||||
if theme is None:
|
||||
warnings.warn('LaTeXTranslator now takes 3rd argument; "theme".',
|
||||
RemovedInSphinx50Warning, stacklevel=2)
|
||||
|
||||
# flags
|
||||
self.in_title = 0
|
||||
self.in_production_list = 0
|
||||
@ -312,30 +300,8 @@ class LaTeXTranslator(SphinxTranslator):
|
||||
|
||||
# initial section names
|
||||
self.sectionnames = LATEXSECTIONNAMES[:]
|
||||
|
||||
if self.theme:
|
||||
# new style: control sectioning via theme's setting
|
||||
#
|
||||
# .. note:: template variables(elements) are already assigned in builder
|
||||
docclass = self.theme.docclass
|
||||
if self.theme.toplevel_sectioning == 'section':
|
||||
self.sectionnames.remove('chapter')
|
||||
else:
|
||||
# old style: sectioning control is hard-coded
|
||||
# but some have other interface in config file
|
||||
self.elements['wrapperclass'] = self.format_docclass(self.settings.docclass)
|
||||
|
||||
# we assume LaTeX class provides \chapter command except in case
|
||||
# of non-Japanese 'howto' case
|
||||
if document.get('docclass') == 'howto':
|
||||
docclass = self.config.latex_docclass.get('howto', 'article')
|
||||
if docclass[0] == 'j': # Japanese class...
|
||||
pass
|
||||
else:
|
||||
self.sectionnames.remove('chapter')
|
||||
else:
|
||||
docclass = self.config.latex_docclass.get('manual', 'report')
|
||||
self.elements['docclass'] = docclass
|
||||
if self.theme.toplevel_sectioning == 'section':
|
||||
self.sectionnames.remove('chapter')
|
||||
|
||||
# determine top section level
|
||||
self.top_sectionlevel = 1
|
||||
@ -345,7 +311,7 @@ class LaTeXTranslator(SphinxTranslator):
|
||||
self.sectionnames.index(self.config.latex_toplevel_sectioning)
|
||||
except ValueError:
|
||||
logger.warning(__('unknown %r toplevel_sectioning for class %r') %
|
||||
(self.config.latex_toplevel_sectioning, docclass))
|
||||
(self.config.latex_toplevel_sectioning, self.theme.docclass))
|
||||
|
||||
if self.config.numfig:
|
||||
self.numfig_secnum_depth = self.config.numfig_secnum_depth
|
||||
@ -444,14 +410,6 @@ class LaTeXTranslator(SphinxTranslator):
|
||||
self.body = self.bodystack.pop()
|
||||
return body
|
||||
|
||||
def format_docclass(self, docclass: str) -> str:
|
||||
"""Prepends prefix to sphinx document classes"""
|
||||
warnings.warn('LaTeXWriter.format_docclass() is deprecated.',
|
||||
RemovedInSphinx50Warning, stacklevel=2)
|
||||
if docclass in self.docclasses:
|
||||
docclass = 'sphinx' + docclass
|
||||
return docclass
|
||||
|
||||
def astext(self) -> str:
|
||||
self.elements.update({
|
||||
'body': ''.join(self.body),
|
||||
|
@ -10,16 +10,14 @@
|
||||
|
||||
import re
|
||||
import textwrap
|
||||
import warnings
|
||||
from os import path
|
||||
from typing import (TYPE_CHECKING, Any, Dict, Iterable, Iterator, List, Optional, Pattern, Set,
|
||||
Tuple, Union, cast)
|
||||
from typing import (TYPE_CHECKING, Any, Dict, Iterable, Iterator, List, Pattern, Set, Tuple,
|
||||
Union, cast)
|
||||
|
||||
from docutils import nodes, writers
|
||||
from docutils.nodes import Element, Node, Text
|
||||
|
||||
from sphinx import __display_version__, addnodes
|
||||
from sphinx.deprecation import RemovedInSphinx50Warning
|
||||
from sphinx.domains import IndexEntry
|
||||
from sphinx.domains.index import IndexDomain
|
||||
from sphinx.errors import ExtensionError
|
||||
@ -1566,11 +1564,3 @@ class TexinfoTranslator(SphinxTranslator):
|
||||
self.body.append('\n\n@example\n%s\n@end example\n\n' %
|
||||
self.escape_arg(node.astext()))
|
||||
raise nodes.SkipNode
|
||||
|
||||
@property
|
||||
def desc(self) -> Optional[addnodes.desc]:
|
||||
warnings.warn('TexinfoWriter.desc is deprecated.', RemovedInSphinx50Warning)
|
||||
if len(self.descs):
|
||||
return self.descs[-1]
|
||||
else:
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user