Skip to content

Commit

Permalink
Merge pull request #6223 from tk0miya/RemovedInSphinx30Warning
Browse files Browse the repository at this point in the history
Drop features and APIs deprecated in 1.8
  • Loading branch information
tk0miya committed Mar 30, 2019
2 parents 7b404ed + 61098a0 commit 44c49f4
Show file tree
Hide file tree
Showing 45 changed files with 73 additions and 1,445 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -7,6 +7,8 @@ Dependencies
Incompatible changes
--------------------

* Drop features and APIs deprecated in 1.8.x

Deprecated
----------

Expand Down
2 changes: 0 additions & 2 deletions doc/extdev/appapi.rst
Expand Up @@ -54,8 +54,6 @@ package.

.. automethod:: Sphinx.add_domain(domain)

.. automethod:: Sphinx.override_domain(domain)

.. method:: Sphinx.add_directive_to_domain(domain, name, func, content, arguments, \*\*options)
.. automethod:: Sphinx.add_directive_to_domain(domain, name, directiveclass)

Expand Down
56 changes: 1 addition & 55 deletions sphinx/addnodes.py
Expand Up @@ -12,7 +12,7 @@

from docutils import nodes

from sphinx.deprecation import RemovedInSphinx30Warning, RemovedInSphinx40Warning
from sphinx.deprecation import RemovedInSphinx40Warning

if False:
# For type annotation
Expand Down Expand Up @@ -188,59 +188,6 @@ class production(nodes.Part, nodes.Inline, nodes.FixedTextElement):
"""Node for a single grammar production rule."""


# math nodes


class math(nodes.math):
"""Node for inline equations.
.. warning:: This node is provided to keep compatibility only.
It will be removed in nearly future. Don't use this from your extension.
.. deprecated:: 1.8
Use ``docutils.nodes.math`` instead.
"""

def __getitem__(self, key):
"""Special accessor for supporting ``node['latex']``."""
if key == 'latex' and 'latex' not in self.attributes:
warnings.warn("math node for Sphinx was replaced by docutils'. "
"Therefore please use ``node.astext()`` to get an equation instead.",
RemovedInSphinx30Warning, stacklevel=2)
return self.astext()
else:
return super().__getitem__(key)


class math_block(nodes.math_block):
"""Node for block level equations.
.. warning:: This node is provided to keep compatibility only.
It will be removed in nearly future. Don't use this from your extension.
.. deprecated:: 1.8
"""

def __getitem__(self, key):
if key == 'latex' and 'latex' not in self.attributes:
warnings.warn("displaymath node for Sphinx was replaced by docutils'. "
"Therefore please use ``node.astext()`` to get an equation instead.",
RemovedInSphinx30Warning, stacklevel=2)
return self.astext()
else:
return super().__getitem__(key)


class displaymath(math_block):
"""Node for block level equations.
.. warning:: This node is provided to keep compatibility only.
It will be removed in nearly future. Don't use this from your extension.
.. deprecated:: 1.8
"""


# other directive-level nodes

class index(nodes.Invisible, nodes.Inline, nodes.TextElement):
Expand Down Expand Up @@ -379,7 +326,6 @@ def setup(app):
app.add_node(seealso)
app.add_node(productionlist)
app.add_node(production)
app.add_node(displaymath)
app.add_node(index)
app.add_node(centered)
app.add_node(acks)
Expand Down
97 changes: 13 additions & 84 deletions sphinx/application.py
Expand Up @@ -15,7 +15,6 @@
import sys
import warnings
from collections import deque
from inspect import isclass
from io import StringIO
from os import path

Expand All @@ -25,21 +24,18 @@
from sphinx import package_dir, locale
from sphinx.config import Config
from sphinx.config import CONFIG_FILENAME # NOQA # for compatibility (RemovedInSphinx30)
from sphinx.deprecation import (
RemovedInSphinx30Warning, RemovedInSphinx40Warning
)
from sphinx.deprecation import RemovedInSphinx40Warning
from sphinx.environment import BuildEnvironment
from sphinx.errors import ApplicationError, ConfigError, VersionRequirementError
from sphinx.events import EventManager
from sphinx.locale import __
from sphinx.project import Project
from sphinx.registry import SphinxComponentRegistry
from sphinx.util import docutils
from sphinx.util import import_object, progress_message
from sphinx.util import logging
from sphinx.util import progress_message
from sphinx.util.build_phase import BuildPhase
from sphinx.util.console import bold # type: ignore
from sphinx.util.docutils import directive_helper
from sphinx.util.i18n import CatalogRepository
from sphinx.util.logging import prefixed_warnings
from sphinx.util.osutil import abspath, ensuredir, relpath
Expand Down Expand Up @@ -98,7 +94,6 @@
'sphinx.transforms.post_transforms',
'sphinx.transforms.post_transforms.code',
'sphinx.transforms.post_transforms.images',
'sphinx.transforms.post_transforms.compat',
'sphinx.util.compat',
'sphinx.versioning',
# collectors should be loaded by specific order
Expand Down Expand Up @@ -397,18 +392,6 @@ def require_sphinx(self, version):
if version > sphinx.__display_version__[:3]:
raise VersionRequirementError(version)

