mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
Issue #21240: Add an abstractmethod directive to mark abstract methods in the docs more explicitly
This commit is contained in:
commit
2e7fca8e48
4 changed files with 25 additions and 11 deletions
|
@ -164,6 +164,19 @@ class PyCoroutineMethod(PyCoroutineMixin, PyClassmember):
|
|||
return PyClassmember.run(self)
|
||||
|
||||
|
||||
class PyAbstractMethod(PyClassmember):
|
||||
|
||||
def handle_signature(self, sig, signode):
|
||||
ret = super(PyAbstractMethod, self).handle_signature(sig, signode)
|
||||
signode.insert(0, addnodes.desc_annotation('abstractmethod ',
|
||||
'abstractmethod '))
|
||||
return ret
|
||||
|
||||
def run(self):
|
||||
self.name = 'py:method'
|
||||
return PyClassmember.run(self)
|
||||
|
||||
|
||||
# Support for documenting version of removal in deprecations
|
||||
|
||||
class DeprecatedRemoved(Directive):
|
||||
|
@ -368,5 +381,6 @@ def setup(app):
|
|||
app.add_directive_to_domain('py', 'decoratormethod', PyDecoratorMethod)
|
||||
app.add_directive_to_domain('py', 'coroutinefunction', PyCoroutineFunction)
|
||||
app.add_directive_to_domain('py', 'coroutinemethod', PyCoroutineMethod)
|
||||
app.add_directive_to_domain('py', 'abstractmethod', PyAbstractMethod)
|
||||
app.add_directive('miscnews', MiscNews)
|
||||
return {'version': '1.0', 'parallel_read_safe': True}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue