Skip to content

Commit

Permalink
Merge pull request #101 from NovoNordisk-OpenSource/100-fix-ensure-md…
Browse files Browse the repository at this point in the history
…-formats-can-be-generated

fix: render other md log formats("gfm", "commonmark", "markua")
  • Loading branch information
Lovemore-Gakava authored Oct 7, 2024
2 parents b7ce7dc + 58b2ee8 commit 8022590
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: whirl
Title: Logging package
Version: 0.1.0
Version: 0.1.1
Authors@R: c(
person("Aksel", "Thomsen", , "[email protected]", role = c("aut", "cre")),
person("Lovemore", "Gakava", , "[email protected]", role = "aut"),
Expand Down
15 changes: 4 additions & 11 deletions R/mdformats.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#' @noRd
mdformats <- function(script, log_html, mdfmt, out_dir) {
mdformats <- function(script, log_html, mdfmt, self, out_dir) {
newname <- gsub(
pattern = "\\.[^\\.]*$",
replacement = "",
x = basename(script)
)

if (length(mdfmt) > 1) {
newname <- paste0(newname, "_", mdfmt)
if (length(mdfmt) >= 1) {
newname <- paste0(newname, "_log_", mdfmt)
}

newname <- paste0(newname, ".md")
Expand All @@ -20,14 +20,7 @@ mdformats <- function(script, log_html, mdfmt, out_dir) {
)

file.copy(
from = file.path(
tempdir(),
gsub(
pattern = "\\.[^\\.]*$",
replacement = ".md",
x = basename(log_html)
)
),
from = file.path(self$get_wd(), "log.md"),
to = file.path(
out_dir,
newname[[i]]
Expand Down
2 changes: 1 addition & 1 deletion R/whirl_queue.R
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ wq_next_step <- function(self, private, wid) {
purrr::pluck(private$.queue, "result", id_script) <- session$
log_finish()$
create_outputs(out_dir = dirname(purrr::pluck(private$.queue, "script", id_script)),
format = "html")
format = options::opt("out_formats", env = "whirl"))

purrr::pluck(private$.queue, "status", id_script) <-
purrr::pluck(private$.queue, "result", id_script, "status", "status")
Expand Down
3 changes: 2 additions & 1 deletion R/whirl_r_session.R
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ wrs_create_outputs <- function(out_dir, format, self, private, super) {
script = private$current_script,
log_html = file.path(self$get_wd(), "log.html"),
mdfmt = format[format %in% c("gfm", "commonmark", "markua")],
out_dir = out_dir
out_dir = out_dir,
self = self
)
}

Expand Down

0 comments on commit 8022590

Please sign in to comment.