Docs: Document projects

This commit is contained in:
Dave Halter
2020-03-14 15:25:03 +01:00
parent 851980e2a9
commit 94f99aaeb3
2 changed files with 13 additions and 3 deletions

View File

@@ -650,6 +650,8 @@ class Script(object):
def inline(self, line=None, column=None): def inline(self, line=None, column=None):
""" """
Inlines a variable under the cursor. Inlines a variable under the cursor.
:rtype: :class:`refactoring.Refactoring`
""" """
names = [d._name for d in self.get_references(line, column, include_builtins=True)] names = [d._name for d in self.get_references(line, column, include_builtins=True)]
return refactoring.inline(self._inference_state, names) return refactoring.inline(self._inference_state, names)

View File

@@ -60,7 +60,9 @@ def _force_unicode_list(lst):
class Project(object): class Project(object):
""" """
XXX Projects are a simple way to manage Python folders and define how Jedi does
import resolution. It is mostly used as a parameter to :class:`.Script`.
Additionally there are functions to search a whole project.
""" """
_environment = None _environment = None
@@ -75,6 +77,9 @@ class Project(object):
@classmethod @classmethod
def load(cls, path): def load(cls, path):
""" """
Loads a project from a specific path. You should not provide the path
to ``.jedi/project.json``, but rather the path to the project folder.
:param path: The path of the directory you want to use as a project. :param path: The path of the directory you want to use as a project.
""" """
with open(cls._get_json_path(path)) as f: with open(cls._get_json_path(path)) as f:
@@ -92,13 +97,13 @@ class Project(object):
:param path: The base path for this project. :param path: The base path for this project.
:param python_path: The Python executable path, typically the path of a :param python_path: The Python executable path, typically the path of a
virtual environment. virtual environment.
:param load_unsafe_extensions: Loads extensions that are not in the :param load_unsafe_extensions: Default False, Loads extensions that are not in the
sys path and in the local directories. With this option enabled, sys path and in the local directories. With this option enabled,
this is potentially unsafe if you clone a git repository and this is potentially unsafe if you clone a git repository and
analyze it's code, because those compiled extensions will be analyze it's code, because those compiled extensions will be
important and therefore have execution privileges. important and therefore have execution privileges.
:param sys_path: list of str. You can override the sys path if you :param sys_path: list of str. You can override the sys path if you
want. By default the ``sys.path.`` is generated from the want. By default the ``sys.path.`` is generated by the
environment (virtualenvs, etc). environment (virtualenvs, etc).
:param added_sys_path: list of str. Adds these paths at the end of the :param added_sys_path: list of str. Adds these paths at the end of the
sys path. sys path.
@@ -175,6 +180,9 @@ class Project(object):
return list(_force_unicode_list(_remove_duplicates_from_path(path))) return list(_force_unicode_list(_remove_duplicates_from_path(path)))
def save(self): def save(self):
"""
Saves the project configuration in the project in ``.jedi/project.json``.
"""
data = dict(self.__dict__) data = dict(self.__dict__)
data.pop('_environment', None) data.pop('_environment', None)
data.pop('_django', None) # TODO make django setting public? data.pop('_django', None) # TODO make django setting public?