forked from VimPlug/jedi
Add new API: jedi.api.get_definitions
This commit is contained in:
19
jedi/api.py
19
jedi/api.py
@@ -468,6 +468,25 @@ class Script(object):
|
||||
api_classes._clear_caches()
|
||||
|
||||
|
||||
def get_definitions(source, source_path=None, source_encoding='utf-8'):
|
||||
"""
|
||||
Get all definitions in `source` sorted by its position.
|
||||
|
||||
This functions can be used for listing functions, classes and
|
||||
data defined in a file. This can be useful if you want to list
|
||||
them in "sidebar". Each element in the returned list also has
|
||||
`get_definition` method which can be used to get sub-definitions
|
||||
(e.g., methods in class).
|
||||
|
||||
:rtype: list of api_classes.Definition
|
||||
"""
|
||||
parser = parsing.Parser(
|
||||
modules.source_to_unicode(source, source_encoding),
|
||||
module_path=source_path,
|
||||
)
|
||||
return api_classes.get_definitions(parser.scope)
|
||||
|
||||
|
||||
def set_debug_function(func_cb=debug.print_to_stdout, warnings=True,
|
||||
notices=True, speed=True):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user