Rustdoc suggestion: Highlight links `fn`s, `mod`s `type`s etc. appropriately within `///` and `//!` documentation

While reading documentation, especially when discovering the API of a new crate, I got the impression that human readers could get an easier understanding of the referenced items if they were appropriately highlighted.

Currently, all links to other documented items within a /// or //! block are rendered as yellow, the default link color var(--link-color)`.

In structured overviews, on the other hand, links to each item type get a specific CSS class like mod, fn, macro, type, primitive etc. assigned - causing these items to be colored distinctly according to their item type.

Applying the same highlighting in /// and //! blocks would help human readers in disambiguating fns from mods from macros and so on, without requiring all fns to be suffixed by () and all macros to be suffixed by ! (which is neither enforced, nor even recommended as best practice). Suffixes are furthermore not available for disambiguation between modules and primitives.

Since rustdoc already gathers all information about the linked item (determining the target URL), implementation should be rather trivial.

If the feature is receiving interest, then I would try an implementation myself.

8 Likes

There appears not to be very much interest. :thinking:

I actually think that's pretty reasonable, but I just didn't notice this.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.