1
0
forked from VimPlug/jedi

Better documentation of Script

This commit is contained in:
Dave Halter
2020-03-14 16:48:07 +01:00
parent e811651b00
commit 7b725553ff

View File

@@ -6,8 +6,6 @@ Additionally you can add a debug function with :func:`set_debug_function`.
Alternatively, if you don't need a custom function and are happy with printing Alternatively, if you don't need a custom function and are happy with printing
debug messages to stdout, simply call :func:`set_debug_function` without debug messages to stdout, simply call :func:`set_debug_function` without
arguments. arguments.
.. warning:: Please, note that Jedi is **not thread safe**.
""" """
import os import os
import sys import sys
@@ -83,9 +81,9 @@ class Script(object):
:param source: The source code of the current file, separated by newlines. :param source: The source code of the current file, separated by newlines.
:type source: str :type source: str
:param line: Deprecated, please use it directly on e.g. `.complete` :param line: Deprecated, please use it directly on e.g. ``.complete``
:type line: int :type line: int
:param column: Deprecated, please use it directly on e.g. `.complete` :param column: Deprecated, please use it directly on e.g. ``.complete``
:type column: int :type column: int
:param path: The path of the file in the file system, or ``''`` if :param path: The path of the file in the file system, or ``''`` if
it hasn't been saved yet. it hasn't been saved yet.
@@ -93,10 +91,10 @@ class Script(object):
:param encoding: The encoding of ``source``, if it is not a :param encoding: The encoding of ``source``, if it is not a
``unicode`` object (default ``'utf-8'``). ``unicode`` object (default ``'utf-8'``).
:type encoding: str :type encoding: str
:param sys_path: ``sys.path`` to use during analysis of the script :param sys_path: Deprecated, use the project parameter.
:type sys_path: list :type sys_path: list of str
:param environment: TODO :param Environment environment: Provide a predefined environment to work
:type environment: Environment with a specific Python version or virtualenv.
""" """
def __init__(self, source=None, line=None, column=None, path=None, def __init__(self, source=None, line=None, column=None, path=None,
encoding='utf-8', sys_path=None, environment=None, encoding='utf-8', sys_path=None, environment=None,
@@ -389,14 +387,17 @@ class Script(object):
@validate_line_column @validate_line_column
def help(self, line=None, column=None): def help(self, line=None, column=None):
""" """
Works like goto and returns a list of Definition objects. Returns Used to display a help window to users. Uses :meth:`.Script.goto` and
additional definitions for keywords and operators. returns additional definitions for keywords and operators.
The additional definitions are of ``Definition(...).type == 'keyword'``. Typically you will want to display :meth:`.BaseDefinition.docstring` to the
user for all the returned definitions.
The additional definitions are ``Definition(...).type == 'keyword'``.
These definitions do not have a lot of value apart from their docstring These definitions do not have a lot of value apart from their docstring
attribute, which contains the output of Python's ``help()`` function. attribute, which contains the output of Python's :func:`help` function.
:rtype: list of :class:`classes.Definition` :rtype: list of :class:`.Definition`
""" """
definitions = self.goto(line, column, follow_imports=True) definitions = self.goto(line, column, follow_imports=True)
if definitions: if definitions:
@@ -416,10 +417,9 @@ class Script(object):
@validate_line_column @validate_line_column
def get_references(self, line=None, column=None, **kwargs): def get_references(self, line=None, column=None, **kwargs):
""" """
Return :class:`.Definition` objects, which contain all Lists all references of a variable in a project. Since this can be
names that point to the definition of the name under the cursor. This quite hard to do for Jedi, if it is too complicated, Jedi will stop
is very useful for refactoring (renaming), or to show all references of searching.
a variable.
:param include_builtins: Default True, checks if a reference is a :param include_builtins: Default True, checks if a reference is a
builtin (e.g. ``sys``) and in that case does not return it. builtin (e.g. ``sys``) and in that case does not return it.