1
0
forked from VimPlug/jedi

fix docstrings that didn't work with multiple return classes of other modules (or in tuples)

This commit is contained in:
Dave Halter
2014-03-27 20:23:41 +01:00
parent 2f71bd4e63
commit fb34864ace

View File

@@ -19,7 +19,6 @@ from textwrap import dedent
from jedi.evaluate.cache import memoize_default from jedi.evaluate.cache import memoize_default
from jedi.parser import Parser from jedi.parser import Parser
from jedi.parser import representation as pr
from jedi.common import indent_block from jedi.common import indent_block
DOCSTRING_PARAM_PATTERNS = [ DOCSTRING_PARAM_PATTERNS = [
@@ -41,17 +40,15 @@ def follow_param(evaluator, param):
param_str = _search_param_in_docstr(func.raw_doc, str(param.get_name())) param_str = _search_param_in_docstr(func.raw_doc, str(param.get_name()))
code = dedent(""" code = dedent("""
def PseudoDocstring(): def pseudo_docstring_stuff():
'''Create a pseudo function for docstring statements.''' '''Create a pseudo function for docstring statements.'''
%s %s
""") """)
if param_str is not None: if param_str is not None:
# Try to import module part in dotted name. for element in re.findall('((?:\w+\.)*\w+)\.', param_str):
# (e.g., 'threading' in 'threading.Thread'). # Try to import module part in dotted name.
if '.' in param_str: # (e.g., 'threading' in 'threading.Thread').
param_str = 'import %s\n%s' % ( param_str = 'import %s\n' % element + param_str
param_str.rsplit('.', 1)[0],
param_str)
p = Parser(code % indent_block(param_str), no_docstr=True) p = Parser(code % indent_block(param_str), no_docstr=True)
pseudo_cls = p.module.subscopes[0] pseudo_cls = p.module.subscopes[0]