Clean render_impl arguments
This commit is contained in:
parent
d7159bdbad
commit
fba4149bf1
@ -711,13 +711,15 @@ fn render_impls(
|
||||
containing_item,
|
||||
assoc_link,
|
||||
RenderMode::Normal,
|
||||
true,
|
||||
None,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
&[],
|
||||
true,
|
||||
ImplRenderingParameters {
|
||||
show_def_docs: true,
|
||||
is_on_foreign_type: false,
|
||||
show_default_items: true,
|
||||
show_non_assoc_items: true,
|
||||
toggle_open_by_default: true,
|
||||
},
|
||||
);
|
||||
buffer.into_inner()
|
||||
})
|
||||
@ -1052,13 +1054,15 @@ fn render_assoc_items(
|
||||
containing_item,
|
||||
AssocItemLink::Anchor(None),
|
||||
render_mode,
|
||||
true,
|
||||
None,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
&[],
|
||||
true,
|
||||
ImplRenderingParameters {
|
||||
show_def_docs: true,
|
||||
is_on_foreign_type: false,
|
||||
show_default_items: true,
|
||||
show_non_assoc_items: true,
|
||||
toggle_open_by_default: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1248,6 +1252,16 @@ fn notable_traits_decl(decl: &clean::FnDecl, cx: &Context<'_>) -> String {
|
||||
out.into_inner()
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct ImplRenderingParameters {
|
||||
show_def_docs: bool,
|
||||
is_on_foreign_type: bool,
|
||||
show_default_items: bool,
|
||||
/// Whether or not to show methods.
|
||||
show_non_assoc_items: bool,
|
||||
toggle_open_by_default: bool,
|
||||
}
|
||||
|
||||
fn render_impl(
|
||||
w: &mut Buffer,
|
||||
cx: &Context<'_>,
|
||||
@ -1255,16 +1269,9 @@ fn render_impl(
|
||||
parent: &clean::Item,
|
||||
link: AssocItemLink<'_>,
|
||||
render_mode: RenderMode,
|
||||
show_def_docs: bool,
|
||||
use_absolute: Option<bool>,
|
||||
is_on_foreign_type: bool,
|
||||
show_default_items: bool,
|
||||
// It'll exclude methods.
|
||||
show_non_assoc_items: bool,
|
||||
// This argument is used to reference same type with different paths to avoid duplication
|
||||
// in documentation pages for trait with automatic implementations like "Send" and "Sync".
|
||||
aliases: &[String],
|
||||
toggle_open_by_default: bool,
|
||||
rendering_params: ImplRenderingParameters,
|
||||
) {
|
||||
let cache = cx.cache();
|
||||
let traits = &cache.traits;
|
||||
@ -1287,13 +1294,12 @@ fn render_impl(
|
||||
render_mode: RenderMode,
|
||||
is_default_item: bool,
|
||||
trait_: Option<&clean::Trait>,
|
||||
show_def_docs: bool,
|
||||
show_non_assoc_items: bool,
|
||||
rendering_params: ImplRenderingParameters,
|
||||
) {
|
||||
let item_type = item.type_();
|
||||
let name = item.name.as_ref().unwrap();
|
||||
|
||||
let render_method_item = show_non_assoc_items
|
||||
let render_method_item = rendering_params.show_non_assoc_items
|
||||
&& match render_mode {
|
||||
RenderMode::Normal => true,
|
||||
RenderMode::ForDeref { mut_: deref_mut_ } => {
|
||||
@ -1322,18 +1328,32 @@ fn render_impl(
|
||||
} else {
|
||||
// In case the item isn't documented,
|
||||
// provide short documentation from the trait.
|
||||
document_short(&mut doc_buffer, it, cx, link, parent, show_def_docs);
|
||||
document_short(
|
||||
&mut doc_buffer,
|
||||
it,
|
||||
cx,
|
||||
link,
|
||||
parent,
|
||||
rendering_params.show_def_docs,
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
document_item_info(&mut info_buffer, cx, item, Some(parent));
|
||||
if show_def_docs {
|
||||
if rendering_params.show_def_docs {
|
||||
document_full(&mut doc_buffer, item, cx);
|
||||
short_documented = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
document_short(&mut doc_buffer, item, cx, link, parent, show_def_docs);
|
||||
document_short(
|
||||
&mut doc_buffer,
|
||||
item,
|
||||
cx,
|
||||
link,
|
||||
parent,
|
||||
rendering_params.show_def_docs,
|
||||
);
|
||||
}
|
||||
}
|
||||
let w = if short_documented && trait_.is_some() { interesting } else { boring };
|
||||
@ -1465,8 +1485,7 @@ fn render_impl(
|
||||
render_mode,
|
||||
false,
|
||||
trait_.map(|t| &t.trait_),
|
||||
show_def_docs,
|
||||
show_non_assoc_items,
|
||||
rendering_params,
|
||||
);
|
||||
}
|
||||
|
||||
@ -1479,8 +1498,7 @@ fn render_impl(
|
||||
parent: &clean::Item,
|
||||
containing_item: &clean::Item,
|
||||
render_mode: RenderMode,
|
||||
show_def_docs: bool,
|
||||
show_non_assoc_items: bool,
|
||||
rendering_params: ImplRenderingParameters,
|
||||
) {
|
||||
for trait_item in &t.items {
|
||||
let n = trait_item.name;
|
||||
@ -1502,8 +1520,7 @@ fn render_impl(
|
||||
render_mode,
|
||||
true,
|
||||
Some(t),
|
||||
show_def_docs,
|
||||
show_non_assoc_items,
|
||||
rendering_params,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1512,7 +1529,7 @@ fn render_impl(
|
||||
// default items which weren't overridden in the implementation block.
|
||||
// We don't emit documentation for default items if they appear in the
|
||||
// Implementations on Foreign Types or Implementors sections.
|
||||
if show_default_items {
|
||||
if rendering_params.show_default_items {
|
||||
if let Some(t) = trait_ {
|
||||
render_default_items(
|
||||
&mut default_impl_items,
|
||||
@ -1523,8 +1540,7 @@ fn render_impl(
|
||||
&i.impl_item,
|
||||
parent,
|
||||
render_mode,
|
||||
show_def_docs,
|
||||
show_non_assoc_items,
|
||||
rendering_params,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1535,7 +1551,7 @@ fn render_impl(
|
||||
write!(
|
||||
w,
|
||||
"<details class=\"rustdoc-toggle implementors-toggle\"{}>",
|
||||
if toggle_open_by_default { " open" } else { "" }
|
||||
if rendering_params.toggle_open_by_default { " open" } else { "" }
|
||||
);
|
||||
write!(w, "<summary>")
|
||||
}
|
||||
@ -1545,9 +1561,9 @@ fn render_impl(
|
||||
i,
|
||||
parent,
|
||||
parent,
|
||||
show_def_docs,
|
||||
rendering_params.show_def_docs,
|
||||
use_absolute,
|
||||
is_on_foreign_type,
|
||||
rendering_params.is_on_foreign_type,
|
||||
aliases,
|
||||
);
|
||||
if toggled {
|
||||
|
@ -17,6 +17,7 @@ use super::{
|
||||
collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_strs, notable_traits_decl,
|
||||
render_assoc_item, render_assoc_items, render_attributes_in_code, render_attributes_in_pre,
|
||||
render_impl, render_stability_since_raw, write_srclink, AssocItemLink, Context,
|
||||
ImplRenderingParameters,
|
||||
};
|
||||
use crate::clean::{self, GetDefId};
|
||||
use crate::formats::item_type::ItemType;
|
||||
@ -735,13 +736,15 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
|
||||
it,
|
||||
assoc_link,
|
||||
RenderMode::Normal,
|
||||
false,
|
||||
None,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
&[],
|
||||
false,
|
||||
ImplRenderingParameters {
|
||||
show_def_docs: false,
|
||||
is_on_foreign_type: true,
|
||||
show_default_items: false,
|
||||
show_non_assoc_items: true,
|
||||
toggle_open_by_default: false,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1396,13 +1399,15 @@ fn render_implementor(
|
||||
trait_,
|
||||
AssocItemLink::Anchor(None),
|
||||
RenderMode::Normal,
|
||||
false,
|
||||
Some(use_absolute),
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
aliases,
|
||||
false,
|
||||
ImplRenderingParameters {
|
||||
show_def_docs: false,
|
||||
is_on_foreign_type: false,
|
||||
show_default_items: false,
|
||||
show_non_assoc_items: false,
|
||||
toggle_open_by_default: false,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user