@@ -340,3 +340,34 @@ ShinyHierarchy <- function(directory=getwd(),ui="ui.R",server="server.R",
340
340
visOptions(highlightNearest = list (enabled = T , degree = 1 , hover = T ))
341
341
342
342
}
343
+
344
+
345
+ ProcessReactives <- function (directory = getwd(),ui = " ui.R" ,server = " server.R" ,
346
+ showCommentedOutChunks = F ){
347
+
348
+ # # Get input again
349
+ a <- read_file(paste(directory ," /" ,server ,sep = " " ))
350
+ b <- gsub(" \r ?\n " ," " ,a )
351
+ # # Identify code chunks, basically each little shiny minifunction
352
+ Chunks <- str_extract_all(b , " [a-zA-Z0-9\\ ._]+ *\\ <\\ - *[a-zA-Z0-9\\ ._]+?\\ (\\ {.+?\\ }\\ )" ,
353
+ simplify = F ) %> % . [[1 ]]
354
+ if (length(Chunks )== 0 ) stop(" Hrm, I can't detect any chunks. I expect assignments to use '<-'... so if
355
+ you're using '=' or '->' assignments or 'source'ing stuff in, then that would be why." )
356
+
357
+ # # Identify only the reactive chunks
358
+ Chunks <- Chunks [grep(" reactive\\ (" ,Chunks )]
359
+
360
+ # # get only the guts
361
+ Chunks2 <- str_extract(string = Chunks ," (?<=\\ (\\ {).+(?=\\ }\\ ))" )
362
+
363
+ # # And make stuff evaluatable by replacing multiple space w/ semicolon, however, except the first one.
364
+ Chunks3 <- gsub(" +" ," ; " ,str_trim(Chunks2 ),perl = T )
365
+
366
+ # # But deal w/ pipes
367
+ Chunks4 <- gsub(" \\ %;" ," \\ %" ,Chunks3 )
368
+
369
+ for (i in 1 : length(Chunks4 )){
370
+ # eval(parse(text = Chunks4[i]))
371
+ eval(parse(text = str_split(Chunks4 [i ]," ;" )[[1 ]]))
372
+ }
373
+ }
0 commit comments