Remove more deprecated items in Sphinx 6.0 (#10562)

This commit is contained in:
Adam Turner 2022-06-26 15:01:09 +01:00 committed by GitHub
parent 7b0787485e
commit ac0fc4b781
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 106 deletions

View File

@ -273,15 +273,6 @@ in the future.
that handles navigation, not the web browser, such as for HTML help or Qt that handles navigation, not the web browser, such as for HTML help or Qt
help formats. In this case, the sidebar is not included. help formats. In this case, the sidebar is not included.
.. data:: favicon
The path to the HTML favicon in the static path, or URL to the favicon, or
``''``.
.. deprecated:: 4.0
Recommend to use ``favicon_url`` instead.
.. data:: favicon_url .. data:: favicon_url
The relative path to the HTML favicon image from the current document, or The relative path to the HTML favicon image from the current document, or
@ -308,15 +299,6 @@ in the future.
The build date. The build date.
.. data:: logo
The path to the HTML logo image in the static path, or URL to the logo, or
``''``.
.. deprecated:: 4.0
Recommend to use ``logo_url`` instead.
.. data:: logo_url .. data:: logo_url
The relative path to the HTML logo image from the current document, or URL The relative path to the HTML logo image from the current document, or URL

View File

@ -427,17 +427,6 @@ The following directives are provided for module and class contents:
Describe the location where the object is defined. The default value is Describe the location where the object is defined. The default value is
the module specified by :rst:dir:`py:currentmodule`. the module specified by :rst:dir:`py:currentmodule`.
.. rst:directive:option:: property
:type: no value
Indicate the method is a property.
.. versionadded:: 2.1
.. deprecated:: 4.0
Use :rst:dir:`py:property` instead.
.. rst:directive:option:: staticmethod .. rst:directive:option:: staticmethod
:type: no value :type: no value

View File

@ -89,7 +89,6 @@ builtin_extensions = (
'sphinx.transforms.post_transforms', 'sphinx.transforms.post_transforms',
'sphinx.transforms.post_transforms.code', 'sphinx.transforms.post_transforms.code',
'sphinx.transforms.post_transforms.images', 'sphinx.transforms.post_transforms.images',
'sphinx.util.compat',
'sphinx.versioning', 'sphinx.versioning',
# collectors should be loaded by specific order # collectors should be loaded by specific order
'sphinx.environment.collectors.dependencies', 'sphinx.environment.collectors.dependencies',

View File

@ -548,8 +548,8 @@ class StandaloneHTMLBuilder(Builder):
'rellinks': rellinks, 'rellinks': rellinks,
'builder': self.name, 'builder': self.name,
'parents': [], 'parents': [],
'logo': logo, 'logo_url': logo,
'favicon': favicon, 'favicon_url': favicon,
'html5_doctype': not self.config.html4_writer, 'html5_doctype': not self.config.html4_writer,
} }
if self.theme: if self.theme:
@ -1227,18 +1227,14 @@ def setup_resource_paths(app: Sphinx, pagename: str, templatename: str,
pathto = context.get('pathto') pathto = context.get('pathto')
# favicon_url # favicon_url
favicon = context.get('favicon') favicon_url = context.get('favicon_url')
if favicon and not isurl(favicon): if favicon_url and not isurl(favicon_url):
context['favicon_url'] = pathto('_static/' + favicon, resource=True) context['favicon_url'] = pathto('_static/' + favicon_url, resource=True)
else:
context['favicon_url'] = favicon
# logo_url # logo_url
logo = context.get('logo') logo_url = context.get('logo_url')
if logo and not isurl(logo): if logo_url and not isurl(logo_url):
context['logo_url'] = pathto('_static/' + logo, resource=True) context['logo_url'] = pathto('_static/' + logo_url, resource=True)
else:
context['logo_url'] = logo
def validate_math_renderer(app: Sphinx) -> None: def validate_math_renderer(app: Sphinx) -> None:

View File

@ -764,15 +764,11 @@ class PyMethod(PyObject):
'async': directives.flag, 'async': directives.flag,
'classmethod': directives.flag, 'classmethod': directives.flag,
'final': directives.flag, 'final': directives.flag,
'property': directives.flag,
'staticmethod': directives.flag, 'staticmethod': directives.flag,
}) })
def needs_arglist(self) -> bool: def needs_arglist(self) -> bool:
if 'property' in self.options: return True
return False
else:
return True
def get_signature_prefix(self, sig: str) -> List[nodes.Node]: def get_signature_prefix(self, sig: str) -> List[nodes.Node]:
prefix: List[nodes.Node] = [] prefix: List[nodes.Node] = []
@ -788,9 +784,6 @@ class PyMethod(PyObject):
if 'classmethod' in self.options: if 'classmethod' in self.options:
prefix.append(nodes.Text('classmethod')) prefix.append(nodes.Text('classmethod'))
prefix.append(addnodes.desc_sig_space()) prefix.append(addnodes.desc_sig_space())
if 'property' in self.options:
prefix.append(nodes.Text('property'))
prefix.append(addnodes.desc_sig_space())
if 'staticmethod' in self.options: if 'staticmethod' in self.options:
prefix.append(nodes.Text('static')) prefix.append(nodes.Text('static'))
prefix.append(addnodes.desc_sig_space()) prefix.append(addnodes.desc_sig_space())
@ -810,8 +803,6 @@ class PyMethod(PyObject):
if 'classmethod' in self.options: if 'classmethod' in self.options:
return _('%s() (%s class method)') % (methname, clsname) return _('%s() (%s class method)') % (methname, clsname)
elif 'property' in self.options:
return _('%s (%s property)') % (methname, clsname)
elif 'staticmethod' in self.options: elif 'staticmethod' in self.options:
return _('%s() (%s static method)') % (methname, clsname) return _('%s() (%s static method)') % (methname, clsname)
else: else:

