summaryrefslogtreecommitdiff
path: root/sphinx/domains/python.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/domains/python.py')
-rw-r--r--sphinx/domains/python.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py
index 91ba489c7..712b2c83e 100644
--- a/sphinx/domains/python.py
+++ b/sphinx/domains/python.py
@@ -604,10 +604,18 @@ class PyClasslike(PyObject):
Description of a class-like object (classes, interfaces, exceptions).
"""
+ option_spec = PyObject.option_spec.copy()
+ option_spec.update({
+ 'final': directives.flag,
+ })
+
allow_nesting = True
def get_signature_prefix(self, sig: str) -> str:
- return self.objtype + ' '
+ if 'final' in self.options:
+ return 'final %s ' % self.objtype
+ else:
+ return '%s ' % self.objtype
def get_index_text(self, modname: str, name_cls: Tuple[str, str]) -> str:
if self.objtype == 'class':
@@ -628,6 +636,7 @@ class PyMethod(PyObject):
'abstractmethod': directives.flag,
'async': directives.flag,
'classmethod': directives.flag,
+ 'final': directives.flag,
'property': directives.flag,
'staticmethod': directives.flag,
})
@@ -640,6 +649,8 @@ class PyMethod(PyObject):
def get_signature_prefix(self, sig: str) -> str:
prefix = []
+ if 'final' in self.options:
+ prefix.append('final')
if 'abstractmethod' in self.options:
prefix.append('abstract')
if 'async' in self.options: