Rollup merge of #62734 - GuillaumeGomez:hide-default-methods, r=Mark-Simulacrum
Hide trait default methods Fixes #62499. However, the question remains: do we want to extend it to this point or not? r? @QuietMisdreavus
This commit is contained in:
commit
1ea8fc587c
6 changed files with 24 additions and 21 deletions
|
@ -2405,13 +2405,14 @@ fn document(w: &mut fmt::Formatter<'_>, cx: &Context, item: &clean::Item) -> fmt
|
|||
}
|
||||
|
||||
/// Render md_text as markdown.
|
||||
fn render_markdown(w: &mut fmt::Formatter<'_>,
|
||||
cx: &Context,
|
||||
md_text: &str,
|
||||
links: Vec<(String, String)>,
|
||||
prefix: &str,
|
||||
is_hidden: bool)
|
||||
-> fmt::Result {
|
||||
fn render_markdown(
|
||||
w: &mut fmt::Formatter<'_>,
|
||||
cx: &Context,
|
||||
md_text: &str,
|
||||
links: Vec<(String, String)>,
|
||||
prefix: &str,
|
||||
is_hidden: bool,
|
||||
) -> fmt::Result {
|
||||
let mut ids = cx.id_map.borrow_mut();
|
||||
write!(w, "<div class='docblock{}'>{}{}</div>",
|
||||
if is_hidden { " hidden" } else { "" },
|
||||
|
@ -2425,7 +2426,8 @@ fn document_short(
|
|||
cx: &Context,
|
||||
item: &clean::Item,
|
||||
link: AssocItemLink<'_>,
|
||||
prefix: &str, is_hidden: bool
|
||||
prefix: &str,
|
||||
is_hidden: bool,
|
||||
) -> fmt::Result {
|
||||
if let Some(s) = item.doc_value() {
|
||||
let markdown = if s.contains('\n') {
|
||||
|
@ -4084,9 +4086,10 @@ fn render_impl(w: &mut fmt::Formatter<'_>, cx: &Context, i: &Impl, link: AssocIt
|
|||
RenderMode::ForDeref { mut_: deref_mut_ } => should_render_item(&item, deref_mut_),
|
||||
};
|
||||
|
||||
let (is_hidden, extra_class) = if trait_.is_none() ||
|
||||
item.doc_value().is_some() ||
|
||||
item.inner.is_associated() {
|
||||
let (is_hidden, extra_class) = if (trait_.is_none() ||
|
||||
item.doc_value().is_some() ||
|
||||
item.inner.is_associated()) &&
|
||||
!is_default_item {
|
||||
(false, "")
|
||||
} else {
|
||||
(true, " hidden")
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
// Local js definitions:
|
||||
/* global addClass, getCurrentValue, hasClass */
|
||||
/* global isHidden onEach, removeClass, updateLocalStorage */
|
||||
/* global isHidden, onEach, removeClass, updateLocalStorage */
|
||||
|
||||
if (!String.prototype.startsWith) {
|
||||
String.prototype.startsWith = function(searchString, position) {
|
||||
|
|
|
@ -95,5 +95,5 @@ impl Qux for Bar {
|
|||
/// Docs for QUX_DEFAULT1 in impl.
|
||||
const QUX_DEFAULT1: i16 = 7;
|
||||
// @has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32'
|
||||
// @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait."
|
||||
// @has - '//*[@class="docblock hidden"]' "Docs for QUX_DEFAULT2 in trait."
|
||||
}
|
||||
|
|
|
@ -16,15 +16,15 @@ extern crate assoc_items;
|
|||
// @has - '//*[@id="associatedconstant.ConstNoDefault"]' 'const ConstNoDefault: i16'
|
||||
// @has - '//*[@class="docblock"]' 'dox for ConstNoDefault'
|
||||
// @has - '//*[@id="associatedconstant.ConstWithDefault"]' 'const ConstWithDefault: u16'
|
||||
// @has - '//*[@class="docblock"]' 'docs for ConstWithDefault'
|
||||
// @has - '//*[@class="docblock hidden"]' 'docs for ConstWithDefault'
|
||||
// @has - '//*[@id="associatedtype.TypeNoDefault"]' 'type TypeNoDefault = i32'
|
||||
// @has - '//*[@class="docblock"]' 'dox for TypeNoDefault'
|
||||
// @has - '//*[@id="associatedtype.TypeWithDefault"]' 'type TypeWithDefault = u32'
|
||||
// @has - '//*[@class="docblock"]' 'docs for TypeWithDefault'
|
||||
// @has - '//*[@class="docblock hidden"]' 'docs for TypeWithDefault'
|
||||
// @has - '//*[@id="method.method_no_default"]' 'fn method_no_default()'
|
||||
// @has - '//*[@class="docblock"]' 'dox for method_no_default'
|
||||
// @has - '//*[@id="method.method_with_default"]' 'fn method_with_default()'
|
||||
// @has - '//*[@class="docblock"]' 'docs for method_with_default'
|
||||
// @has - '//*[@class="docblock hidden"]' 'docs for method_with_default'
|
||||
pub use assoc_items::MyStruct;
|
||||
|
||||
// @has foo/trait.MyTrait.html
|
||||
|
|
|
@ -8,5 +8,5 @@ extern crate impl_inline_without_trait;
|
|||
|
||||
// @has 'foo/struct.MyStruct.html'
|
||||
// @has - '//*[@id="method.my_trait_method"]' 'fn my_trait_method()'
|
||||
// @has - '//*[@class="docblock"]' 'docs for my_trait_method'
|
||||
// @has - '//*[@class="docblock hidden"]' 'docs for my_trait_method'
|
||||
pub use impl_inline_without_trait::MyStruct;
|
||||
|
|
|
@ -24,10 +24,10 @@ pub trait T {
|
|||
// @has - '//*[@class="docblock"]' 'Docs associated with the S1 trait implementation.'
|
||||
// @has - '//*[@class="docblock"]' 'Docs associated with the S1 trait a_method implementation.'
|
||||
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
|
||||
// @has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
|
||||
// @has - '//*[@class="docblock"]' 'Docs associated with the trait c_method definition.'
|
||||
// @has - '//*[@class="docblock hidden"]' 'Docs associated with the trait b_method definition.'
|
||||
// @has - '//*[@class="docblock hidden"]' 'Docs associated with the trait c_method definition.'
|
||||
// @!has - '//*[@class="docblock"]' 'There is another line'
|
||||
// @has - '//*[@class="docblock"]' 'Read more'
|
||||
// @has - '//*[@class="docblock hidden"]' 'Read more'
|
||||
pub struct S1(usize);
|
||||
|
||||
/// Docs associated with the S1 trait implementation.
|
||||
|
@ -44,7 +44,7 @@ impl T for S1 {
|
|||
// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait c_method implementation.'
|
||||
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
|
||||
// @!has - '//*[@class="docblock"]' 'Docs associated with the trait c_method definition.'
|
||||
// @has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
|
||||
// @has - '//*[@class="docblock hidden"]' 'Docs associated with the trait b_method definition.'
|
||||
pub struct S2(usize);
|
||||
|
||||
/// Docs associated with the S2 trait implementation.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue