forked from VimPlug/jedi
import statement doc works now -> fixes davidhalter/jedi-vim#44
This commit is contained in:
@@ -34,7 +34,10 @@ class BaseDefinition(object):
|
||||
self.is_keyword = isinstance(definition, keywords.Keyword)
|
||||
|
||||
# generate a path to the definition
|
||||
try:
|
||||
self.module_path = str(definition.get_parent_until().path)
|
||||
except AttributeError:
|
||||
self.module_path = None
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
@@ -206,7 +209,6 @@ class Definition(BaseDefinition):
|
||||
`Script.get_definition`. """
|
||||
def __init__(self, definition):
|
||||
super(Definition, self).__init__(definition, definition.start_pos)
|
||||
self._def_parent = definition.parent # just here to limit gc
|
||||
|
||||
@property
|
||||
def description(self):
|
||||
@@ -229,6 +231,8 @@ class Definition(BaseDefinition):
|
||||
d = 'module %s' % self.module_name
|
||||
elif self.is_keyword:
|
||||
d = 'keyword %s' % d.name
|
||||
elif isinstance(d, type(imports.ImportPath.GlobalNamespace)):
|
||||
d = 'Global Namespace'
|
||||
else:
|
||||
d = d.get_code().replace('\n', '')
|
||||
return d
|
||||
|
||||
@@ -35,6 +35,13 @@ class ImportPath(parsing.Base):
|
||||
def get_imports(self):
|
||||
return []
|
||||
|
||||
@property
|
||||
def start_pos(self):
|
||||
return (0, 0)
|
||||
|
||||
def get_parent_until(self):
|
||||
return None
|
||||
|
||||
GlobalNamespace = _GlobalNamespace()
|
||||
|
||||
def __init__(self, import_stmt, is_like_search=False, kill_count=0,
|
||||
|
||||
@@ -261,6 +261,10 @@ class TestRegression(Base):
|
||||
defs = self.get_def("print")
|
||||
assert [d.doc for d in defs]
|
||||
|
||||
defs = self.get_def("import")
|
||||
print [d.doc for d in defs]
|
||||
assert [d.doc for d in defs]
|
||||
|
||||
|
||||
class TestFeature(Base):
|
||||
def test_full_name(self):
|
||||
|
||||
Reference in New Issue
Block a user