Skip to content

allow for clickable links from console-generated output #2530

Closed

Description

@kevinushey

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.

cc: @hadley

Activity

  1. hadley commented on Mar 28, 2018

    @hadley
    Member

    I suspect this might also be useful in usethis if when we inform a user that we have modified a file for them.

  2. gtritchie commented on Mar 28, 2018

    @gtritchie
    Member

    See also #1941

  3. hadley commented on Apr 3, 2018

    @hadley
    Member

    This would also be useful in shiny, where they're printing their own stack traces.

  4. hadley commented on Apr 4, 2018

    @hadley
    Member

    Ideally, this would also work for http(s) urls, where clicking on them would open in the system browser.

  5. colearendt commented on Apr 8, 2020

    @colearendt
    Contributor

    This would also be useful in the terminal

  6. gtritchie commented on Apr 8, 2020

    @gtritchie
    Member

    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

  7. stale commented on Feb 5, 2021

    @stale

    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.

  8. added
    stale
    on Feb 5, 2021
  9. hadley commented on Feb 5, 2021

    @hadley
    Member

    Please keep this alive 😄

  10. removed
    stale
    on Feb 5, 2021
  11. mikebessuille commented on Oct 4, 2021

    @mikebessuille
    Contributor

    high priority for Hadley - consider soon

  12. hadley commented on Oct 4, 2021

    @hadley
    Member

    It would be very useful to be able to annotate output with two types of links:

    And there are two more types that would be useful but are less important:

    • viewer links, like external links but open in the viewer.
    • help links, that open specified documentation in the help pane.

    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.

      #> 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.

  13. 3 remaining items

  14. romainfrancois commented on Jan 25, 2022

    @romainfrancois
    Contributor

    Can we consider this a duplicate of #1941 (with its pull request here: #10416).

  15. removed their assignment
    on Jan 25, 2022
  16. mikebessuille commented on Jan 25, 2022

    @mikebessuille
    Contributor

    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.

  17. romainfrancois commented on Jan 25, 2022

    @romainfrancois
    Contributor

    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.

    r-lib/testthat#1544 is an example use.

  18. mikebessuille commented on Feb 17, 2022

    @mikebessuille
    Contributor

    Closed as duplicate of #1941

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions