Skip to content

Turn HTML output into links #12888

@epage

Description

@epage

Problem

In most terminals, if a URL is printed it is turned into a link you can click on for easy opening. This is less true for file paths.

This is less of a problem for cargo doc --open as cargo will open the page up for you.

Places where we are falling short include

  • cargo doc --target foo --target bar (--open doesn't work)
  • Wanting to a cargo doc invocation that you can run multiple times, using shell history, without editing in/out --open
  • cargo doc calls wrapped in other tools, like make
  • cargo build --timings (it'd be awkward to add a --open just for --timings)

Proposed Solution

Turn the file paths into links using ANSI escape codes

Notes

From #12859 (review)

This looks great. Have you consider integrating something like hyperlinks in terminal emulators?

ripgrep just got a similar feature, though not by using OSC escape sequence:

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-timingsArea: timingsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-docS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions