Skip to content

Commit

Permalink
Merge pull request #122 from NovoNordisk-OpenSource/fix/render_summary
Browse files Browse the repository at this point in the history
Fixing hyperlink bug and adjust title of individual logs
  • Loading branch information
Troejelsgaard authored Dec 6, 2024
2 parents 9310cc0 + 692a9c3 commit 9758418
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 5 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.6
Version: 0.1.6.9000
Authors@R: c(
person("Aksel", "Thomsen", , "[email protected]", role = c("aut", "cre")),
person("Lovemore", "Gakava", , "[email protected]", role = "aut"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# whirl (development version)
* Changed the title on the individual logs to the script name and moved the path to a distinct section within the title-block.
* Fixed a bug where the hyperlink in the summary files was not rendered correctly.

# whirl 0.1.6 (2024-11-25)
* Added support for logging of Python scripts with `run()`.
* Improved unit tests for `run()`
Expand Down
5 changes: 5 additions & 0 deletions R/internal_run.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ internal_run <- function(input, steps, queue, level,
} else {
# Execute the scripts
queue$run(files)
zephyr::msg("\n",
msg_fun = cli::cli_verbatim,
levels_to_write = "verbose",
verbosity_level = verbosity_level)

}
}

Expand Down
6 changes: 4 additions & 2 deletions R/render_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ knit_print.whirl_summary_info <- function(x, path_rel_start, ...) {
ncols <- ncol(hold)

if (grepl("rstudio_cloud", Sys.getenv("R_CONFIG_ACTIVE"))) {
formatted <- file.path("/file_show?path=", hold[["Hyperlink"]])
formatted <- file.path("/file_show?path=", hold$"Hyperlink")
} else {
formatted <- file.path(path_rel(hold[["Hyperlink"]], start = path_rel_start))
formatted <- lapply(hold$"Hyperlink", path_rel, start = path_rel_start) |>
unlist() |>
file.path()
}

hold$Hyperlink <- paste0(sprintf('<a href="%s" target="_blank">%s</a>', formatted, "HTML Log"))
Expand Down
1 change: 1 addition & 0 deletions inst/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*.html
*.json
*_files/*
!documents/title-block.html
5 changes: 4 additions & 1 deletion inst/documents/log.qmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---
title: "`r params$title`"
title: "`r basename(params$title)`"
date: "`r Sys.time()`"
date-format: "YYYY-MM-DDTHH:mm:ss zzz"
abstract: "`r params$title`"
template-partials:
- title-block.html
params:
title: 'dev'
check_approved_folder_pkgs: NULL
Expand Down
37 changes: 37 additions & 0 deletions inst/documents/title-block.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title">$title$</h1>
$if(subtitle)$
<p class="subtitle">$subtitle$</p>
$endif$
$for(author)$
<p class="author">$author$</p>
$endfor$

$if(date)$
<div>
<div class="quarto-title-meta-heading">Execution end time</div>
<div class="quarto-title-meta-contents">
<p class="date">$date$</p>
</div>
</div>
$endif$

$if(date-modified)$
<div>
<div class="quarto-title-meta-heading">Execution time</div>
<div class="quarto-title-meta-contents">
<p class="date-modified">$date-modified$</p>
</div>
</div>
$endif$

$if(abstract)$
<div>
<div class="quarto-title-meta-heading">Path to script</div>
<div class="quarto-title-meta-contents">
<p class="abstract">$abstract$</p>
</div>
</div>
$endif$
</header>
5 changes: 4 additions & 1 deletion tests/testthat/scripts/_whirl_to_config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
steps:
- name: "Run config file"
- name: "Run _whirl.yaml"
paths:
- "_whirl.yaml"
- name: "Run _whirl_unnamed.yaml"
paths:
- "_whirl_unnamed.yaml"

0 comments on commit 9758418

Please sign in to comment.