Skip to content

Commit

Permalink
Merge branch 'main' into add-testing-section
Browse files Browse the repository at this point in the history
  • Loading branch information
karangattu authored Jun 25, 2024
2 parents 60dca06 + 345fc3e commit 8aae4c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions docs/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def append_file(self, file_path: str, file_name: Optional[str] = None):
def append_shinylive_chunk(
self,
files: list[str] | str,
language: str = "py",
language: Literal["auto", "py", "r"] = "auto",
**kwargs,
):
if isinstance(files, str):
Expand All @@ -32,6 +32,9 @@ def append_shinylive_chunk(
else:
app_file = files.pop(0)

if language == "auto":
language = "py" if app_file.endswith(".py") else "r"

app = ShinyliveApp.from_local(app_file, files, language)

self.append(app.to_chunk(**kwargs))
Expand All @@ -42,10 +45,12 @@ def shinylive_chunk(
components: Sequence[str] = ("editor", "viewer"),
viewer_height: str = "400",
layout: Literal["horizontal", "vertical"] = "horizontal",
language: Literal["py", "r"] = "py",
):
lang = "python" if language == "py" else "r"
block = QuartoPrint(
[
"```{shinylive-python}",
f"```{{shinylive-{lang}}}",
"#| standalone: true",
f"#| components: [{', '.join(components)}]",
f"#| layout: {layout}",
Expand Down Expand Up @@ -80,9 +85,10 @@ def _include_shiny_folder(
folder_path = Path(__name__).parent / path

# Start with the header
lang = "python" if file_name.endswith(".py") else "r"
block = QuartoPrint(
[
"```{shinylive-python}",
f"```{{shinylive-{lang}}}",
"#| standalone: true",
f"#| components: [{', '.join(components)}]",
"#| layout: horizontal",
Expand Down Expand Up @@ -230,10 +236,11 @@ def express_core_preview(
continue

sl_app = ShinyliveApp.from_local(app_file, files, language)
lang = "python" if language == "py" else "r"

block.append("### " + tab_name)
block.append(
'```{.python .code-overflow-scroll shinylive="' + sl_app.to_url() + '"}'
f'```{{.{lang} .code-overflow-scroll shinylive="{sl_app.to_url()}"}}'
)
block.append_file(app_file)
block.extend(["```", ""])
Expand Down
Binary file modified templates/database-explorer/thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8aae4c3

Please sign in to comment.