diff --git a/R/get.R b/R/get.R index 4ab8830..12d9884 100644 --- a/R/get.R +++ b/R/get.R @@ -155,13 +155,6 @@ get_masked_functions <- function(){ #' get_used_functions <- function(file){ - if (grepl("*.Rmd$", file, ignore.case = TRUE)){ - tmpfile <- tempfile(fileext = ".R") - on.exit(unlink(tmpfile)) - knitr::purl(file, tmpfile) - file <- tmpfile - } - # catch error retfun <- safely(parse, quiet = FALSE, @@ -202,7 +195,7 @@ get_used_functions <- function(file){ mutate(function_name = coalesce(.data[["SYMBOL_FUNCTION_CALL"]], .data[["SPECIAL"]])) - get_library(combine_tokens) %>% +get_library(combine_tokens) %>% select(all_of(c("function_name", "library"))) %>% distinct() diff --git a/R/interact.R b/R/interact.R index 5852004..959d052 100644 --- a/R/interact.R +++ b/R/interact.R @@ -110,13 +110,6 @@ set_log_name_path <- function(log_name = NA, log_path = NA) { #' @noRd run_safely <- function(file) "dummy" -#' Is this a R Markdown file#' -#' @param file String. Path to file to execute -#' @noRd -is_rmarkdown <- function(file) { - grepl("*.Rmd$", file, ignore.case = TRUE) -} - #' Dummy function for running a file #' @noRd run_file <- function(file){ @@ -125,13 +118,7 @@ run_file <- function(file){ } else{ exec_env <- getOption("log.rx.exec.env") } - - if (is_rmarkdown(file)) { - rmarkdown::render(file, envir = exec_env) - } else ( - source(file, local = exec_env) - ) - + source(file, local = exec_env) } #' Safely run an R script and record results, outputs, messages, errors, warnings diff --git a/R/log.R b/R/log.R index b420b73..7e10223 100644 --- a/R/log.R +++ b/R/log.R @@ -276,7 +276,7 @@ log_write <- function(file = NA, } if ("result" %in% to_report){ cleaned_log_vec <- c(cleaned_log_vec, - write_result(file)) + write_result()) } cleaned_log_vec <- c(cleaned_log_vec, diff --git a/R/writer.R b/R/writer.R index 2b5268b..f10ac82 100644 --- a/R/writer.R +++ b/R/writer.R @@ -255,19 +255,14 @@ write_output <- function() { #' Format result attribute for writing #' -#' @param file String. Path to file to execute #' @return A formatted vector of results #' #' @noRd #' -write_result <- function(file) { +write_result <- function() { result <- get_log_element("result") - if (is_rmarkdown(file)) { - c("\nResult:", paste0("\t", capture.output(result))) - } else { - c("\nResult:", paste0("\t", capture.output(result$value))) - } + c("\nResult:", paste0("\t", capture.output(result$value))) } #' Format lint results for writing diff --git a/tests/testthat/test-writer.R b/tests/testthat/test-writer.R index 2ff04e3..dcd6d98 100644 --- a/tests/testthat/test-writer.R +++ b/tests/testthat/test-writer.R @@ -176,7 +176,7 @@ test_that("write_result will return a formatted log result element", { run_safely_loudly(fp) - expect_identical(write_result(fp), + expect_identical(write_result(), c("\nResult:", paste0("\t", capture.output(data.frame(test = c(8, 6, 7, 5, 3, 0, 9)))))) log_remove()