1
0
forked from VimPlug/jedi
This commit is contained in:
David Halter
2013-02-06 13:00:23 +01:00
parent 8cf783f2c3
commit 69137a48f0
6 changed files with 26 additions and 19 deletions

View File

@@ -18,17 +18,18 @@ import evaluate_representation as er
import parsing
DOCSTRING_PARAM_PATTERNS = [
r'\s*:type\s+%s:\s*([^\n]+)', # Sphinx
r'\s*@type\s+%s:\s*([^\n]+)', # Epidoc
r'\s*:type\s+%s:\s*([^\n]+)', # Sphinx
r'\s*@type\s+%s:\s*([^\n]+)', # Epidoc
]
DOCSTRING_RETURN_PATTERNS = [
re.compile(r'\s*:rtype:\s*([^\n]+)', re.M), # Sphinx
re.compile(r'\s*@rtype:\s*([^\n]+)', re.M), # Epidoc
re.compile(r'\s*:rtype:\s*([^\n]+)', re.M), # Sphinx
re.compile(r'\s*@rtype:\s*([^\n]+)', re.M), # Epidoc
]
REST_ROLE_PATTERN = re.compile(r':[^`]+:`([^`]+)`')
#@cache.memoize_default() # TODO add
def follow_param(param):
func = param.parent_function
@@ -68,7 +69,8 @@ def search_param_in_docstr(docstr, param_str):
"""
# look at #40 to see definitions of those params
patterns = [ re.compile(p % re.escape(param_str)) for p in DOCSTRING_PARAM_PATTERNS ]
patterns = [re.compile(p % re.escape(param_str))
for p in DOCSTRING_PARAM_PATTERNS]
for pattern in patterns:
match = pattern.search(docstr)
if match:
@@ -114,6 +116,7 @@ def find_return_types(func):
p.user_stmt.parent = func
return list(evaluate.follow_statement(p.user_stmt))
def search_return_in_docstr(code):
for p in DOCSTRING_RETURN_PATTERNS:
match = p.search(code)