Skip to content

Support clickable hyperlinks in lintr output if hyperlinks are available (but not markers) #2645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
olivroy opened this issue Aug 6, 2024 · 0 comments · Fixed by #2646
Closed

Comments

@olivroy
Copy link
Collaborator

olivroy commented Aug 6, 2024

i.e. in Positron, output looks like this
image

It would be great if hyperlinks are available, but not source markers (i.e. cli::ansi_has_hyperlink_support() && (!requireNamespace("rstudioapi") || !rstudioapi::hasFun("sourceMarkers") ) then we could just use

paths <- c("tests/spelling:1:1", "tests/spelling:1:2")
paths2 <- paste0("{.path ", paths, "}")
paths3 <- unlist(lapply(paths2, cli::format_inline))
cat(paths3, sep = "\n")

I am however not sure where to put this condition, I tried in

lintr/R/methods.R

Lines 95 to 99 in 8d96145

} else if (in_github_actions() && !in_pkgdown()) {
github_actions_log_lints(x, project_dir = github_annotation_project_dir)
} else {
lapply(x, print, ...)
}

} else if (in_github_actions() && !in_pkgdown()) { 
   github_actions_log_lints(x, project_dir = github_annotation_project_dir) 
 } else if (cli::has_hyperlink_support()) { 
  # Do some modification here?
 } else { 
   lapply(x, print, ...) 
 } 

But it didn't seem to work

This should happen in the print method to make sure no output is problematic.

I think it can happen in format.lint(). I may come up with a PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant