about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2024-10-07 13:27:50 -0700
committerMichael Howell <michael@notriddle.com>2024-10-07 13:27:50 -0700
commitf7eced3a21a3a0377b2a23ba6fb0f8a346e837f1 (patch)
treefdff127397abe9dc549b152076118809c33f216a
parente23419fc97a8ca2fb3f6331115c13b2a5948d2c9 (diff)
downloadrust-f7eced3a21a3a0377b2a23ba6fb0f8a346e837f1.tar.gz
rust-f7eced3a21a3a0377b2a23ba6fb0f8a346e837f1.zip
Add comment to describe camelcase line break
-rw-r--r--src/librustdoc/html/escape.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/librustdoc/html/escape.rs b/src/librustdoc/html/escape.rs
index 72ad42c2bd0..31a2701f06a 100644
--- a/src/librustdoc/html/escape.rs
+++ b/src/librustdoc/html/escape.rs
@@ -108,6 +108,16 @@ 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(':'));
+            // Check for CamelCase.
+            //
+            // `i - last > 3` avoids turning FmRadio into Fm<wbr>Radio, which is technically
+            // correct, but needlessly bloated.
+            //
+            // is_uppercase && !next_is_uppercase checks for camelCase. HTTPSProxy,
+            // for example, should become HTTPS<wbr>Proxy.
+            //
+            // !next_is_underscore avoids turning TEST_RUN into TEST<wbr>_<wbr>RUN, which is also
+            // needlessly bloated.
             if i - last > 3 && is_uppercase() && !next_is_uppercase() && !next_is_underscore() {
                 EscapeBodyText(&text[last..i]).fmt(fmt)?;
                 fmt.write_str("<wbr>")?;