Skip to content

Commit

Permalink
refactor: use newer py-shinylive syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
gadenbuie committed Jan 24, 2024
1 parent 506e743 commit 102ef03
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions shiny/_docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 102ef03

Please sign in to comment.