def import_object(self, objname, source=None):
# type: (str, str) -> Any
"""Import an object from a ``module.name`` string.
.. deprecated:: 1.8
Use ``sphinx.util.import_object()`` instead.
"""
warnings.warn('app.import_object() is deprecated. '
'Use sphinx.util.add_object_type() instead.',
RemovedInSphinx30Warning, stacklevel=2)
return import_object(objname, source=None)

# event interface
def connect(self, event, callback):
# type: (str, Callable) -> int
Expand Down Expand Up @@ -593,36 +576,14 @@ def add_enumerable_node(self, node, figtype, title_getter=None, override=False,
self.registry.add_enumerable_node(node, figtype, title_getter, override=override)
self.add_node(node, override=override, **kwds)

@property
def enumerable_nodes(self):
# type: () -> Dict[Type[nodes.Node], Tuple[str, TitleGetter]]
warnings.warn('app.enumerable_nodes() is deprecated. '
'Use app.get_domain("std").enumerable_nodes instead.',
RemovedInSphinx30Warning, stacklevel=2)
return self.registry.enumerable_nodes

def add_directive(self, name, obj, content=None, arguments=None, override=False, **options): # NOQA
# type: (str, Any, bool, Tuple[int, int, bool], bool, Any) -> None
def add_directive(self, name, cls, override=False):
# type: (str, Type[Directive], bool) -> None
"""Register a Docutils directive.
*name* must be the prospective directive name. There are two possible
ways to write a directive:
- In the docutils 0.4 style, *obj* is the directive function.
*content*, *arguments* and *options* are set as attributes on the
function and determine whether the directive has content, arguments
and options, respectively. **This style is deprecated.**
- In the docutils 0.5 style, *obj* is the directive class.
It must already have attributes named *has_content*,
*required_arguments*, *optional_arguments*,
*final_argument_whitespace* and *option_spec* that correspond to the
options for the function way. See `the Docutils docs
<http://docutils.sourceforge.net/docs/howto/rst-directives.html>`_
for details.
The directive class must inherit from the class
``docutils.parsers.rst.Directive``.
*name* must be the prospective directive name. *cls* is a directive
class which inherits ``docutils.parsers.rst.Directive``. For more
details, see `the Docutils docs
<http://docutils.sourceforge.net/docs/howto/rst-directives.html>`_ .
For example, the (already existing) :rst:dir:`literalinclude` directive
would be added like this:
Expand Down Expand Up @@ -653,17 +614,12 @@ def run(self):
.. versionchanged:: 1.8
Add *override* keyword.
"""
logger.debug('[app] adding directive: %r',
(name, obj, content, arguments, options))
logger.debug('[app] adding directive: %r', (name, cls))
if not override and docutils.is_directive_registered(name):
logger.warning(__('directive %r is already registered, it will be overridden'),
name, type='app', subtype='add_directive')

if not isclass(obj) or not issubclass(obj, Directive):
directive = directive_helper(obj, content, arguments, **options)
docutils.register_directive(name, directive)
else:
docutils.register_directive(name, obj)
docutils.register_directive(name, cls)

def add_role(self, name, role, override=False):
# type: (str, Any, bool) -> None
Expand Down Expand Up @@ -716,26 +672,8 @@ def add_domain(self, domain, override=False):
"""
self.registry.add_domain(domain, override=override)

def override_domain(self, domain):
# type: (Type[Domain]) -> None
"""Override a registered domain.
Make the given *domain* class known to Sphinx, assuming that there is
already a domain with its ``.name``. The new domain must be a subclass
of the existing one.
.. versionadded:: 1.0
.. deprecated:: 1.8
Integrated to :meth:`add_domain`.
"""
warnings.warn('app.override_domain() is deprecated. '
'Use app.add_domain() with override option instead.',
RemovedInSphinx30Warning, stacklevel=2)
self.registry.add_domain(domain, override=True)

def add_directive_to_domain(self, domain, name, obj, has_content=None, argument_spec=None,
override=False, **option_spec):
# type: (str, str, Any, bool, Any, bool, Any) -> None
def add_directive_to_domain(self, domain, name, cls, override=False):
# type: (str, str, Type[Directive], bool) -> None
"""Register a Docutils directive in a domain.
Like :meth:`add_directive`, but the directive is added to the domain
Expand All @@ -745,9 +683,7 @@ def add_directive_to_domain(self, domain, name, obj, has_content=None, argument_
.. versionchanged:: 1.8
Add *override* keyword.
"""
self.registry.add_directive_to_domain(domain, name, obj,
has_content, argument_spec, override=override,
**option_spec)
self.registry.add_directive_to_domain(domain, name, cls, override=override)

def add_role_to_domain(self, domain, name, role, override=False):
# type: (str, str, Union[RoleFunction, XRefRole], bool) -> None
Expand Down Expand Up @@ -1205,13 +1141,6 @@ def is_parallel_allowed(self, typ):

return True

@property
def _setting_up_extension(self):
# type: () -> List[str]
warnings.warn('app._setting_up_extension is deprecated.',
RemovedInSphinx30Warning)
return ['?']


class TemplateBridge:
"""
Expand Down
49 changes: 2 additions & 47 deletions sphinx/builders/html.py
Expand Up @@ -24,9 +24,7 @@

from sphinx import package_dir, __display_version__
from sphinx.builders import Builder
from sphinx.deprecation import (
RemovedInSphinx30Warning, RemovedInSphinx40Warning, deprecated_alias
)
from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
from sphinx.environment.adapters.asset import ImageAdapter
from sphinx.environment.adapters.indexentries import IndexEntries
from sphinx.environment.adapters.toctree import TocTree
Expand Down Expand Up @@ -105,39 +103,6 @@ def __new__(cls, filename, *args, **attributes):
return self


class JSContainer(list):
"""The container for JavaScript scripts."""
def insert(self, index, obj):
# type: (int, str) -> None
warnings.warn('To modify script_files in the theme is deprecated. '
'Please insert a <script> tag directly in your theme instead.',
RemovedInSphinx30Warning, stacklevel=3)
super().insert(index, obj)

def extend(self, other): # type: ignore
# type: (List[str]) -> None
warnings.warn('To modify script_files in the theme is deprecated. '
'Please insert a <script> tag directly in your theme instead.',
RemovedInSphinx30Warning, stacklevel=3)
for item in other:
self.append(item)

def __iadd__(self, other): # type: ignore
# type: (List[str]) -> JSContainer
warnings.warn('To modify script_files in the theme is deprecated. '
'Please insert a <script> tag directly in your theme instead.',
RemovedInSphinx30Warning, stacklevel=3)
for item in other:
self.append(item)
return self

def __add__(self, other):
# type: (List[str]) -> JSContainer
ret = JSContainer(self)
ret += other
return ret


class JavaScript(str):
"""A metadata of javascript file.
Expand Down Expand Up @@ -247,7 +212,7 @@ def __init__(self, app):
self.css_files = [] # type: List[Dict[str, str]]

# JS files
self.script_files = JSContainer() # type: List[JavaScript]
self.script_files = [] # type: List[JavaScript]

def init(self):
# type: () -> None
Expand Down Expand Up @@ -1068,16 +1033,6 @@ def hasdoc(name):
return False
ctx['hasdoc'] = hasdoc

def warn(*args, **kwargs):
# type: (Any, Any) -> str
"""Simple warn() wrapper for themes."""
warnings.warn('The template function warn() was deprecated. '
'Use warning() instead.',
RemovedInSphinx30Warning, stacklevel=2)
logger.warning(*args, **kwargs)
return '' # return empty string
ctx['warn'] = warn

ctx['toctree'] = lambda **kw: self._get_local_toctree(pagename, **kw)
self.add_sidebars(pagename, ctx)
ctx.update(addctx)
Expand Down
11 changes: 0 additions & 11 deletions sphinx/builders/latex/util.py
Expand Up @@ -8,12 +8,8 @@
:license: BSD, see LICENSE for details.
"""

import warnings

from docutils.writers.latex2e import Babel

from sphinx.deprecation import RemovedInSphinx30Warning


class ExtBabel(Babel):
cyrillic_languages = ('bulgarian', 'kazakh', 'mongolian', 'russian', 'ukrainian')
Expand All @@ -25,13 +21,6 @@ def __init__(self, language_code, use_polyglossia=False):
self.supported = True
super().__init__(language_code or '')

def get_shorthandoff(self):
# type: () -> str
warnings.warn('ExtBabel.get_shorthandoff() is deprecated.',
RemovedInSphinx30Warning, stacklevel=2)
from sphinx.writers.latex import SHORTHANDOFF
return SHORTHANDOFF

def uses_cyrillic(self):
# type: () -> bool
return self.language in self.cyrillic_languages
Expand Down

0 comments on commit 44c49f4

Please sign in to comment.