Skip to content

Commit

Permalink
forgiving to_call()
Browse files Browse the repository at this point in the history
  • Loading branch information
romainfrancois committed Mar 9, 2024
1 parent f3b4728 commit a525856
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions R/auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ to_pkg <- function(pkg, type = c("tooltip", "plain"), keep_braces = TRUE, ...) {

url <- downlit::href_package(pkg)
if (is.na(url)) {
return(link_text)
return(tags$span(link_text, class = "r-link-pkg-error"))
}
link <- tags$a(link_text, href = url, class = "r-link-pkg", target = "_blank")

Expand All @@ -86,12 +86,16 @@ to_pkg <- function(pkg, type = c("tooltip", "plain"), keep_braces = TRUE, ...) {
to_call <- function(call, type = c("tooltip", "plain"), keep_pkg_prefix = TRUE, ...) {
type <- rlang::arg_match(type)

url <- downlit::autolink_url(call)
link_text <- if (keep_pkg_prefix) {
call
} else {
glue::glue("{fun}()", fun = stringr::str_extract(call, rx_call, group = 2))
}

url <- downlit::autolink_url(call)
if (is.na(url)) {
return(tags$span(link_text, class = "r-link-pkg-error"))
}
link <- tags$a(link_text, href = url, class = "r-link-call", target = "_blank")

switch(
Expand Down

0 comments on commit a525856

Please sign in to comment.