py domain: Deprecate PyDecoratorMixin

This commit is contained in:
Takeshi KOMIYA 2020-03-07 23:13:06 +09:00
parent 3cadc82559
commit d49bec1c67
3 changed files with 16 additions and 1 deletions

View File

@ -42,6 +42,7 @@ Deprecated
* ``desc_signature['first']`` * ``desc_signature['first']``
* ``sphinx.directives.DescDirective`` * ``sphinx.directives.DescDirective``
* ``sphinx.domains.std.StandardDomain.add_object()`` * ``sphinx.domains.std.StandardDomain.add_object()``
* ``sphinx.domains.python.PyDecoratorMixin``
* ``sphinx.parsers.Parser.app`` * ``sphinx.parsers.Parser.app``
* ``sphinx.testing.path.Path.text()`` * ``sphinx.testing.path.Path.text()``
* ``sphinx.testing.path.Path.bytes()`` * ``sphinx.testing.path.Path.bytes()``

View File

@ -41,6 +41,11 @@ The following is a list of deprecated interfaces.
- 5.0 - 5.0
- ``sphinx.domains.std.StandardDomain.note_object()`` - ``sphinx.domains.std.StandardDomain.note_object()``
* - ``sphinx.domains.python.PyDecoratorMixin``
- 3.0
- 5.0
- N/A
* - ``sphinx.parsers.Parser.app`` * - ``sphinx.parsers.Parser.app``
- 3.0 - 3.0
- 5.0 - 5.0

View File

@ -25,7 +25,7 @@ from sphinx import addnodes
from sphinx.addnodes import pending_xref, desc_signature from sphinx.addnodes import pending_xref, desc_signature
from sphinx.application import Sphinx from sphinx.application import Sphinx
from sphinx.builders import Builder from sphinx.builders import Builder
from sphinx.deprecation import RemovedInSphinx40Warning from sphinx.deprecation import RemovedInSphinx40Warning, RemovedInSphinx50Warning
from sphinx.directives import ObjectDescription from sphinx.directives import ObjectDescription
from sphinx.domains import Domain, ObjType, Index, IndexEntry from sphinx.domains import Domain, ObjType, Index, IndexEntry
from sphinx.environment import BuildEnvironment from sphinx.environment import BuildEnvironment
@ -775,6 +775,15 @@ class PyDecoratorMixin:
Mixin for decorator directives. Mixin for decorator directives.
""" """
def handle_signature(self, sig: str, signode: desc_signature) -> Tuple[str, str]: 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)
break
else:
warnings.warn('PyDecoratorMixin is deprecated', RemovedInSphinx50Warning)
ret = super().handle_signature(sig, signode) # type: ignore ret = super().handle_signature(sig, signode) # type: ignore
signode.insert(0, addnodes.desc_addname('@', '@')) signode.insert(0, addnodes.desc_addname('@', '@'))
return ret return ret