add [src] links to methods on a trait's page
This commit is contained in:
parent
b491587c91
commit
ae644a2d4d
3 changed files with 43 additions and 24 deletions
|
@ -86,11 +86,7 @@ crate type NameDoc = (String, Option<String>);
|
||||||
|
|
||||||
crate fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
|
crate fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
|
||||||
crate::html::format::display_fn(move |f| {
|
crate::html::format::display_fn(move |f| {
|
||||||
if !v.ends_with('/') && !v.is_empty() {
|
if !v.ends_with('/') && !v.is_empty() { write!(f, "{}/", v) } else { write!(f, "{}", v) }
|
||||||
write!(f, "{}/", v)
|
|
||||||
} else {
|
|
||||||
write!(f, "{}", v)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1950,11 +1946,7 @@ fn document_stability(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn document_non_exhaustive_header(item: &clean::Item) -> &str {
|
fn document_non_exhaustive_header(item: &clean::Item) -> &str {
|
||||||
if item.is_non_exhaustive() {
|
if item.is_non_exhaustive() { " (Non-exhaustive)" } else { "" }
|
||||||
" (Non-exhaustive)"
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn document_non_exhaustive(w: &mut Buffer, item: &clean::Item) {
|
fn document_non_exhaustive(w: &mut Buffer, item: &clean::Item) {
|
||||||
|
@ -2636,7 +2628,7 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
|
||||||
write!(w, "{}<span class=\"loading-content\">Loading content...</span>", extra_content)
|
write!(w, "{}<span class=\"loading-content\">Loading content...</span>", extra_content)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trait_item(w: &mut Buffer, cx: &Context, m: &clean::Item, t: &clean::Item) {
|
fn trait_item(w: &mut Buffer, cx: &Context, m: &clean::Item, t: &clean::Item, cache: &Cache) {
|
||||||
let name = m.name.as_ref().unwrap();
|
let name = m.name.as_ref().unwrap();
|
||||||
info!("Documenting {} on {}", name, t.name.as_deref().unwrap_or_default());
|
info!("Documenting {} on {}", name, t.name.as_deref().unwrap_or_default());
|
||||||
let item_type = m.type_();
|
let item_type = m.type_();
|
||||||
|
@ -2645,6 +2637,7 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
|
||||||
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl);
|
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl);
|
||||||
write!(w, "</code>");
|
write!(w, "</code>");
|
||||||
render_stability_since(w, m, t);
|
render_stability_since(w, m, t);
|
||||||
|
write_srclink(cx, m, w, cache);
|
||||||
write!(w, "</h3>");
|
write!(w, "</h3>");
|
||||||
document(w, cx, m, Some(t));
|
document(w, cx, m, Some(t));
|
||||||
}
|
}
|
||||||
|
@ -2656,8 +2649,8 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
|
||||||
"Associated Types",
|
"Associated Types",
|
||||||
"<div class=\"methods\">",
|
"<div class=\"methods\">",
|
||||||
);
|
);
|
||||||
for t in &types {
|
for t in types {
|
||||||
trait_item(w, cx, *t, it);
|
trait_item(w, cx, t, it, cache);
|
||||||
}
|
}
|
||||||
write_loading_content(w, "</div>");
|
write_loading_content(w, "</div>");
|
||||||
}
|
}
|
||||||
|
@ -2669,8 +2662,8 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
|
||||||
"Associated Constants",
|
"Associated Constants",
|
||||||
"<div class=\"methods\">",
|
"<div class=\"methods\">",
|
||||||
);
|
);
|
||||||
for t in &consts {
|
for t in consts {
|
||||||
trait_item(w, cx, *t, it);
|
trait_item(w, cx, t, it, cache);
|
||||||
}
|
}
|
||||||
write_loading_content(w, "</div>");
|
write_loading_content(w, "</div>");
|
||||||
}
|
}
|
||||||
|
@ -2683,8 +2676,8 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
|
||||||
"Required methods",
|
"Required methods",
|
||||||
"<div class=\"methods\">",
|
"<div class=\"methods\">",
|
||||||
);
|
);
|
||||||
for m in &required {
|
for m in required {
|
||||||
trait_item(w, cx, *m, it);
|
trait_item(w, cx, m, it, cache);
|
||||||
}
|
}
|
||||||
write_loading_content(w, "</div>");
|
write_loading_content(w, "</div>");
|
||||||
}
|
}
|
||||||
|
@ -2695,8 +2688,8 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
|
||||||
"Provided methods",
|
"Provided methods",
|
||||||
"<div class=\"methods\">",
|
"<div class=\"methods\">",
|
||||||
);
|
);
|
||||||
for m in &provided {
|
for m in provided {
|
||||||
trait_item(w, cx, *m, it);
|
trait_item(w, cx, m, it, cache);
|
||||||
}
|
}
|
||||||
write_loading_content(w, "</div>");
|
write_loading_content(w, "</div>");
|
||||||
}
|
}
|
||||||
|
|
|
@ -659,7 +659,7 @@ a {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.invisible > .srclink, h4 > code + .srclink {
|
.invisible > .srclink, h4 > code + .srclink, h3 > code + .srclink {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
|
@ -857,25 +857,25 @@ body.blur > :not(#help) {
|
||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.impl-items .since, .impl .since {
|
.impl-items .since, .impl .since, .methods .since {
|
||||||
flex-grow: 0;
|
flex-grow: 0;
|
||||||
padding-left: 12px;
|
padding-left: 12px;
|
||||||
padding-right: 2px;
|
padding-right: 2px;
|
||||||
position: initial;
|
position: initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
.impl-items .srclink, .impl .srclink {
|
.impl-items .srclink, .impl .srclink, .methods .srclink {
|
||||||
flex-grow: 0;
|
flex-grow: 0;
|
||||||
/* Override header settings otherwise it's too bold */
|
/* Override header settings otherwise it's too bold */
|
||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.impl-items code, .impl code {
|
.impl-items code, .impl code, .methods code {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.impl-items h4, h4.impl, h3.impl {
|
.impl-items h4, h4.impl, h3.impl, .methods h3 {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-basis: 100%;
|
flex-basis: 100%;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|
26
src/test/rustdoc/trait-src-link.rs
Normal file
26
src/test/rustdoc/trait-src-link.rs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#![crate_name = "quix"]
|
||||||
|
pub trait Foo {
|
||||||
|
// @has quix/trait.Foo.html '//a[@href="../src/quix/trait-src-link.rs.html#4"]' '[src]'
|
||||||
|
fn required();
|
||||||
|
|
||||||
|
// @has quix/trait.Foo.html '//a[@href="../src/quix/trait-src-link.rs.html#7"]' '[src]'
|
||||||
|
fn provided() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Bar;
|
||||||
|
|
||||||
|
impl Foo for Bar {
|
||||||
|
// @has quix/struct.Bar.html '//a[@href="../src/quix/trait-src-link.rs.html#14"]' '[src]'
|
||||||
|
fn required() {}
|
||||||
|
// @has quix/struct.Bar.html '//a[@href="../src/quix/trait-src-link.rs.html#7"]' '[src]'
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Baz;
|
||||||
|
|
||||||
|
impl Foo for Baz {
|
||||||
|
// @has quix/struct.Baz.html '//a[@href="../src/quix/trait-src-link.rs.html#22"]' '[src]'
|
||||||
|
fn required() {}
|
||||||
|
|
||||||
|
// @has quix/struct.Baz.html '//a[@href="../src/quix/trait-src-link.rs.html#25"]' '[src]'
|
||||||
|
fn provided() {}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue