Skip to content

rustdoc: make item links consistently use title="{shortty} {path}" #107242

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

Merged
merged 1 commit into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
stab = stab.unwrap_or_default(),
unsafety_flag = unsafety_flag,
href = item_path(myitem.type_(), myitem.name.unwrap().as_str()),
title = [full_path(cx, myitem), myitem.type_().to_string()]
title = [myitem.type_().to_string(), full_path(cx, myitem)]
.iter()
.filter_map(|s| if !s.is_empty() { Some(s.as_str()) } else { None })
.collect::<Vec<_>>()
Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc-gui/unsafe-fn.goml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
show-text: true

compare-elements-property: (
"//a[@title='test_docs::safe_fn fn']/..",
"//a[@title='test_docs::unsafe_fn fn']/..",
"//a[@title='fn test_docs::safe_fn']/..",
"//a[@title='fn test_docs::unsafe_fn']/..",
["clientHeight"]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ pub mod sub {
#[doc(inline)]
pub use sub::*;

// @count foo/index.html '//a[@class="mod"][@title="foo::prelude mod"]' 1
// @count foo/index.html '//a[@class="mod"][@title="mod foo::prelude"]' 1
// @count foo/prelude/index.html '//div[@class="item-row"]' 0
pub mod prelude {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub mod sub {
}
}

// @count foo/index.html '//a[@class="mod"][@title="foo::prelude mod"]' 1
// @count foo/index.html '//a[@class="mod"][@title="mod foo::prelude"]' 1
// @count foo/prelude/index.html '//div[@class="item-row"]' 0
pub mod prelude {}

Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc/issue-99221-multiple-structs-w-same-name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ extern crate issue_99221_aux;

pub use issue_99221_aux::*;

// @count foo/index.html '//a[@class="struct"][@title="foo::Print struct"]' 1
// @count foo/index.html '//a[@class="struct"][@title="struct foo::Print"]' 1

pub struct Print;
2 changes: 1 addition & 1 deletion tests/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern crate issue_99734_aux;

pub use issue_99734_aux::*;

// @count foo/index.html '//a[@class="fn"][@title="foo::main fn"]' 1
// @count foo/index.html '//a[@class="fn"][@title="fn foo::main"]' 1

extern "C" {
pub fn main() -> std::ffi::c_int;
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc/issue-99734-multiple-mods-w-same-name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ extern crate issue_99734_aux;

pub use issue_99734_aux::*;

// @count foo/index.html '//a[@class="mod"][@title="foo::task mod"]' 1
// @count foo/index.html '//a[@class="mod"][@title="mod foo::task"]' 1

pub mod task {}