You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
allow for clickable links from console-generated output #2530
It'd be handy if we could generate clickable links for certain kinds of console output; primarily for source references. Some example cases:
testthat output, with links of the form:
test-file.R:42: failure: a thing happened
Source references, e.g.
1: expect_match(arg_descriptions[["a"]], "Description for a") at
/Users/kevin/r/pkg/reticulate/tests/testthat/test-help-handlers.R:33
pkgdown output, e.g.
Building 'man/with.python.builtin.object.Rd'
Writing 'reference/with.python.builtin.object.html'
The two most common places where these types of outputs will appear are in the Console (for direct console output), and in the Build pane. If possible, a generic solution that post-processes console output would likely be most appropriate, since we could re-use that in both scenarios.
Reacted by Hadley Wickham, Jennifer (Jenny) Bryan, Javier Arturo Porras Luraschi, Kun Ren, Forest Fang, Cole Arendt, Paul Kaefer, Indranil Gayen, CJ Yetman, Aron Atkins and 6 more
Ah, in RStudio 1.2 literal hyperlinks in the terminal do work (in that if the terminal displays something recognized as a link, you can click on it to launch it in the browser). This stopped working in 1.3, however. I'll open an issue on that. #6621
Also note that the terminal doesn't support the ANSI escape link sequences: xtermjs/xterm.js#1134
It would be very useful to be able to annotate output with two types of links:
source code (e.g. tests/testthat/test-foo.R:5). These would generally (but not always) be project-local, would open in the script editor (or activate the tab if already open), and should navigate to a line, if specified.
There are pros and cons for both approaches. Regexp based parsing would add links to existing code without developer effort but would have some false positives and negatives, and there's no obvious way to support viewer links. ANSI escapes would be 100% accurate, but would require work by developers to take adavantage of.
There are a number of places where the tidyverse team would take advantage of such links:
Where we're already displaying srcrefs, particularly in tracebacks produced by by rlang and in testthat errors. These links making debugging faster and more fluid because you can easily jump directly from the error to the underlying source code. These are mostly useful for package developers.
In errors that require more explanation, e.g. in vctrs (as below), when we're wrapping web APIs that provide informative urls on error, and in "sitrep" functions, which give users a situation report on the package and its environs.
#> rlang::inform(vctrs:::incompatible_attrib_bullets())
x Some attributes are incompatible.
ℹ The author of the class should implement vctrs methods.
ℹ See https://vctrs.r-lib.org/reference/faq-error-incompatible-attributes.html#
We have used such links in relatively few places, but would be likely to include more (especially in deprecation messages) if we could produce live links.
Does #1941 include support for source code links as well as external? If it does, and it resolves all the main aspects of the request, then I think we can consider it a duplicate.
yes, e.g. cli::style_hyperlink("go", "file://{file path}", params = c(line = <line>, col = <col>)), it's just a bit clunky that we have to prefix with file:// and use the absolute path.
Activity
hadley commentedon Mar 28, 2018
I suspect this might also be useful in usethis if when we inform a user that we have modified a file for them.
gtritchie commentedon Mar 28, 2018
See also #1941
hadley commentedon Apr 3, 2018
This would also be useful in shiny, where they're printing their own stack traces.
hadley commentedon Apr 4, 2018
Ideally, this would also work for http(s) urls, where clicking on them would open in the system browser.
Hyperlinks in terminals that support them
colearendt commentedon Apr 8, 2020
This would also be useful in the terminal
gtritchie commentedon Apr 8, 2020
Ah, in RStudio 1.2 literal hyperlinks in the terminal do work (in that if the terminal displays something recognized as a link, you can click on it to launch it in the browser). This stopped working in 1.3, however. I'll open an issue on that. #6621
Also note that the terminal doesn't support the ANSI escape link sequences: xtermjs/xterm.js#1134
stale commentedon Feb 5, 2021
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.
hadley commentedon Feb 5, 2021
Please keep this alive 😄
mikebessuille commentedon Oct 4, 2021
high priority for Hadley - consider soon
hadley commentedon Oct 4, 2021
It would be very useful to be able to annotate output with two types of links:
tests/testthat/test-foo.R:5). These would generally (but not always) be project-local, would open in the script editor (or activate the tab if already open), and should navigate to a line, if specified.http://rstudio.com), would open in external web browser.And there are two more types that would be useful but are less important:
There are two ways such annotations could be provided:
Regexp based parsing of console output so (e.g.
<https?://.*?>would be an external link and[^ ]+\\.[rR]:(0-9)+would be a source code link).ANSI escape code (probably using iTerm's proprietary extension).
There are pros and cons for both approaches. Regexp based parsing would add links to existing code without developer effort but would have some false positives and negatives, and there's no obvious way to support viewer links. ANSI escapes would be 100% accurate, but would require work by developers to take adavantage of.
There are a number of places where the tidyverse team would take advantage of such links:
Where we're already displaying srcrefs, particularly in tracebacks produced by by rlang and in testthat errors. These links making debugging faster and more fluid because you can easily jump directly from the error to the underlying source code. These are mostly useful for package developers.
In errors that require more explanation, e.g. in vctrs (as below), when we're wrapping web APIs that provide informative urls on error, and in "sitrep" functions, which give users a situation report on the package and its environs.
We have used such links in relatively few places, but would be likely to include more (especially in deprecation messages) if we could produce live links.
3 remaining items
romainfrancois commentedon Jan 25, 2022
Can we consider this a duplicate of #1941 (with its pull request here: #10416).
mikebessuille commentedon Jan 25, 2022
Does #1941 include support for source code links as well as external? If it does, and it resolves all the main aspects of the request, then I think we can consider it a duplicate.
romainfrancois commentedon Jan 25, 2022
yes, e.g.
cli::style_hyperlink("go", "file://{file path}", params = c(line = <line>, col = <col>)), it's just a bit clunky that we have to prefix withfile://and use the absolute path.r-lib/testthat#1544 is an example use.
mikebessuille commentedon Feb 17, 2022
Closed as duplicate of #1941