rstudio / rmarkdown

Dynamic Documents for R
https://rmarkdown.rstudio.com
GNU General Public License v3.0
2.86k stars 969 forks source link

rmarkdown::run with multiple shiny_prerendered documents #2037

Open aronatkins opened 3 years ago

aronatkins commented 3 years ago

Using rmarkdown 2.6

Given a directory with multiple Rmd containing runtime: shiny_prerendered, only one of the documents is served by rmarkdown::run. This behavior is different than we see with multiple runtime: shiny documents.

First file (named empty.Rmd):

---
title: "empty.Rmd"
output: html_document
runtime: shiny_prerendered
---

[second](second.Rmd)

```{r, echo=FALSE}
textOutput("message")
output$message <- renderText({
  "This is the empty.Rmd file"
})

Second file (named `second.Rmd`):

````markdown
---
title: "second.Rmd"
output: html_document
runtime: shiny_prerendered
---

[empty](empty.Rmd)

```{r, echo=FALSE}
textOutput("message")
output$message <- renderText({
  "This is the second.Rmd file"
})

Launch the content with:

```r
rmarkdown::run(file=NULL, dir=".")

Only one of the two files is served. In my case, it was always empty.Rmd (the alphabetically first file).

Both documents can be served if you change runtime: shiny_prerendered to runtime: shiny.

The expectations for rmarkdown::run (at least for runtime: shiny documents):


By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

cderv commented 3 years ago

Hi @aronatkins,

I think this is a duplicate of #1576 which I recently asked @schloerke about. It is currently the way prerendered document are working as it will pre render the app UI before running based on one Rmd (or html) file.

Currently, the document to serve at the root url if not provided (default_file) is

This logic is the same for both runtime but with prerendered not being able to render according to a new route as with runtime shiny (which render on the run unlike pre rendered). it seems only one Rmd makes sense for shiny prerendered document.

So this is definitly something to look into with the help of the shiny team if we want to support this.