2

It seems that if you define a link in an item's doc comment, it is evidently only defined for that particular item. As an example:

/// This is some example [documentation]
///
/// [documentation]: https://www.rust-lang.org/learn

If I try to use [documentation] in the doc comments for another item, it says that the link is unresolved. Is there an easy way to define links globally, or at least within the same file such that they can be used in the doc comments for multiple items? This seems like something that should be common and easy, but I could find no information about it, and this was no help either. Having to redefine the links in every item's doc comments would be a lot of unwanted duplication.

kyp4
  • 133
  • 5
  • 3
    Surely if the same thing is documented on many items, it should simply be as part of the crate/module documentation rather than on every item, no? And if you feel it must be mentioned everywhere, individual items could then link to the crate/module documentation. – kmdreko Nov 05 '22 at 20:39
  • Yeah, I just ended up doing things in a different way so that I no longer need this capability. However, it still seems like something that could be generally useful. – kyp4 Nov 06 '22 at 16:35
  • This sort of feature would be useful to me. In a number of different places in a codebase I'm working with I want to refer to a common source specification. The need to mention the link in multiple places is to assist newcomers in reading and understanding the codebase so it wouldn't be sufficient to put the link in only the crate-level documentation like @kmdreko suggests. – Kent Bull Dec 05 '22 at 04:17

0 Answers0