posit-dev / shiny-vscode

Shiny VS Code Extension
https://open-vsx.org/extension/posit/shiny
MIT License
26 stars 10 forks source link
python rstats shiny shiny-python shiny-r vscode-extension

Shiny - VS Code Extension

This is an extension to help launch Shiny applications. Shiny is a package for Python and R that is designed to make it easy to build interactive web applications with the powerful data and scientific features of Python and R.

Features

Run and Debug Shiny Apps

The main features of this extension are additional options in the Run button menu when editing an app.py or app.R file to "Run Shiny App" or "Debug Shiny App" (Python only).

Run app

It also provides a couple of code snippets in both Python and R:

For a complete Shiny for Python experience in VS Code, please visit our docs for more information, including instructions for configuring the type checker and debugger for use with Shiny.

Shinylive

You can use the extension to create shareable links to your apps using Shinylive, a free service for sharing Shiny apps via static hosting. Shinylive links encode the app's code and data in the URL, so you can share your app with others without needing to deploy it to a server. When the link is opened, the app runs in the user's browser using special version of Python or R that can run in the browser.

To create a Shinylive link from your app, you have two choices:

  1. For single-file apps, e.g. app.py or app.R, run the Create ShinyLive Link from Active File from the command palette with the app file open and active.

  2. For multi-file apps, select all of the files or directories you want to include in your Shinylive app in the Explorer pane. Then right click on the selection and choose Create ShinyLive Link from Selected Files.

The Shiny extension will ask you which app mode you want to use (display the app or show an editor next to the app) and what action to take (to open or copy the link).You can also configure these options in the extension settings.

For the reverse operation, use the Save App from Shinylive Link command in the command palette to save an app and its files from a Shinylive link. You'll be prompted to paste the Shinylive link and then to choose where the app will be saved in your workspace.

Extension Settings

This extension contributes the following settings for Python and R.

Python

Note that there is no setting for Python executable path or virtual environment. This extension uses whatever Python environment the VS Code Python extension thinks is active. If you find that the "Run Shiny App" and "Debug Shiny App" commands are launching with a different version of Python or different virtual environment than you intended, use the Python extension's Select Interpreter command to change it.

R

Shinylive