mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Close #7143: py domain: Add :final: option to py:*: directives
This commit is contained in:
@@ -499,6 +499,34 @@ def test_pyfunction(app):
|
||||
assert domain.objects['example.func2'] == ('index', 'example.func2', 'function')
|
||||
|
||||
|
||||
def test_pyclass_options(app):
|
||||
text = (".. py:class:: Class1\n"
|
||||
".. py:class:: Class2\n"
|
||||
" :final:\n")
|
||||
domain = app.env.get_domain('py')
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(doctree, (addnodes.index,
|
||||
[desc, ([desc_signature, ([desc_annotation, "class "],
|
||||
[desc_name, "Class1"])],
|
||||
[desc_content, ()])],
|
||||
addnodes.index,
|
||||
[desc, ([desc_signature, ([desc_annotation, "final class "],
|
||||
[desc_name, "Class2"])],
|
||||
[desc_content, ()])]))
|
||||
|
||||
# class
|
||||
assert_node(doctree[0], addnodes.index,
|
||||
entries=[('single', 'Class1 (built-in class)', 'Class1', '', None)])
|
||||
assert 'Class1' in domain.objects
|
||||
assert domain.objects['Class1'] == ('index', 'Class1', 'class')
|
||||
|
||||
# :final:
|
||||
assert_node(doctree[2], addnodes.index,
|
||||
entries=[('single', 'Class2 (built-in class)', 'Class2', '', None)])
|
||||
assert 'Class2' in domain.objects
|
||||
assert domain.objects['Class2'] == ('index', 'Class2', 'class')
|
||||
|
||||
|
||||
def test_pymethod_options(app):
|
||||
text = (".. py:class:: Class\n"
|
||||
"\n"
|
||||
@@ -512,7 +540,9 @@ def test_pymethod_options(app):
|
||||
" .. py:method:: meth5\n"
|
||||
" :property:\n"
|
||||
" .. py:method:: meth6\n"
|
||||
" :abstractmethod:\n")
|
||||
" :abstractmethod:\n"
|
||||
" .. py:method:: meth7\n"
|
||||
" :final:\n")
|
||||
domain = app.env.get_domain('py')
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(doctree, (addnodes.index,
|
||||
@@ -529,6 +559,8 @@ def test_pymethod_options(app):
|
||||
addnodes.index,
|
||||
desc,
|
||||
addnodes.index,
|
||||
desc,
|
||||
addnodes.index,
|
||||
desc)])]))
|
||||
|
||||
# method
|
||||
@@ -589,6 +621,16 @@ def test_pymethod_options(app):
|
||||
assert 'Class.meth6' in domain.objects
|
||||
assert domain.objects['Class.meth6'] == ('index', 'Class.meth6', 'method')
|
||||
|
||||
# :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_name, "meth7"],
|
||||
[desc_parameterlist, ()])],
|
||||
[desc_content, ()]))
|
||||
assert 'Class.meth7' in domain.objects
|
||||
assert domain.objects['Class.meth7'] == ('index', 'Class.meth7', 'method')
|
||||
|
||||
|
||||
def test_pyclassmethod(app):
|
||||
text = (".. py:class:: Class\n"
|
||||
|
||||
Reference in New Issue
Block a user