mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-16 10:37:52 +08:00
Sphinx oneline param type declaration feature
allows for type definition in ":param keyword"
This commit is contained in:
@@ -3,13 +3,14 @@
|
||||
# -----------------
|
||||
# sphinx style
|
||||
# -----------------
|
||||
def f(a, b, c, d):
|
||||
def f(a, b, c, d, x):
|
||||
""" asdfasdf
|
||||
:param a: blablabla
|
||||
:type a: str
|
||||
:type b: (str, int)
|
||||
:type c: threading.Thread
|
||||
:type d: :class:`threading.Thread`
|
||||
:param str x: blablabla
|
||||
:rtype: dict
|
||||
"""
|
||||
#? str()
|
||||
@@ -22,23 +23,28 @@ def f(a, b, c, d):
|
||||
c.join
|
||||
#? ['join']
|
||||
d.join
|
||||
#? ['lower']
|
||||
x.lower
|
||||
|
||||
#? dict()
|
||||
f()
|
||||
|
||||
# wrong declarations
|
||||
def f(a, b):
|
||||
def f(a, b, x):
|
||||
"""
|
||||
:param a: Forgot type declaration
|
||||
:type a:
|
||||
:param b: Just something
|
||||
:type b: ``
|
||||
:rtype:
|
||||
:param x: Just something without type
|
||||
:rtype:
|
||||
"""
|
||||
#?
|
||||
a
|
||||
#?
|
||||
b
|
||||
#?
|
||||
x
|
||||
|
||||
#?
|
||||
f()
|
||||
|
||||
@@ -50,6 +50,16 @@ class TestDocstring(unittest.TestCase):
|
||||
names = [c.name for c in jedi.Script(s).completions()]
|
||||
assert 'start' in names
|
||||
|
||||
def test_docstrings_param_type(self):
|
||||
s = """
|
||||
def func(arg):
|
||||
'''
|
||||
:param str arg: some description
|
||||
'''
|
||||
arg."""
|
||||
names = [c.name for c in jedi.Script(s).completions()]
|
||||
assert 'join' in names
|
||||
|
||||
def test_docstrings_type_str(self):
|
||||
s = """
|
||||
def func(arg):
|
||||
|
||||
Reference in New Issue
Block a user