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