1
0
forked from VimPlug/jedi

pydoc works now with operators and keywords

This commit is contained in:
David Halter
2012-09-06 01:55:52 +02:00
parent 730dfdc012
commit a238985ed8
4 changed files with 49 additions and 7 deletions

View File

@@ -9,6 +9,7 @@ import modules
import debug
import imports
import settings
import keywords
from _compatibility import next
@@ -105,6 +106,8 @@ class Definition(object):
elif isinstance(d, evaluate.parsing.Module):
# only show module name
d = 'module %s' % self.module_name
elif isinstance(d, keywords.Keyword):
d = 'keyword %s' % d.name
else:
d = d.get_code().replace('\n', '')
return d
@@ -243,10 +246,18 @@ def get_definition(source, line, column, source_path):
context = f.get_context()
if next(context) in ('class', 'def'):
scopes = [f.parser.user_scope]
scopes = set([f.parser.user_scope])
elif not goto_path:
op = f.get_operator_under_cursor()
scopes = set([keywords.get_operator(op)])
else:
scopes = _prepare_goto(source, pos, source_path, f, goto_path)
d = [Definition(s) for s in set(scopes)]
# add keywords
scopes |= keywords.get_keywords(string=goto_path)
d = set([Definition(s) for s in scopes])
_clear_caches()
return d