Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #128360

Merged
merged 18 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
adf0dff
Not lint pub structs without pub constructors if containing fields of…
mu001999 Jul 23, 2024
06d64ea
simplify the use of `CiEnv`
onur-ozkan Jul 29, 2024
f3661dc
rustdoc: word wrap CamelCase in the item list table
notriddle Jun 10, 2024
583bf1e
Fix tidy call in runtest with custom HTML element
notriddle Jun 10, 2024
0d0e18e
rustdoc: use `<wbr>`-tolerant function to check text contents
notriddle Jul 7, 2024
9186001
rustdoc: avoid redundant HTML when there's already line breaks
notriddle Jul 7, 2024
f990239
Stop using MoveDataParamEnv for places that don't need a param-env
compiler-errors Jul 24, 2024
23f46e5
Stabilize offset_of_nested
GKFX Jul 29, 2024
f4fa80f
triagebot: make sure Nora is called Nora
jieyouxu Jul 29, 2024
1d339b0
rustdoc: use `<wbr>` in sidebar headers
notriddle Jul 7, 2024
3bf8bcf
rustdoc: properly handle path wrapping
notriddle Jul 19, 2024
ac303df
rustdoc: move the wbr after the underscore, instead of before
notriddle Jul 22, 2024
9aedec9
Rollup merge of #126247 - notriddle:notriddle/word-wrap-item-table, r…
matthiaskrgr Jul 29, 2024
91b18a0
Rollup merge of #128104 - mu001999-contrib:fix/128053, r=petrochenkov
matthiaskrgr Jul 29, 2024
b02cf4c
Rollup merge of #128153 - compiler-errors:mdpe, r=cjgillot
matthiaskrgr Jul 29, 2024
a73a025
Rollup merge of #128284 - GKFX:stabilize-offset-of-nested, r=dtolnay,…
matthiaskrgr Jul 29, 2024
4d78d11
Rollup merge of #128342 - onur-ozkan:ci-env-usage, r=Kobzol
matthiaskrgr Jul 29, 2024
c261620
Rollup merge of #128355 - jieyouxu:rename-nora, r=aDotInTheVoid
matthiaskrgr Jul 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rustdoc: properly handle path wrapping
  • Loading branch information
notriddle committed Jul 29, 2024
commit 3bf8bcfbe0ebd9527a8ec107c83085cd2d4d6ec1
5 changes: 5 additions & 0 deletions src/librustdoc/html/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,17 @@ impl<'a> fmt::Display for EscapeBodyTextWithWbr<'a> {
let next_is_uppercase =
|| pk.map_or(true, |(_, t)| t.chars().any(|c| c.is_uppercase()));
let next_is_underscore = || pk.map_or(true, |(_, t)| t.contains('_'));
let next_is_colon = || pk.map_or(true, |(_, t)| t.contains(':'));
if (i - last > 3 && is_uppercase() && !next_is_uppercase())
|| (s.contains('_') && !next_is_underscore())
{
EscapeBodyText(&text[last..i]).fmt(fmt)?;
fmt.write_str("<wbr>")?;
last = i;
} else if s.contains(':') && !next_is_colon() {
EscapeBodyText(&text[last..i + 1]).fmt(fmt)?;
fmt.write_str("<wbr>")?;
last = i + 1;
}
}
if last < text.len() {
Expand Down
9 changes: 8 additions & 1 deletion src/librustdoc/html/escape/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ fn escape_body_text_with_wbr() {
assert_eq!(&E("").to_string(), "");
assert_eq!(&E("a").to_string(), "a");
assert_eq!(&E("A").to_string(), "A");
assert_eq!(&E("_").to_string(), "_");
assert_eq!(&E(":").to_string(), ":");
assert_eq!(&E(" ").to_string(), " ");
assert_eq!(&E("___________").to_string(), "___________");
assert_eq!(&E(":::::::::::").to_string(), ":::::::::::");
assert_eq!(&E(" ").to_string(), " ");
// real(istic) examples
assert_eq!(&E("FirstSecond").to_string(), "First<wbr>Second");
assert_eq!(&E("First_Second").to_string(), "First<wbr>_Second");
Expand All @@ -15,8 +21,9 @@ fn escape_body_text_with_wbr() {
assert_eq!(&E("First SecondThird").to_string(), "First Second<wbr>Third");
assert_eq!(&E("First<T>_Second").to_string(), "First&lt;<wbr>T&gt;<wbr>_Second");
assert_eq!(&E("first_second").to_string(), "first<wbr>_second");
assert_eq!(&E("first:second").to_string(), "first:<wbr>second");
assert_eq!(&E("first::second").to_string(), "first::<wbr>second");
assert_eq!(&E("MY_CONSTANT").to_string(), "MY<wbr>_CONSTANT");
assert_eq!(&E("___________").to_string(), "___________");
// a string won't get wrapped if it's less than 8 bytes
assert_eq!(&E("HashSet").to_string(), "HashSet");
// an individual word won't get wrapped if it's less than 4 bytes
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ fn extra_info_tags<'a, 'tcx: 'a>(
display_fn(move |f| {
write!(
f,
r#"<span class="stab {class}" title="{title}">{contents}</span>"#,
r#"<wbr><span class="stab {class}" title="{title}">{contents}</span>"#,
title = Escape(title),
)
})
Expand Down
5 changes: 4 additions & 1 deletion src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -586,12 +586,15 @@ ul.block, .block li {
}

.sidebar h2 {
text-wrap: balance;
overflow-wrap: anywhere;
padding: 0;
margin: 0.7rem 0;
}

.sidebar h3 {
text-wrap: balance;
overflow-wrap: anywhere;
font-size: 1.125rem; /* 18px */
padding: 0;
margin: 0;
Expand Down Expand Up @@ -2222,7 +2225,7 @@ in src-script.js and main.js
width: 33%;
}
.item-table > li > div {
word-break: break-all;
overflow-wrap: anywhere;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/templates/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ <h3><a href="#{{block.heading.href|safe}}"> {# #}
</section>
{% endif %}
{% if !path.is_empty() %}
<h2><a href="{% if is_mod %}../{% endif %}index.html">In {{+ path}}</a></h2>
<h2><a href="{% if is_mod %}../{% endif %}index.html">In {{+ path|wrapped|safe}}</a></h2>
{% endif %}
</div>
3 changes: 2 additions & 1 deletion tests/rustdoc-gui/label-next-to-symbol.goml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ compare-elements-position-near: (
".item-name .stab.deprecated",
{"y": 2},
)
compare-elements-position: (
// "Unix" part is on second line
compare-elements-position-false: (
".item-name .stab.deprecated",
".item-name .stab.portability",
["y"],
Expand Down