From 59219ab287c7a8ee15c86340df84d4836decddb2 Mon Sep 17 00:00:00 2001 From: Devin Smith Date: Mon, 11 Dec 2023 08:17:04 -0800 Subject: [PATCH 1/5] Updates JsPlugin distribution_path to root In addition, updates JsPlugin documentation to be consistent with https://github.com/deephaven/deephaven-core/pull/4925 Fixes #15 --- src/deephaven/plugin/js.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/deephaven/plugin/js.py b/src/deephaven/plugin/js.py index 39fc743..d046a36 100644 --- a/src/deephaven/plugin/js.py +++ b/src/deephaven/plugin/js.py @@ -6,29 +6,44 @@ class JsPlugin(Plugin): - """A js plugin. Useful for adding custom JS code to the server that can be passed to the web client.""" + """ + A JS plugin is a Plugin that allows adding javascript code under the server's URL path "js-plugins/". + See https://github.com/deephaven/deephaven-plugins#js-plugins for more details about the underlying + construction for JS plugins. + """ @abc.abstractmethod - def distribution_path(self) -> typing.Generator[pathlib.Path, None, None]: - """A generator that yields the distribution path directory.""" + def root(self) -> typing.Generator[pathlib.Path, None, None]: + """ + The root directory of the resources to serve. The root must exist. + """ pass @property @abc.abstractmethod def name(self) -> str: - """The plugin name""" + """ + The JS plugin name. The JS plugin contents will be served via the URL path "js-plugins/{name}/", + as well as included as the "name" field for the manifest entry in "js-plugins/manifest.json". + """ pass @property @abc.abstractmethod def version(self) -> str: - """The plugin version""" + """ + The JS plugin version. Will be included as the "version" field for the manifest entry in + js-plugins/manifest.json". + """ pass @property @abc.abstractmethod def main(self) -> str: - """The main js file, the relative path with respect to distribution_path.""" + """ + The main JS file path, specified relative to root. The main JS file must exist. Will be included + as the "main" field for the manifest entry in "js-plugins/manifest.json". + """ pass def __str__(self) -> str: From 329d602d6a987185e9b37e3acfffd8f9ae20b6b2 Mon Sep 17 00:00:00 2001 From: Devin Smith Date: Mon, 11 Dec 2023 12:00:54 -0800 Subject: [PATCH 2/5] Update typing to ContextManager --- src/deephaven/plugin/js.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/deephaven/plugin/js.py b/src/deephaven/plugin/js.py index d046a36..e8002c3 100644 --- a/src/deephaven/plugin/js.py +++ b/src/deephaven/plugin/js.py @@ -13,9 +13,9 @@ class JsPlugin(Plugin): """ @abc.abstractmethod - def root(self) -> typing.Generator[pathlib.Path, None, None]: + def root(self) -> typing.ContextManager[pathlib.Path]: """ - The root directory of the resources to serve. The root must exist. + The root directory of the resources to serve in a context manager. The root must exist. """ pass From 064249f82093a14fe81e720f763dfb6c70726176 Mon Sep 17 00:00:00 2001 From: Devin Smith Date: Tue, 12 Dec 2023 09:17:23 -0800 Subject: [PATCH 3/5] Update from root to root_path --- src/deephaven/plugin/js.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/deephaven/plugin/js.py b/src/deephaven/plugin/js.py index e8002c3..8abcb68 100644 --- a/src/deephaven/plugin/js.py +++ b/src/deephaven/plugin/js.py @@ -13,9 +13,9 @@ class JsPlugin(Plugin): """ @abc.abstractmethod - def root(self) -> typing.ContextManager[pathlib.Path]: + def root_path(self) -> typing.ContextManager[pathlib.Path]: """ - The root directory of the resources to serve in a context manager. The root must exist. + The root directory path of the resources to serve in a context manager. The root path must exist. """ pass From 79ead8bc3a5736c67d581c12b4979ca3af70edfd Mon Sep 17 00:00:00 2001 From: Devin Smith Date: Tue, 12 Dec 2023 12:50:43 -0800 Subject: [PATCH 4/5] Update name to path --- src/deephaven/plugin/js.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/deephaven/plugin/js.py b/src/deephaven/plugin/js.py index 8abcb68..6d59b1b 100644 --- a/src/deephaven/plugin/js.py +++ b/src/deephaven/plugin/js.py @@ -13,9 +13,9 @@ class JsPlugin(Plugin): """ @abc.abstractmethod - def root_path(self) -> typing.ContextManager[pathlib.Path]: + def path(self) -> typing.ContextManager[pathlib.Path]: """ - The root directory path of the resources to serve in a context manager. The root path must exist. + The directory path of the resources to serve in a context manager. """ pass From b0572ed251fb05c0e78cd0865d43d1f62c76a36a Mon Sep 17 00:00:00 2001 From: Devin Smith Date: Tue, 12 Dec 2023 16:31:25 -0800 Subject: [PATCH 5/5] Change return type of path to pathlib.Path --- src/deephaven/plugin/js.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/deephaven/plugin/js.py b/src/deephaven/plugin/js.py index 6d59b1b..055f9bf 100644 --- a/src/deephaven/plugin/js.py +++ b/src/deephaven/plugin/js.py @@ -13,9 +13,9 @@ class JsPlugin(Plugin): """ @abc.abstractmethod - def path(self) -> typing.ContextManager[pathlib.Path]: + def path(self) -> pathlib.Path: """ - The directory path of the resources to serve in a context manager. + The directory path of the resources to serve. The path must exist. """ pass