rstudio/rstudio — pull request #104 by jmcphers (2014-04-16 21:20:15+00:00)
Title: Add IDE support for Shiny documents

This change adds IDE support for Shiny documents. Rough overview:

Shiny documents are identified via a `runtime: shiny` key in their YAML front matter. They have the following special treatment in the editor UI:
- Knit becomes 'Run Document' (shortcut key is the same)
- The format options dialog no longer allows format switching

The same process that services regular R Markdown render now also handles Shiny documents. When run with a Shiny document, the process stays alive (and the console tab remains open for viewing output) while the Shiny app is running. As with regular Shiny applications, the lifetime of the process is tied to the Shiny document viewer window: closing the window will terminate the process, and vice-versa.

When a document that contains Shiny application objects is rendered in a static R Markdown doc, the IDE picks up the warning string emitted and displays some UI that allows the user to re-render as a Shiny doc to see the dynamic content. It's also possible to see the static content, or to permanently mark the doc as a Shiny doc.

Two work items that were on the border (we can put these on master later if we think they're worthwhile):
- Preservation of anchors and scroll positions doesn't work in Shiny documents. There are two challenges involved:
- Shiny documents have a different origin on the desktop, and so it's not possible to read or write their scroll position because of cross-site scripting rules. (This could be surmountable by implementing a back-channel method that uses native desktop code to read and write the positions)
- Shiny documents are loaded asynchronously, so we don't know when the content is ready to have its scroll position adjusted. In the worst case here we could have Shiny post a message when it's ready (as we do for `disconnected`).
- Debugging could be challenging because the code runs out of process. We discussed implementing a 'run for debug' option that runs it in process.