heading_level: u32 -> heading_offset: HeadingOffset
This commit is contained in:
parent
13558ee0a0
commit
f1425c7c3e
7 changed files with 88 additions and 61 deletions
|
@ -67,7 +67,7 @@ use crate::html::format::{
|
|||
href, print_abi_with_space, print_constness_with_space, print_default_space,
|
||||
print_generic_bounds, print_where_clause, Buffer, HrefError, PrintWithSpace,
|
||||
};
|
||||
use crate::html::markdown::{Markdown, MarkdownHtml, MarkdownSummaryLine};
|
||||
use crate::html::markdown::{HeadingOffset, Markdown, MarkdownHtml, MarkdownSummaryLine};
|
||||
|
||||
/// A pair of name and its optional document.
|
||||
crate type NameDoc = (String, Option<String>);
|
||||
|
@ -475,16 +475,16 @@ fn document(
|
|||
cx: &Context<'_>,
|
||||
item: &clean::Item,
|
||||
parent: Option<&clean::Item>,
|
||||
level: u32,
|
||||
heading_offset: HeadingOffset,
|
||||
) {
|
||||
if let Some(ref name) = item.name {
|
||||
info!("Documenting {}", name);
|
||||
}
|
||||
document_item_info(w, cx, item, parent);
|
||||
if parent.is_none() {
|
||||
document_full_collapsible(w, item, cx, level);
|
||||
document_full_collapsible(w, item, cx, heading_offset);
|
||||
} else {
|
||||
document_full(w, item, cx, level);
|
||||
document_full(w, item, cx, heading_offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -494,7 +494,7 @@ fn render_markdown(
|
|||
cx: &Context<'_>,
|
||||
md_text: &str,
|
||||
links: Vec<RenderedLink>,
|
||||
heading_level: u32,
|
||||
heading_offset: HeadingOffset,
|
||||
) {
|
||||
let mut ids = cx.id_map.borrow_mut();
|
||||
write!(
|
||||
|
@ -507,7 +507,7 @@ fn render_markdown(
|
|||
error_codes: cx.shared.codes,
|
||||
edition: cx.shared.edition(),
|
||||
playground: &cx.shared.playground,
|
||||
heading_level,
|
||||
heading_offset,
|
||||
}
|
||||
.into_string()
|
||||
)
|
||||
|
@ -544,12 +544,22 @@ fn document_short(
|
|||
}
|
||||
}
|
||||
|
||||
fn document_full_collapsible(w: &mut Buffer, item: &clean::Item, cx: &Context<'_>, level: u32) {
|
||||
document_full_inner(w, item, cx, true, level);
|
||||
fn document_full_collapsible(
|
||||
w: &mut Buffer,
|
||||
item: &clean::Item,
|
||||
cx: &Context<'_>,
|
||||
heading_offset: HeadingOffset,
|
||||
) {
|
||||
document_full_inner(w, item, cx, true, heading_offset);
|
||||
}
|
||||
|
||||
fn document_full(w: &mut Buffer, item: &clean::Item, cx: &Context<'_>, level: u32) {
|
||||
document_full_inner(w, item, cx, false, level);
|
||||
fn document_full(
|
||||
w: &mut Buffer,
|
||||
item: &clean::Item,
|
||||
cx: &Context<'_>,
|
||||
heading_offset: HeadingOffset,
|
||||
) {
|
||||
document_full_inner(w, item, cx, false, heading_offset);
|
||||
}
|
||||
|
||||
fn document_full_inner(
|
||||
|
@ -557,7 +567,7 @@ fn document_full_inner(
|
|||
item: &clean::Item,
|
||||
cx: &Context<'_>,
|
||||
is_collapsible: bool,
|
||||
level: u32,
|
||||
heading_offset: HeadingOffset,
|
||||
) {
|
||||
if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) {
|
||||
debug!("Doc block: =====\n{}\n=====", s);
|
||||
|
@ -568,10 +578,10 @@ fn document_full_inner(
|
|||
<span>Expand description</span>\
|
||||
</summary>",
|
||||
);
|
||||
render_markdown(w, cx, &s, item.links(cx), level);
|
||||
render_markdown(w, cx, &s, item.links(cx), heading_offset);
|
||||
w.write_str("</details>");
|
||||
} else {
|
||||
render_markdown(w, cx, &s, item.links(cx), level);
|
||||
render_markdown(w, cx, &s, item.links(cx), heading_offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1340,7 +1350,7 @@ fn render_impl(
|
|||
// because impls can't have a stability.
|
||||
if item.doc_value().is_some() {
|
||||
document_item_info(&mut info_buffer, cx, it, Some(parent));
|
||||
document_full(&mut doc_buffer, item, cx, 4);
|
||||
document_full(&mut doc_buffer, item, cx, HeadingOffset::H5);
|
||||
short_documented = false;
|
||||
} else {
|
||||
// In case the item isn't documented,
|
||||
|
@ -1358,7 +1368,7 @@ fn render_impl(
|
|||
} else {
|
||||
document_item_info(&mut info_buffer, cx, item, Some(parent));
|
||||
if rendering_params.show_def_docs {
|
||||
document_full(&mut doc_buffer, item, cx, 4);
|
||||
document_full(&mut doc_buffer, item, cx, HeadingOffset::H5);
|
||||
short_documented = false;
|
||||
}
|
||||
}
|
||||
|
@ -1599,7 +1609,7 @@ fn render_impl(
|
|||
error_codes: cx.shared.codes,
|
||||
edition: cx.shared.edition(),
|
||||
playground: &cx.shared.playground,
|
||||
heading_level: 1
|
||||
heading_offset: HeadingOffset::H2
|
||||
}
|
||||
.into_string()
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue