diff --git a/setup.cfg b/setup.cfg index 46d7999dc..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@main + shinylive @ git+https://github.com/posit-dev/py-shinylive.git pydantic==1.10 quartodoc==0.7.2 griffe==0.33.0 diff --git a/shiny/_docstring.py b/shiny/_docstring.py index c177e4ebc..a45a4edce 100644 --- a/shiny/_docstring.py +++ b/shiny/_docstring.py @@ -177,29 +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.") - 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 = ShinyliveApp.from_local(app_file, app_files, language="py") - return SHINYLIVE_CODE_TEMPLATE.format(code.strip()) + return app.to_chunk(layout="vertical", viewer_height=400) example_writer = ShinyliveExampleWriter()