rustdoc: use <wbr>
in sidebar headers
This also improves sidebar layout, so instead of BTreeM ap you get this BTree Map
This commit is contained in:
parent
9186001f34
commit
1d339b07ca
5 changed files with 24 additions and 4 deletions
|
@ -69,6 +69,8 @@ struct PageLayout<'a> {
|
||||||
display_krate_version_extra: &'a str,
|
display_krate_version_extra: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) use crate::html::render::sidebar::filters;
|
||||||
|
|
||||||
pub(crate) fn render<T: Print, S: Print>(
|
pub(crate) fn render<T: Print, S: Print>(
|
||||||
layout: &Layout,
|
layout: &Layout,
|
||||||
page: &Page<'_>,
|
page: &Page<'_>,
|
||||||
|
|
|
@ -30,7 +30,7 @@ mod tests;
|
||||||
|
|
||||||
mod context;
|
mod context;
|
||||||
mod print_item;
|
mod print_item;
|
||||||
mod sidebar;
|
pub(crate) mod sidebar;
|
||||||
mod span_map;
|
mod span_map;
|
||||||
mod type_layout;
|
mod type_layout;
|
||||||
mod write_shared;
|
mod write_shared;
|
||||||
|
|
|
@ -77,6 +77,22 @@ impl<'a> Link<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) mod filters {
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
|
use rinja::filters::Safe;
|
||||||
|
|
||||||
|
use crate::html::escape::EscapeBodyTextWithWbr;
|
||||||
|
use crate::html::render::display_fn;
|
||||||
|
pub(crate) fn wrapped<T>(v: T) -> rinja::Result<Safe<impl Display>>
|
||||||
|
where
|
||||||
|
T: Display,
|
||||||
|
{
|
||||||
|
let string = v.to_string();
|
||||||
|
Ok(Safe(display_fn(move |f| EscapeBodyTextWithWbr(&string).fmt(f))))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
|
pub(super) fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
|
||||||
let blocks: Vec<LinkBlock<'_>> = match *it.kind {
|
let blocks: Vec<LinkBlock<'_>> = match *it.kind {
|
||||||
clean::StructItem(ref s) => sidebar_struct(cx, it, s),
|
clean::StructItem(ref s) => sidebar_struct(cx, it, s),
|
||||||
|
|
|
@ -98,7 +98,7 @@
|
||||||
</a> {# #}
|
</a> {# #}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<h2> {# #}
|
<h2> {# #}
|
||||||
<a href="{{page.root_path|safe}}{{display_krate_with_trailing_slash|safe}}index.html">{{display_krate}}</a> {# #}
|
<a href="{{page.root_path|safe}}{{display_krate_with_trailing_slash|safe}}index.html">{{display_krate|wrapped|safe}}</a> {# #}
|
||||||
{% if !display_krate_version_number.is_empty() %}
|
{% if !display_krate_version_number.is_empty() %}
|
||||||
<span class="version">{{+ display_krate_version_number}}</span>
|
<span class="version">{{+ display_krate_version_number}}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% if !title.is_empty() %}
|
{% if !title.is_empty() %}
|
||||||
<h2 class="location"> {# #}
|
<h2 class="location"> {# #}
|
||||||
<a href="#">{{title_prefix}}{{title}}</a> {# #}
|
<a href="#">{{title_prefix}}{{title|wrapped|safe}}</a> {# #}
|
||||||
</h2>
|
</h2>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="sidebar-elems">
|
<div class="sidebar-elems">
|
||||||
|
@ -15,7 +15,9 @@
|
||||||
{% for block in blocks %}
|
{% for block in blocks %}
|
||||||
{% if block.should_render() %}
|
{% if block.should_render() %}
|
||||||
{% if !block.heading.name.is_empty() %}
|
{% if !block.heading.name.is_empty() %}
|
||||||
<h3><a href="#{{block.heading.href|safe}}">{{block.heading.name}}</a></h3>
|
<h3><a href="#{{block.heading.href|safe}}"> {# #}
|
||||||
|
{{block.heading.name|wrapped|safe}} {# #}
|
||||||
|
</a></h3> {# #}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if !block.links.is_empty() %}
|
{% if !block.links.is_empty() %}
|
||||||
<ul class="block{% if !block.class.is_empty() +%} {{+block.class}}{% endif %}">
|
<ul class="block{% if !block.class.is_empty() +%} {{+block.class}}{% endif %}">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue