Skip to content
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

Consider styling go-to-definition links using faint underline #88120

Open
camelid opened this issue Aug 17, 2021 · 2 comments
Open

Consider styling go-to-definition links using faint underline #88120

camelid opened this issue Aug 17, 2021 · 2 comments
Labels
A-rustdoc-ui Area: rustdoc UI (generated HTML) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@camelid
Copy link
Member

camelid commented Aug 17, 2021

Basically, we could style the links similarly to Haskell's equivalent to Rustdoc, Haddock. They use a faint underline, and then add background color when the link is hovered:

image

image

I like how it's very subtle in Haddock, so it doesn't affect the reading experience, but it's strong enough to think, "Hey, I bet I can click that link!"

IIUC, nearly all of the identifiers should be clickable in the generated source view, so we just want to give a hint that the links are clickable without distracting from the reading view.

Originally posted by @camelid in #88111 (comment)

@camelid camelid added A-rustdoc-ui Area: rustdoc UI (generated HTML) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 17, 2021
@camelid camelid changed the title Consider styling clickable go-to-definition links using faint underline Consider styling go-to-definition links using faint underline Aug 17, 2021
@jsha
Copy link
Contributor

jsha commented Nov 18, 2021

Instead, what about using the same color conventions in source view that we do in doc view? As in, the last token of a path (Baz in foo::bar::Baz) is linkified and colored.

There's a slight conflict here:

  • the source view is currently color-highlighted the way an IDE highlights: keywords are colorized; identifiers and types are unmarked.
  • the doc view is color-highlighted in an inverse way: keywords are unmarked; identifiers and types are colorized.

I think it makes the most sense to follow the doc view conventions here, in part because colorizing the identifiers and types can act as the indicator that they are clickable. This would be consistent with the doc pages, and would avoid adding distracting emphasis on the source page.

If we adopt this, for consistency we'd want to also colorize and linkify identifiers when they are declared, like idx on the first line of this example:

image

@camelid
Copy link
Member Author

camelid commented Nov 18, 2021

Hmm, it's an interesting idea. FWIW, some IDEs do color identifiers (semantic highlighting).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: rustdoc UI (generated HTML) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants