diff --git a/docs/helpers.py b/docs/helpers.py index 57d45c7..9b5fee6 100644 --- a/docs/helpers.py +++ b/docs/helpers.py @@ -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): @@ -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))