From 506e743740faf0a00e70648992dc19a5ae9a402c Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Mon, 22 Jan 2024 13:44:18 -0500 Subject: [PATCH 1/5] Use PR version of py-shinylive --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 46d7999dc..63abb7505 100644 --- a/setup.cfg +++ b/setup.cfg @@ -102,7 +102,7 @@ doc = jupyter jupyter_client < 8.0.0 tabulate - shinylive @ git+https://github.com/posit-dev/py-shinylive.git@main + shinylive @ git+https://github.com/posit-dev/py-shinylive.git@shinylive-bundle-class pydantic==1.10 quartodoc==0.7.2 griffe==0.33.0 From 102ef03917ce52f0a9ec34d65104cc0f64a02e9c Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Mon, 22 Jan 2024 13:46:23 -0500 Subject: [PATCH 2/5] refactor: use newer py-shinylive syntax --- shiny/_docstring.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/shiny/_docstring.py b/shiny/_docstring.py index c177e4ebc..da6f6ee89 100644 --- a/shiny/_docstring.py +++ b/shiny/_docstring.py @@ -181,25 +181,11 @@ def _(func: F) -> F: except ModuleNotFoundError: raise RuntimeError("Please install shinylive to build the docs.") - SHINYLIVE_CODE_TEMPLATE = """ -```{{shinylive-python}} -#| standalone: true -#| components: [editor, viewer] -#| layout: vertical -#| viewerHeight: 400 - -{0} -``` -""" - class ShinyliveExampleWriter(ExampleWriter): def write_example(self, app_files: list[str]) -> str: app_file = app_files.pop(0) - bundle = shinylive._url.create_shinylive_bundle_file( - app_file, app_files, language="py" - ) - code = shinylive._url.create_shinylive_chunk_contents(bundle) + app = shinylive.url_encode(app_file, app_files, language="py") - return SHINYLIVE_CODE_TEMPLATE.format(code.strip()) + return app.chunk(layout="vertical", viewerHeight=400) example_writer = ShinyliveExampleWriter() From 6cc7c05f4f734a7bb52b08ea050db25626d727ba Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Tue, 23 Jan 2024 13:32:14 -0500 Subject: [PATCH 3/5] update syntax for latest version of shinylive in PR --- shiny/_docstring.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/shiny/_docstring.py b/shiny/_docstring.py index da6f6ee89..8d5d02ba2 100644 --- a/shiny/_docstring.py +++ b/shiny/_docstring.py @@ -177,15 +177,19 @@ def _(func: F) -> F: # This part is hidden from the typechecker because shinylive is not a direct # dependency of shiny and we only need this section when building the docs. try: - import shinylive + from shinylive import ShinyliveApp + except ImportError: + raise RuntimeError( + "Please install the latest version of shinylive to build the docs." + ) except ModuleNotFoundError: raise RuntimeError("Please install shinylive to build the docs.") class ShinyliveExampleWriter(ExampleWriter): def write_example(self, app_files: list[str]) -> str: app_file = app_files.pop(0) - app = shinylive.url_encode(app_file, app_files, language="py") + app = ShinyliveApp.from_local(app_file, app_files, language="py") - return app.chunk(layout="vertical", viewerHeight=400) + return app.chunk(layout="vertical", viewer_height=400) example_writer = ShinyliveExampleWriter() From 9efdfb028b887c8549e3c18a83e2ec255cf63190 Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Wed, 24 Jan 2024 09:38:10 -0500 Subject: [PATCH 4/5] update syntax again `.to_chunk()` --- shiny/_docstring.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shiny/_docstring.py b/shiny/_docstring.py index 8d5d02ba2..a45a4edce 100644 --- a/shiny/_docstring.py +++ b/shiny/_docstring.py @@ -190,6 +190,6 @@ def write_example(self, app_files: list[str]) -> str: app_file = app_files.pop(0) app = ShinyliveApp.from_local(app_file, app_files, language="py") - return app.chunk(layout="vertical", viewer_height=400) + return app.to_chunk(layout="vertical", viewer_height=400) example_writer = ShinyliveExampleWriter() From 74e46ff5fd2c5b3184d9be619974880a2ba1d021 Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Wed, 24 Jan 2024 14:42:15 -0500 Subject: [PATCH 5/5] use py-shinylive from main --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 63abb7505..ec04d972f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -102,7 +102,7 @@ doc = jupyter jupyter_client < 8.0.0 tabulate - shinylive @ git+https://github.com/posit-dev/py-shinylive.git@shinylive-bundle-class + shinylive @ git+https://github.com/posit-dev/py-shinylive.git pydantic==1.10 quartodoc==0.7.2 griffe==0.33.0