Skip to content

Commit

Permalink
Follow up to #159: auto-detect language in append_shinylive_chunk() (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Jun 18, 2024
1 parent c1f595d commit 1eec556
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion 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 Down

0 comments on commit 1eec556

Please sign in to comment.