forked from VimPlug/jedi
Merge branch 'dev' of github.com:davidhalter/jedi into docrtypes
This commit is contained in:
+2
-5
@@ -167,6 +167,8 @@ html_static_path = ['_static']
|
|||||||
# Output file base name for HTML help builder.
|
# Output file base name for HTML help builder.
|
||||||
htmlhelp_basename = 'Jedidoc'
|
htmlhelp_basename = 'Jedidoc'
|
||||||
|
|
||||||
|
html_style = '/default.css' # Force usage of default template on RTD
|
||||||
|
|
||||||
|
|
||||||
# -- Options for LaTeX output --------------------------------------------------
|
# -- Options for LaTeX output --------------------------------------------------
|
||||||
|
|
||||||
@@ -249,8 +251,3 @@ todo_include_todos = False
|
|||||||
# -- Options for autodoc module ------------------------------------------------
|
# -- Options for autodoc module ------------------------------------------------
|
||||||
|
|
||||||
autodoc_default_flags = ['members', 'undoc-members']
|
autodoc_default_flags = ['members', 'undoc-members']
|
||||||
|
|
||||||
|
|
||||||
# -- Options for readthedocs ---------------------------------------------------
|
|
||||||
|
|
||||||
html_style = True # Force usage of default template on RTD
|
|
||||||
|
|||||||
@@ -135,6 +135,9 @@ class Script(object):
|
|||||||
l = self._module.get_line(self.pos[0])[:self.pos[1]]
|
l = self._module.get_line(self.pos[0])[:self.pos[1]]
|
||||||
if not l.endswith('import import'):
|
if not l.endswith('import import'):
|
||||||
continue
|
continue
|
||||||
|
a = s.import_stmt.alias
|
||||||
|
if a and a.start_pos <= self.pos <= a.end_pos:
|
||||||
|
continue
|
||||||
names = s.get_defined_names(on_import_stmt=True)
|
names = s.get_defined_names(on_import_stmt=True)
|
||||||
else:
|
else:
|
||||||
names = s.get_defined_names()
|
names = s.get_defined_names()
|
||||||
|
|||||||
+31
-13
@@ -104,6 +104,14 @@ class ImportPath(parsing.Base):
|
|||||||
for i in range(self.import_stmt.relative_count - 1):
|
for i in range(self.import_stmt.relative_count - 1):
|
||||||
path = os.path.dirname(path)
|
path = os.path.dirname(path)
|
||||||
names += self.get_module_names([path])
|
names += self.get_module_names([path])
|
||||||
|
|
||||||
|
if self.import_stmt.relative_count:
|
||||||
|
rel_path = self.get_relative_path() + '/__init__.py'
|
||||||
|
try:
|
||||||
|
m = modules.Module(rel_path)
|
||||||
|
names += m.parser.module.get_defined_names()
|
||||||
|
except IOError:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
if on_import_stmt and isinstance(scope, parsing.Module) \
|
if on_import_stmt and isinstance(scope, parsing.Module) \
|
||||||
and scope.path.endswith('__init__.py'):
|
and scope.path.endswith('__init__.py'):
|
||||||
@@ -158,8 +166,7 @@ class ImportPath(parsing.Base):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
scopes = [scope]
|
scopes = [scope]
|
||||||
scopes += itertools.chain.from_iterable(
|
scopes += remove_star_imports(scope)
|
||||||
remove_star_imports(s) for s in scopes)
|
|
||||||
|
|
||||||
# follow the rest of the import (not FS -> classes, functions)
|
# follow the rest of the import (not FS -> classes, functions)
|
||||||
if len(rest) > 1 or rest and self.is_like_search:
|
if len(rest) > 1 or rest and self.is_like_search:
|
||||||
@@ -184,20 +191,23 @@ class ImportPath(parsing.Base):
|
|||||||
evaluate.follow_statement.pop_stmt()
|
evaluate.follow_statement.pop_stmt()
|
||||||
return scopes
|
return scopes
|
||||||
|
|
||||||
|
def get_relative_path(self):
|
||||||
|
path = self.file_path
|
||||||
|
for i in range(self.import_stmt.relative_count - 1):
|
||||||
|
path = os.path.dirname(path)
|
||||||
|
return path
|
||||||
|
|
||||||
def _follow_file_system(self):
|
def _follow_file_system(self):
|
||||||
"""
|
"""
|
||||||
Find a module with a path (of the module, like usb.backend.libusb10).
|
Find a module with a path (of the module, like usb.backend.libusb10).
|
||||||
"""
|
"""
|
||||||
def follow_str(ns, string):
|
def follow_str(ns_path, string):
|
||||||
debug.dbg('follow_module', ns, string)
|
debug.dbg('follow_module', ns_path, string)
|
||||||
path = None
|
path = None
|
||||||
if ns:
|
if ns_path:
|
||||||
path = ns[1]
|
path = ns_path
|
||||||
elif self.import_stmt.relative_count:
|
elif self.import_stmt.relative_count:
|
||||||
module = self.import_stmt.get_parent_until()
|
path = self.get_relative_path()
|
||||||
path = os.path.abspath(module.path)
|
|
||||||
for i in range(self.import_stmt.relative_count):
|
|
||||||
path = os.path.dirname(path)
|
|
||||||
|
|
||||||
global imports_processed
|
global imports_processed
|
||||||
imports_processed += 1
|
imports_processed += 1
|
||||||
@@ -222,14 +232,22 @@ class ImportPath(parsing.Base):
|
|||||||
else:
|
else:
|
||||||
sys_path_mod = list(builtin.get_sys_path())
|
sys_path_mod = list(builtin.get_sys_path())
|
||||||
|
|
||||||
current_namespace = None
|
current_namespace = (None, None, None)
|
||||||
# now execute those paths
|
# now execute those paths
|
||||||
rest = []
|
rest = []
|
||||||
for i, s in enumerate(self.import_path):
|
for i, s in enumerate(self.import_path):
|
||||||
try:
|
try:
|
||||||
current_namespace = follow_str(current_namespace, s)
|
current_namespace = follow_str(current_namespace[1], s)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
if current_namespace:
|
if self.import_stmt.relative_count \
|
||||||
|
and len(self.import_path) == 1:
|
||||||
|
# follow `from . import some_variable`
|
||||||
|
rel_path = self.get_relative_path()
|
||||||
|
try:
|
||||||
|
current_namespace = follow_str(rel_path, '__init__')
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
if current_namespace[1]:
|
||||||
rest = self.import_path[i:]
|
rest = self.import_path[i:]
|
||||||
else:
|
else:
|
||||||
raise ModuleNotFound(
|
raise ModuleNotFound(
|
||||||
|
|||||||
+4
-1
@@ -23,8 +23,11 @@ class Module(builtin.CachedModule):
|
|||||||
:param path: The module path of the file.
|
:param path: The module path of the file.
|
||||||
:param source: The source code of the file.
|
:param source: The source code of the file.
|
||||||
"""
|
"""
|
||||||
def __init__(self, path, source):
|
def __init__(self, path, source=None):
|
||||||
super(Module, self).__init__(path=path)
|
super(Module, self).__init__(path=path)
|
||||||
|
if source is None:
|
||||||
|
with open(path) as f:
|
||||||
|
source = f.read()
|
||||||
self.source = source_to_unicode(source)
|
self.source = source_to_unicode(source)
|
||||||
self._line_cache = None
|
self._line_cache = None
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
""" needed for some modules to test against packages. """
|
||||||
|
|
||||||
|
some_variable = 1
|
||||||
@@ -115,6 +115,12 @@ mod1.a
|
|||||||
#! ['a=1.0']
|
#! ['a=1.0']
|
||||||
from import_tree.pkg.mod1 import a
|
from import_tree.pkg.mod1 import a
|
||||||
|
|
||||||
|
#! ['import os']
|
||||||
|
from .imports import os
|
||||||
|
|
||||||
|
#! ['some_variable=1']
|
||||||
|
from . import some_variable
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# anonymous classes
|
# anonymous classes
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
@@ -175,6 +175,13 @@ mod1.
|
|||||||
#? str()
|
#? str()
|
||||||
imp_tree.a
|
imp_tree.a
|
||||||
|
|
||||||
|
#? ['some_variable']
|
||||||
|
from . import some_variable
|
||||||
|
#? ['arrays']
|
||||||
|
from . import arrays
|
||||||
|
#? []
|
||||||
|
from . import import_tree as ren
|
||||||
|
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# special positions -> edge cases
|
# special positions -> edge cases
|
||||||
|
|||||||
Reference in New Issue
Block a user