strboul / supreme

Generate UML diagrams of Shiny modules
Other
60 stars 5 forks source link

Cannot parse modules called via namespaces #6

Closed ShaulAb closed 4 years ago

ShaulAb commented 4 years ago

Hello, first of all I want to say thank you for developing supreme! I find this package very useful, especially when dealing with complex apps.

I'm not sure if it's in your scope, but currently supreme is not parsing modules called via namespace properly.

For example, if you take the app from shinyauthr

library(shiny)
library(shinyauthr)
library(shinyjs)

user_base <- data.frame(
  user = c("user"),
  password = c("pass"),
  permissions = c("admin"),
  name = c("User One"),
  stringsAsFactors = FALSE,
  row.names = NULL
)

ui <- fluidPage(
  shinyjs::useShinyjs(),
  div(class = "pull-right", logoutUI(id = "logout")),
  loginUI(id = "login"),
  tableOutput("user_table")
)

server <- function(input, output, session) {

  logout_init <- callModule(shinyauthr::logout,
                            id = "logout",
                            active = reactive(credentials()$user_auth))

  credentials <- callModule(shinyauthr::login,
                            id = "login",
                            data = user_base,
                            user_col = user,
                            pwd_col = password,
                            log_out = reactive(logout_init()))

  user_data <- reactive({credentials()$info})

  output$user_table <- renderTable({
    req(credentials()$user_auth)
    user_data()
  })
}

as sample_app.R, you get the following error:

library(supreme)
obj <- supreme(src_file("sample_app.R"))
#> Error in names(object) <- nm: 'names' attribute [3] must be the same length as the vector [1]

Created on 2020-03-28 by the reprex package (v0.3.0)

Calling the module directly (i.e. replacing shinyauthr::<module> with <module>) works as expected.

strboul commented 4 years ago

Thanks for reporting this! I patched it. Please let me know if it doesn't work.