Skip to content

Commit 054f493

Browse files
authored
docs(examples): Use refactored shinylive syntax (#1048)
1 parent 39bcfdd commit 054f493

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ doc =
102102
jupyter
103103
jupyter_client < 8.0.0
104104
tabulate
105-
shinylive @ git+https://github.com/posit-dev/py-shinylive.git@main
105+
shinylive @ git+https://github.com/posit-dev/py-shinylive.git
106106
pydantic==1.10
107107
quartodoc==0.7.2
108108
griffe==0.33.0

shiny/_docstring.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -177,29 +177,19 @@ def _(func: F) -> F:
177177
# This part is hidden from the typechecker because shinylive is not a direct
178178
# dependency of shiny and we only need this section when building the docs.
179179
try:
180-
import shinylive
180+
from shinylive import ShinyliveApp
181+
except ImportError:
182+
raise RuntimeError(
183+
"Please install the latest version of shinylive to build the docs."
184+
)
181185
except ModuleNotFoundError:
182186
raise RuntimeError("Please install shinylive to build the docs.")
183187

184-
SHINYLIVE_CODE_TEMPLATE = """
185-
```{{shinylive-python}}
186-
#| standalone: true
187-
#| components: [editor, viewer]
188-
#| layout: vertical
189-
#| viewerHeight: 400
190-
191-
{0}
192-
```
193-
"""
194-
195188
class ShinyliveExampleWriter(ExampleWriter):
196189
def write_example(self, app_files: list[str]) -> str:
197190
app_file = app_files.pop(0)
198-
bundle = shinylive._url.create_shinylive_bundle_file(
199-
app_file, app_files, language="py"
200-
)
201-
code = shinylive._url.create_shinylive_chunk_contents(bundle)
191+
app = ShinyliveApp.from_local(app_file, app_files, language="py")
202192

203-
return SHINYLIVE_CODE_TEMPLATE.format(code.strip())
193+
return app.to_chunk(layout="vertical", viewer_height=400)
204194

205195
example_writer = ShinyliveExampleWriter()

0 commit comments

Comments
 (0)