Search code examples
rshinyroxygen2

Document a shiny application


Is there any way to generate documentation for a R shiny application?

It becomes very hard to maintain a shiny application without documentation.

It seems that all the eco-system of tests/documentation is created for an R package structure. Maybe we can emulate/extend this behavior for a shiny application?

An example :

A reactive expression is typically an R shiny element taht can contain complex data structure.

   filtered_dat <- reactive({ 
      dx[ NAME == input$crr & TOU == input$tou & 
            PlotYear == input$year. & PlotMonth == input$season]
    })

To give more context, I am here in the context of building a complete web application using R shiny. All the business-logic is wrapped in a separated package(s).

For testing Ui I think it is complicated ( one can use Rselenium for example) , but generating doc from roxygen2 comments is just parsing. It should be easy to have such tool.


Solution

  • update

    Add an example of shiny application


    There is not an ideal solution but this is basically what I am doing to deal with my shiny applications to create a robust and well "documented" shiny application:

    • Create a package where you put all your logic within it. Don't worry to call input/output structure from the package as an argument. Also try to create some controls within your package. For example you can have an inline version of some basic shiny controls.

    A typical package will have this structure:

     R
         ui-view1.R
         ui-view2.R
         server-server1.R
         server-server2.R
         controls.R
    
    • Create a shiny application that is structured in a way that reflects your different applications elements. Basically create a view/server files for each app page. You can of course put the shiny application under inst/ui or put it in a separate project.

    Here an example:

     app 
         ui.R
         server.R
         global.R
         views
            view1.R
            view2.R
         servers
            server1.R
            server2.R
         init 
            global1.R
            gloabl2.R