Correctly generate item info of trait items

This commit is contained in:
Guillaume Gomez 2024-03-01 15:20:24 +01:00
parent 71a7b66f20
commit bc261998c5
2 changed files with 14 additions and 13 deletions

View File

@ -1680,7 +1680,7 @@ fn render_impl(
write!( write!(
&mut doc_buffer, &mut doc_buffer,
"{}", "{}",
document_short(item, cx, link, parent, rendering_params.show_def_docs,) document_short(item, cx, link, parent, rendering_params.show_def_docs)
); );
} }
} }
@ -2043,15 +2043,13 @@ pub(crate) fn render_impl_summary(
w.write_str("</h3>"); w.write_str("</h3>");
let is_trait = inner_impl.trait_.is_some(); let is_trait = inner_impl.trait_.is_some();
if is_trait { if is_trait && let Some(portability) = portability(&i.impl_item, Some(parent)) {
if let Some(portability) = portability(&i.impl_item, Some(parent)) { write!(
write!( w,
w, "<span class=\"item-info\">\
"<span class=\"item-info\">\ <div class=\"stab portability\">{portability}</div>\
<div class=\"stab portability\">{portability}</div>\ </span>",
</span>", );
);
}
} }
w.write_str("</section>"); w.write_str("</section>");

View File

@ -33,6 +33,7 @@ use crate::html::format::{
}; };
use crate::html::layout::Page; use crate::html::layout::Page;
use crate::html::markdown::{HeadingOffset, MarkdownSummaryLine}; use crate::html::markdown::{HeadingOffset, MarkdownSummaryLine};
use crate::html::render::{document_full, document_item_info};
use crate::html::url_parts_builder::UrlPartsBuilder; use crate::html::url_parts_builder::UrlPartsBuilder;
use crate::html::{highlight, static_files}; use crate::html::{highlight, static_files};
@ -818,8 +819,10 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
info!("Documenting {name} on {ty_name:?}", ty_name = t.name); info!("Documenting {name} on {ty_name:?}", ty_name = t.name);
let item_type = m.type_(); let item_type = m.type_();
let id = cx.derive_id(format!("{item_type}.{name}")); let id = cx.derive_id(format!("{item_type}.{name}"));
let mut content = Buffer::empty_from(w); let mut content = Buffer::empty_from(w);
write!(&mut content, "{}", document(cx, m, Some(t), HeadingOffset::H5)); write!(content, "{}", document_full(m, cx, HeadingOffset::H5));
let toggled = !content.is_empty(); let toggled = !content.is_empty();
if toggled { if toggled {
let method_toggle_class = if item_type.is_method() { " method-toggle" } else { "" }; let method_toggle_class = if item_type.is_method() { " method-toggle" } else { "" };
@ -836,8 +839,8 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
cx, cx,
RenderMode::Normal, RenderMode::Normal,
); );
w.write_str("</h4>"); w.write_str("</h4></section>");
w.write_str("</section>"); document_item_info(cx, m, Some(t)).render_into(w).unwrap();
if toggled { if toggled {
write!(w, "</summary>"); write!(w, "</summary>");
w.push_buffer(content); w.push_buffer(content);