From cfb9f8387b85480d7ac71bf1eece027323659cdb Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 7 Mar 2020 22:56:37 +0900 Subject: [PATCH] Fix #7266: Update deprecation messages for PyClassmember and PyModulelevel --- sphinx/domains/python.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index ac6ee4839..be6bf34e3 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -397,8 +397,14 @@ class PyModulelevel(PyObject): """ def run(self) -> List[Node]: - warnings.warn('PyModulelevel is deprecated.', - RemovedInSphinx40Warning) + for cls in self.__class__.__mro__: + if cls.__name__ != 'DirectiveAdapter': + warnings.warn('PyModulelevel is deprecated. ' + 'Please check the implementation of %s' % cls, + RemovedInSphinx40Warning) + break + else: + warnings.warn('PyModulelevel is deprecated', RemovedInSphinx40Warning) return super().run() @@ -500,8 +506,14 @@ class PyClassmember(PyObject): """ def run(self) -> List[Node]: - warnings.warn('PyClassmember is deprecated.', - RemovedInSphinx40Warning) + for cls in self.__class__.__mro__: + if cls.__name__ != 'DirectiveAdapter': + warnings.warn('PyClassmember is deprecated. ' + 'Please check the implementation of %s' % cls, + RemovedInSphinx40Warning) + break + else: + warnings.warn('PyClassmember is deprecated', RemovedInSphinx40Warning) return super().run()