Auto merge of #50953 - GuillaumeGomez:attributes-in-other-places, r=QuietMisdreavus
Add attributes for trait and methods as well Fixes #48485. r? @QuietMisdreavus
This commit is contained in:
commit
251ec62a13
@ -3055,6 +3055,7 @@ fn render_assoc_item(w: &mut fmt::Formatter,
|
||||
} else {
|
||||
(0, true)
|
||||
};
|
||||
render_attributes(w, meth)?;
|
||||
write!(w, "{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
|
||||
{generics}{decl}{where_clause}",
|
||||
VisSpace(&meth.visibility),
|
||||
|
@ -2041,16 +2041,16 @@
|
||||
|
||||
autoCollapseAllImpls(getPageId());
|
||||
|
||||
function createToggleWrapper() {
|
||||
function createToggleWrapper(tog) {
|
||||
var span = document.createElement('span');
|
||||
span.className = 'toggle-label';
|
||||
span.style.display = 'none';
|
||||
span.innerHTML = ' Expand attributes';
|
||||
toggle.appendChild(span);
|
||||
tog.appendChild(span);
|
||||
|
||||
var wrapper = document.createElement('div');
|
||||
wrapper.className = 'toggle-wrapper toggle-attributes';
|
||||
wrapper.appendChild(toggle);
|
||||
wrapper.appendChild(tog);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@ -2078,13 +2078,11 @@
|
||||
});
|
||||
}
|
||||
|
||||
onEach(document.getElementById('main').getElementsByTagName('pre'), function(e) {
|
||||
onEach(e.getElementsByClassName('attributes'), function(i_e) {
|
||||
i_e.parentNode.insertBefore(createToggleWrapper(), i_e);
|
||||
if (getCurrentValue("rustdoc-item-attributes") !== "false") {
|
||||
collapseDocs(i_e.previousSibling.childNodes[0], "toggle");
|
||||
}
|
||||
});
|
||||
onEach(document.getElementById('main').getElementsByClassName('attributes'), function(i_e) {
|
||||
i_e.parentNode.insertBefore(createToggleWrapper(toggle.cloneNode(true)), i_e);
|
||||
if (getCurrentValue("rustdoc-item-attributes") !== "false") {
|
||||
collapseDocs(i_e.previousSibling.childNodes[0], "toggle");
|
||||
}
|
||||
});
|
||||
|
||||
onEach(document.getElementsByClassName('rust-example-rendered'), function(e) {
|
||||
|
@ -771,7 +771,7 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
|
||||
|
||||
.toggle-wrapper {
|
||||
position: relative;
|
||||
margin-top: 5px;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.toggle-wrapper.collapsed {
|
||||
@ -854,10 +854,19 @@ span.since {
|
||||
|
||||
.attributes {
|
||||
display: block;
|
||||
margin: 0px 0px 0px 30px !important;
|
||||
margin-top: 0px !important;
|
||||
margin-right: 0px;
|
||||
margin-bottom: 0px !important;
|
||||
margin-left: 30px;
|
||||
}
|
||||
.toggle-attributes.collapsed {
|
||||
margin-bottom: 5px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.impl-items > .toggle-attributes {
|
||||
margin-left: 20px;
|
||||
}
|
||||
.impl-items .attributes {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
:target > code {
|
||||
|
32
src/test/rustdoc/trait-attributes.rs
Normal file
32
src/test/rustdoc/trait-attributes.rs
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![crate_name = "foo"]
|
||||
|
||||
// ignore-tidy-linelength
|
||||
|
||||
pub trait Foo {
|
||||
// @has foo/trait.Foo.html '//h3[@id="tymethod.foo"]//div[@class="docblock attributes"]' '#[must_use]'
|
||||
#[must_use]
|
||||
fn foo();
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub struct Bar;
|
||||
|
||||
impl Bar {
|
||||
// @has foo/struct.Bar.html '//h4[@id="method.bar"]//div[@class="docblock attributes"]' '#[must_use]'
|
||||
#[must_use]
|
||||
pub fn bar() {}
|
||||
|
||||
// @has foo/struct.Bar.html '//h4[@id="method.bar2"]//div[@class="docblock attributes"]' '#[must_use]'
|
||||
#[must_use]
|
||||
pub fn bar2() {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user