Remove disambiguator from intra doc link text
dtolnay opened this issue · 9 comments
/// Trait: [`trait@Name`], fn: [`fn@Name`]
pub struct S;
pub trait Name {}
#[allow(non_snake_case)]
pub fn Name() {}This is currently rendered as:
The links point to the right place (the trait and the fn respectively) but I believe the link text should be just "Name" for both.
Discovered in #65336.
Mentioning the tracking issue: #43466
This issue has been assigned to @jyn514 via this comment.
I can do it if you want but maybe you prefer doing it?
I definitely don't prefer doing it. 😉 Feel free to go ahead. Thanks!
Ok haha. Will try to do it not too far into the future.
So, I tried implementing this just now and it's not possible with the current pulldown-cmark API. The issue is that while broken_link_callback can return a new title (for when you hover) and a new URL, it cannot change the text that is rendered for shortcut reference links: [fn@Name]. See https://github.com/raphlinus/pulldown-cmark/blob/master/src/parse.rs#L2213.
Maybe we could ask pulldown to extend the API to allow this? I had trouble with the last PR I made though, the link parsing is very complicated.
I think it'll be the best situation to directly improve the parser's API, indeed.
The recommended solution @marcusklaas gave in pulldown-cmark/pulldown-cmark#466 (comment) was to add a second pass on top of the pulldown parser which removes the disambiguator from Unknown link kinds. Not yet sure how hard this will be to implement, but it wouldn't need pulldown changes. It would go somewhere around jyn514@1650fbe#diff-545d93b02fb448fc31d33a6b1e0e0c48.
Presumably you would still want to keep symbol disambiguators, right? So fn@Name would be rendered as Name, but Name() would still be rendered the same?
