From 94f99aaeb3c18a6f0f27348f4635828fb8a3a757 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sat, 14 Mar 2020 15:25:03 +0100 Subject: [PATCH] Docs: Document projects --- jedi/api/__init__.py | 2 ++ jedi/api/project.py | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 64122f45..a0f1958a 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -650,6 +650,8 @@ class Script(object): def inline(self, line=None, column=None): """ Inlines a variable under the cursor. + + :rtype: :class:`refactoring.Refactoring` """ names = [d._name for d in self.get_references(line, column, include_builtins=True)] return refactoring.inline(self._inference_state, names) diff --git a/jedi/api/project.py b/jedi/api/project.py index 279c554b..041ad984 100644 --- a/jedi/api/project.py +++ b/jedi/api/project.py @@ -60,7 +60,9 @@ def _force_unicode_list(lst): 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 @@ -75,6 +77,9 @@ class Project(object): @classmethod 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. """ 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 python_path: The Python executable path, typically the path of a 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, this is potentially unsafe if you clone a git repository and analyze it's code, because those compiled extensions will be important and therefore have execution privileges. :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). :param added_sys_path: list of str. Adds these paths at the end of the sys path. @@ -175,6 +180,9 @@ class Project(object): return list(_force_unicode_list(_remove_duplicates_from_path(path))) def save(self): + """ + Saves the project configuration in the project in ``.jedi/project.json``. + """ data = dict(self.__dict__) data.pop('_environment', None) data.pop('_django', None) # TODO make django setting public?