-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
rustdoc: improve <wbr>
-insertion for SCREAMING_CAMEL_CASE
#131370
rustdoc: improve <wbr>
-insertion for SCREAMING_CAMEL_CASE
#131370
Conversation
rustbot has assigned @GuillaumeGomez. Use |
src/librustdoc/html/escape/tests.rs
Outdated
@@ -24,6 +24,7 @@ fn escape_body_text_with_wbr() { | |||
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("_SIDD_MASKED_NEGATIVE_POLARITY").to_string(), "_SIDD_<wbr>MASKED_<wbr>NEGATIVE_<wbr>POLARITY"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sample is pulled from core/arch, and before this patch it was written _SID<wbr>D_<wbr>MASKE<wbr>D_<wbr>NEGATIV<wbr>E_<wbr>POLARITY
which is clearly worse.
This comment has been minimized.
This comment has been minimized.
24cbbf9
to
e23419f
Compare
@@ -108,7 +108,7 @@ impl<'a> fmt::Display for EscapeBodyTextWithWbr<'a> { | |||
|| 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() { | |||
if i - last > 3 && is_uppercase() && !next_is_uppercase() && !next_is_underscore() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this code is now complex enough to deserve a small comment (at least on this if
) to explain what it's checking (with some examples to make it even simpler).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. No problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks!
@bors r+ rollup |
…l-case, r=GuillaumeGomez rustdoc: improve `<wbr>`-insertion for SCREAMING_CAMEL_CASE
…llaumeGomez Rollup of 4 pull requests Successful merges: - rust-lang#130824 (Add missing module flags for `-Zfunction-return=thunk-extern`) - rust-lang#131170 (Fix `target_vendor` in non-IDF Xtensa ESP32 targets) - rust-lang#131369 (Update books) - rust-lang#131370 (rustdoc: improve `<wbr>`-insertion for SCREAMING_CAMEL_CASE) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 7 pull requests Successful merges: - rust-lang#130824 (Add missing module flags for `-Zfunction-return=thunk-extern`) - rust-lang#131170 (Fix `target_vendor` in non-IDF Xtensa ESP32 targets) - rust-lang#131355 (Add tests for some old fixed issues) - rust-lang#131369 (Update books) - rust-lang#131370 (rustdoc: improve `<wbr>`-insertion for SCREAMING_CAMEL_CASE) - rust-lang#131379 (Fix utf8-bom test) - rust-lang#131385 (Un-vacation myself) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#131370 - notriddle:notriddle/screaming-camel-case, r=GuillaumeGomez rustdoc: improve `<wbr>`-insertion for SCREAMING_CAMEL_CASE
No description provided.