1
0
forked from VimPlug/jedi

Merge pull request #90 from jjay/master

Epydoc dosctrings support
This commit is contained in:
David Halter
2012-12-27 03:10:55 -08:00
2 changed files with 20 additions and 8 deletions

View File

@@ -5,6 +5,11 @@ import re
import evaluate import evaluate
import parsing import parsing
DOCSTRING_PARAM_PATTERNS = [
r'\s*:type\s+%s:\s*([\d\w_]+)', # Sphinx
r'\s*@type\s+%s:\s*([\d\w_]+)', # Epidoc
r'\s*%s\s+\(([^()]+)\)' # googley
]
#@cache.memoize_default() # TODO add #@cache.memoize_default() # TODO add
def follow_param(param): def follow_param(param):
@@ -21,15 +26,12 @@ def follow_param(param):
def search_param_in_docstr(docstr, param_str): def search_param_in_docstr(docstr, param_str):
lines = docstr.split('\n') lines = docstr.split('\n')
# look at #40 to see definitions of those params # look at #40 to see definitions of those params
sphinx_comp = ':type %s:' % param_str patterns = [ re.compile(p % re.escape(param_str)) for p in DOCSTRING_PARAM_PATTERNS ]
googley_comp = re.compile('\s*%s\s+\(([^()]+)\)' % re.escape(param_str))
for l in lines: for l in lines:
if l.startswith(sphinx_comp): for pattern in patterns:
return l.replace(sphinx_comp, '', 1).strip() match = pattern.match(l)
if match:
return match.group(1)
r = re.match(googley_comp, l)
if r is not None:
return r.group(1)
return None return None

View File

@@ -19,3 +19,13 @@ def g(a, b):
a a
#? #?
b b
def e(a, b):
""" asdfasdf
@type a: str
@param a: blablabla
"""
#? str()
a
#?
b