View File

@ -1,33 +0,0 @@
"""modules for backward compatibility"""
import sys
from typing import TYPE_CHECKING, Any, Dict
if TYPE_CHECKING:
from sphinx.application import Sphinx
def register_application_for_autosummary(app: "Sphinx") -> None:
"""Register application object to autosummary module.
Since Sphinx-1.7, documenters and attrgetters are registered into
application object. As a result, the arguments of
``get_documenter()`` has been changed. To keep compatibility,
this handler registers application object to the module.
"""
if 'sphinx.ext.autosummary' in sys.modules:
from sphinx.ext import autosummary
if hasattr(autosummary, '_objects'):
autosummary._objects['_app'] = app # type: ignore
else:
autosummary._app = app # type: ignore
def setup(app: "Sphinx") -> Dict[str, Any]:
app.connect('builder-inited', register_application_for_autosummary, priority=100)
return {
'version': 'builtin',
'parallel_read_safe': True,
'parallel_write_safe': True,
}

View File

@ -731,10 +731,8 @@ def test_pymethod_options(app):
" .. py:method:: meth4\n" " .. py:method:: meth4\n"
" :async:\n" " :async:\n"
" .. py:method:: meth5\n" " .. py:method:: meth5\n"
" :property:\n"
" .. py:method:: meth6\n"
" :abstractmethod:\n" " :abstractmethod:\n"
" .. py:method:: meth7\n" " .. py:method:: meth6\n"
" :final:\n") " :final:\n")
domain = app.env.get_domain('py') domain = app.env.get_domain('py')
doctree = restructuredtext.parse(app, text) doctree = restructuredtext.parse(app, text)
@ -752,8 +750,6 @@ def test_pymethod_options(app):
addnodes.index, addnodes.index,
desc, desc,
addnodes.index, addnodes.index,
desc,
addnodes.index,
desc)])])) desc)])]))
# method # method
@ -795,35 +791,26 @@ def test_pymethod_options(app):
assert 'Class.meth4' in domain.objects assert 'Class.meth4' in domain.objects
assert domain.objects['Class.meth4'] == ('index', 'Class.meth4', 'method', False) assert domain.objects['Class.meth4'] == ('index', 'Class.meth4', 'method', False)
# :property: # :abstractmethod:
assert_node(doctree[1][1][8], addnodes.index, assert_node(doctree[1][1][8], addnodes.index,
entries=[('single', 'meth5 (Class property)', 'Class.meth5', '', None)]) entries=[('single', 'meth5() (Class method)', 'Class.meth5', '', None)])
assert_node(doctree[1][1][9], ([desc_signature, ([desc_annotation, ("property", desc_sig_space)], assert_node(doctree[1][1][9], ([desc_signature, ([desc_annotation, ("abstract", desc_sig_space)],
[desc_name, "meth5"])], [desc_name, "meth5"],
[desc_parameterlist, ()])],
[desc_content, ()])) [desc_content, ()]))
assert 'Class.meth5' in domain.objects assert 'Class.meth5' in domain.objects
assert domain.objects['Class.meth5'] == ('index', 'Class.meth5', 'method', False) assert domain.objects['Class.meth5'] == ('index', 'Class.meth5', 'method', False)
# :abstractmethod: # :final:
assert_node(doctree[1][1][10], addnodes.index, assert_node(doctree[1][1][10], addnodes.index,
entries=[('single', 'meth6() (Class method)', 'Class.meth6', '', None)]) entries=[('single', 'meth6() (Class method)', 'Class.meth6', '', None)])
assert_node(doctree[1][1][11], ([desc_signature, ([desc_annotation, ("abstract", desc_sig_space)], assert_node(doctree[1][1][11], ([desc_signature, ([desc_annotation, ("final", desc_sig_space)],
[desc_name, "meth6"], [desc_name, "meth6"],
[desc_parameterlist, ()])], [desc_parameterlist, ()])],
[desc_content, ()])) [desc_content, ()]))
assert 'Class.meth6' in domain.objects assert 'Class.meth6' in domain.objects
assert domain.objects['Class.meth6'] == ('index', 'Class.meth6', 'method', False) assert domain.objects['Class.meth6'] == ('index', 'Class.meth6', 'method', False)
# :final:
assert_node(doctree[1][1][12], addnodes.index,
entries=[('single', 'meth7() (Class method)', 'Class.meth7', '', None)])
assert_node(doctree[1][1][13], ([desc_signature, ([desc_annotation, ("final", desc_sig_space)],
[desc_name, "meth7"],
[desc_parameterlist, ()])],
[desc_content, ()]))
assert 'Class.meth7' in domain.objects
assert domain.objects['Class.meth7'] == ('index', 'Class.meth7', 'method', False)
def test_pyclassmethod(app): def test_pyclassmethod(app):
text = (".. py:class:: Class\n" text = (".. py:class:: Class\n"