mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
py nodes, PyClassLike, get_signature_prefix
This commit is contained in:
parent
83fcc98dbc
commit
51e7b6d2aa
@ -714,11 +714,12 @@ class PyClasslike(PyObject):
|
|||||||
|
|
||||||
allow_nesting = True
|
allow_nesting = True
|
||||||
|
|
||||||
def get_signature_prefix(self, sig: str) -> str:
|
def get_signature_prefix(self, sig: str) -> List[nodes.Node]:
|
||||||
if 'final' in self.options:
|
if 'final' in self.options:
|
||||||
return 'final %s ' % self.objtype
|
return [nodes.Text('final'), addnodes.desc_sig_space(),
|
||||||
|
nodes.Text(self.objtype), addnodes.desc_sig_space()]
|
||||||
else:
|
else:
|
||||||
return '%s ' % self.objtype
|
return [nodes.Text(self.objtype), addnodes.desc_sig_space()]
|
||||||
|
|
||||||
def get_index_text(self, modname: str, name_cls: Tuple[str, str]) -> str:
|
def get_index_text(self, modname: str, name_cls: Tuple[str, str]) -> str:
|
||||||
if self.objtype == 'class':
|
if self.objtype == 'class':
|
||||||
|
@ -520,7 +520,7 @@ def test_pyexception_signature(app):
|
|||||||
text = ".. py:exception:: builtins.IOError"
|
text = ".. py:exception:: builtins.IOError"
|
||||||
doctree = restructuredtext.parse(app, text)
|
doctree = restructuredtext.parse(app, text)
|
||||||
assert_node(doctree, (addnodes.index,
|
assert_node(doctree, (addnodes.index,
|
||||||
[desc, ([desc_signature, ([desc_annotation, "exception "],
|
[desc, ([desc_signature, ([desc_annotation, ('exception', desc_sig_space)],
|
||||||
[desc_addname, "builtins."],
|
[desc_addname, "builtins."],
|
||||||
[desc_name, "IOError"])],
|
[desc_name, "IOError"])],
|
||||||
desc_content)]))
|
desc_content)]))
|
||||||
@ -583,7 +583,7 @@ def test_pyobject_prefix(app):
|
|||||||
" .. py:method:: FooBar.say")
|
" .. py:method:: FooBar.say")
|
||||||
doctree = restructuredtext.parse(app, text)
|
doctree = restructuredtext.parse(app, text)
|
||||||
assert_node(doctree, (addnodes.index,
|
assert_node(doctree, (addnodes.index,
|
||||||
[desc, ([desc_signature, ([desc_annotation, "class "],
|
[desc, ([desc_signature, ([desc_annotation, ('class', desc_sig_space)],
|
||||||
[desc_name, "Foo"])],
|
[desc_name, "Foo"])],
|
||||||
[desc_content, (addnodes.index,
|
[desc_content, (addnodes.index,
|
||||||
desc,
|
desc,
|
||||||
@ -653,11 +653,14 @@ def test_pyclass_options(app):
|
|||||||
domain = app.env.get_domain('py')
|
domain = app.env.get_domain('py')
|
||||||
doctree = restructuredtext.parse(app, text)
|
doctree = restructuredtext.parse(app, text)
|
||||||
assert_node(doctree, (addnodes.index,
|
assert_node(doctree, (addnodes.index,
|
||||||
[desc, ([desc_signature, ([desc_annotation, "class "],
|
[desc, ([desc_signature, ([desc_annotation, ("class", desc_sig_space)],
|
||||||
[desc_name, "Class1"])],
|
[desc_name, "Class1"])],
|
||||||
[desc_content, ()])],
|
[desc_content, ()])],
|
||||||
addnodes.index,
|
addnodes.index,
|
||||||
[desc, ([desc_signature, ([desc_annotation, "final class "],
|
[desc, ([desc_signature, ([desc_annotation, ("final",
|
||||||
|
desc_sig_space,
|
||||||
|
"class",
|
||||||
|
desc_sig_space)],
|
||||||
[desc_name, "Class2"])],
|
[desc_name, "Class2"])],
|
||||||
[desc_content, ()])]))
|
[desc_content, ()])]))
|
||||||
|
|
||||||
@ -693,7 +696,7 @@ def test_pymethod_options(app):
|
|||||||
domain = app.env.get_domain('py')
|
domain = app.env.get_domain('py')
|
||||||
doctree = restructuredtext.parse(app, text)
|
doctree = restructuredtext.parse(app, text)
|
||||||
assert_node(doctree, (addnodes.index,
|
assert_node(doctree, (addnodes.index,
|
||||||
[desc, ([desc_signature, ([desc_annotation, "class "],
|
[desc, ([desc_signature, ([desc_annotation, ("class", desc_sig_space)],
|
||||||
[desc_name, "Class"])],
|
[desc_name, "Class"])],
|
||||||
[desc_content, (addnodes.index,
|
[desc_content, (addnodes.index,
|
||||||
desc,
|
desc,
|
||||||
@ -786,7 +789,7 @@ def test_pyclassmethod(app):
|
|||||||
domain = app.env.get_domain('py')
|
domain = app.env.get_domain('py')
|
||||||
doctree = restructuredtext.parse(app, text)
|
doctree = restructuredtext.parse(app, text)
|
||||||
assert_node(doctree, (addnodes.index,
|
assert_node(doctree, (addnodes.index,
|
||||||
[desc, ([desc_signature, ([desc_annotation, "class "],
|
[desc, ([desc_signature, ([desc_annotation, ("class", desc_sig_space)],
|
||||||
[desc_name, "Class"])],
|
[desc_name, "Class"])],
|
||||||
[desc_content, (addnodes.index,
|
[desc_content, (addnodes.index,
|
||||||
desc)])]))
|
desc)])]))
|
||||||
@ -807,7 +810,7 @@ def test_pystaticmethod(app):
|
|||||||
domain = app.env.get_domain('py')
|
domain = app.env.get_domain('py')
|
||||||
doctree = restructuredtext.parse(app, text)
|
doctree = restructuredtext.parse(app, text)
|
||||||
assert_node(doctree, (addnodes.index,
|
assert_node(doctree, (addnodes.index,
|
||||||
[desc, ([desc_signature, ([desc_annotation, "class "],
|
[desc, ([desc_signature, ([desc_annotation, ("class", desc_sig_space)],
|
||||||
[desc_name, "Class"])],
|
[desc_name, "Class"])],
|
||||||
[desc_content, (addnodes.index,
|
[desc_content, (addnodes.index,
|
||||||
desc)])]))
|
desc)])]))
|
||||||
@ -830,7 +833,7 @@ def test_pyattribute(app):
|
|||||||
domain = app.env.get_domain('py')
|
domain = app.env.get_domain('py')
|
||||||
doctree = restructuredtext.parse(app, text)
|
doctree = restructuredtext.parse(app, text)
|
||||||
assert_node(doctree, (addnodes.index,
|
assert_node(doctree, (addnodes.index,
|
||||||
[desc, ([desc_signature, ([desc_annotation, "class "],
|
[desc, ([desc_signature, ([desc_annotation, ("class", desc_sig_space)],
|
||||||
[desc_name, "Class"])],
|
[desc_name, "Class"])],
|
||||||
[desc_content, (addnodes.index,
|
[desc_content, (addnodes.index,
|
||||||
desc)])]))
|
desc)])]))
|
||||||
@ -868,7 +871,7 @@ def test_pyproperty(app):
|
|||||||
domain = app.env.get_domain('py')
|
domain = app.env.get_domain('py')
|
||||||
doctree = restructuredtext.parse(app, text)
|
doctree = restructuredtext.parse(app, text)
|
||||||
assert_node(doctree, (addnodes.index,
|
assert_node(doctree, (addnodes.index,
|
||||||
[desc, ([desc_signature, ([desc_annotation, "class "],
|
[desc, ([desc_signature, ([desc_annotation, ("class", desc_sig_space)],
|
||||||
[desc_name, "Class"])],
|
[desc_name, "Class"])],
|
||||||
[desc_content, (addnodes.index,
|
[desc_content, (addnodes.index,
|
||||||
desc,
|
desc,
|
||||||
@ -932,7 +935,7 @@ def test_canonical(app):
|
|||||||
domain = app.env.get_domain('py')
|
domain = app.env.get_domain('py')
|
||||||
doctree = restructuredtext.parse(app, text)
|
doctree = restructuredtext.parse(app, text)
|
||||||
assert_node(doctree, (addnodes.index,
|
assert_node(doctree, (addnodes.index,
|
||||||
[desc, ([desc_signature, ([desc_annotation, "class "],
|
[desc, ([desc_signature, ([desc_annotation, ("class", desc_sig_space)],
|
||||||
[desc_addname, "io."],
|
[desc_addname, "io."],
|
||||||
[desc_name, "StringIO"])],
|
[desc_name, "StringIO"])],
|
||||||
desc_content)]))
|
desc_content)]))
|
||||||
@ -990,7 +993,7 @@ def test_info_field_list(app):
|
|||||||
assert_node(doctree, (nodes.target,
|
assert_node(doctree, (nodes.target,
|
||||||
addnodes.index,
|
addnodes.index,
|
||||||
addnodes.index,
|
addnodes.index,
|
||||||
[desc, ([desc_signature, ([desc_annotation, "class "],
|
[desc, ([desc_signature, ([desc_annotation, ("class", desc_sig_space)],
|
||||||
[desc_addname, "example."],
|
[desc_addname, "example."],
|
||||||
[desc_name, "Class"])],
|
[desc_name, "Class"])],
|
||||||
[desc_content, nodes.field_list, nodes.field])]))
|
[desc_content, nodes.field_list, nodes.field])]))
|
||||||
@ -1081,7 +1084,7 @@ def test_info_field_list_piped_type(app):
|
|||||||
(nodes.target,
|
(nodes.target,
|
||||||
addnodes.index,
|
addnodes.index,
|
||||||
addnodes.index,
|
addnodes.index,
|
||||||
[desc, ([desc_signature, ([desc_annotation, "class "],
|
[desc, ([desc_signature, ([desc_annotation, ("class", desc_sig_space)],
|
||||||
[desc_addname, "example."],
|
[desc_addname, "example."],
|
||||||
[desc_name, "Class"])],
|
[desc_name, "Class"])],
|
||||||
[desc_content, nodes.field_list, nodes.field, (nodes.field_name,
|
[desc_content, nodes.field_list, nodes.field, (nodes.field_name,
|
||||||
|
Loading…
Reference in New Issue
Block a user