Skip to content

Commit

Permalink
Add hyperlink to errors
Browse files Browse the repository at this point in the history
Fixes #1323
  • Loading branch information
hadley committed Apr 20, 2022
1 parent 8279a15 commit 6fd9a18
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/block.R
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,6 @@ parse_description <- function(tags) {
}

warn_roxy_block <- function(block, message, ...) {
message[[1]] <- paste0("[", block$file, ":", block$line, "] ", message[[1]])
message[[1]] <- paste0(link_to(block$file, block$line), message[[1]])
cli::cli_warn(message, ..., .envir = parent.frame())
}
11 changes: 9 additions & 2 deletions R/tag.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,17 @@ roxy_tag_warning <- function(x, ...) {
#' @rdname roxy_tag
warn_roxy_tag <- function(tag, message, ...) {
message[[1]] <- paste0(
"[", tag$file, ":", tag$line, "] ",
"@", tag$tag, " ",
link_to(tag$file, tag$line), " @", tag$tag, " ",
if (is.null(tag$raw)) ("(automatically generated) "),
message[[1]]
)
cli::cli_warn(message, ..., .envir = parent.frame())
}

link_to <- function(file, line) {
paste0("[", cli::style_hyperlink(
paste0(basename(file), ":", line),
paste0("file://", file),
params = c(line = line, col = 1)
), "]")
}

0 comments on commit 6fd9a18

Please # to comment.