-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
[WIP] Distinguish between links on inner and outer attributes #78611
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Normally, rustdoc will resolve `//!` docs in the scope inside the module and `///` in the scope of the parent. But if there are modules with inner docs, it would previously resolve _all_ of the links inside the module. This now distinguishes between links that came from inside the module and links that came from outside. The intra-doc links part works, but unfortunately the rest of rustdoc assumes there is only one canonical resolution for a link and won't look for more than one on the same item. - Store the attribute style on each DocFragment - Don't combine attributes with different styles - Calculate the parent module in only one place - Remove outdated and fixed FIXME comments
Question: wouldn't it be simpler to first treat inner docs and then outer docs for each item? Therefore, you could change the |
This is what it does currently, no? Or do you mean to have separate |
From what I understand, not exactly. We have a weird mix between the two and then treat them as one. What I meant was to literally try to split both handling so that the parent id isn't "special". |
let base_node = if !seen_inner_docs && item.is_mod() && attr.style == AttrStyle::Inner { | ||
// FIXME(jynelson): once `Self` handling is cleaned up I think we can get rid | ||
// of `mod_ids` altogether | ||
self.mod_ids.push(item.def_id); | ||
seen_inner_docs = true; | ||
Some(item.def_id) | ||
} else { | ||
parent_node | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to also update parent_node
or any following attributes will still use the outer scope.
let base_node = if !seen_inner_docs && item.is_mod() && attr.style == AttrStyle::Inner { | |
// FIXME(jynelson): once `Self` handling is cleaned up I think we can get rid | |
// of `mod_ids` altogether | |
self.mod_ids.push(item.def_id); | |
seen_inner_docs = true; | |
Some(item.def_id) | |
} else { | |
parent_node | |
}; | |
if !seen_inner_docs && item.is_mod() && attr.style == AttrStyle::Inner { | |
// FIXME(jynelson): once `Self` handling is cleaned up I think we can get rid | |
// of `mod_ids` altogether | |
self.mod_ids.push(item.def_id); | |
seen_inner_docs = true; | |
parent_node = Some(item.def_id); | |
} |
and then change base_node
to parent_node
below.
☔ The latest upstream changes (presumably #78956) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
Triage: CI is still red here. |
I'm not convinced this is actually useful ... It doesn't fix the ICE and a lot of the rest of rustdoc assumes this is the same. It might be easier to just forbid intra-doc-links to appear on both inner and outer attributes. |
I don't plan to follow up on this. |
Normally, rustdoc will resolve
//!
docs in the scope inside the moduleand
///
in the scope of the parent. But if there are modules withinner docs, it would previously resolve all of the links inside the module.
This now distinguishes between links that came from inside the module
and links that came from outside. The intra-doc links part works, but
unfortunately the rest of rustdoc assumes there is only one canonical
resolution for a link and won't look for more than one on the same item.
This came from a failed attempt to work on #78591 and there's some debugging for that left over. Let me know if I should remove it.
r? @GuillaumeGomez - do you have suggestions for how to pass this information to the rest of rustdoc? For context, the issue is that given a list of links like
rustdoc::html
will always pick the first resolution in the array. Maybe the link should also say whether it's an inner or outer link, and havehtml
distinguish too?cc @Manishearth - technically this is a breaking change, but I consider the old behavior a bug.