about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJordi Boggiano <j.boggiano@seld.be>2013-10-02 19:35:30 +0200
committerAlex Crichton <alex@alexcrichton.com>2013-10-02 16:17:07 -0700
commitf00d72b78b5fbcc865500184b883f5991e2cf68d (patch)
treec42798bf7eb1df12af30c597edbb4d6d80b53487
parent49e6db7f3510a99ab3d3723b2430add985629c39 (diff)
downloadrust-f00d72b78b5fbcc865500184b883f5991e2cf68d.tar.gz
rust-f00d72b78b5fbcc865500184b883f5991e2cf68d.zip
Make source links highlight the entire definition and not just the first line
-rw-r--r--src/librustdoc/html/render.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index b7ee60b9f54..b39a2bcbfb5 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -714,13 +714,18 @@ impl<'self> fmt::Default for Item<'self> {
             do clean_srcpath(it.item.source.filename) |component| {
                 path.push(component.to_owned());
             }
+            let href = if it.item.source.loline == it.item.source.hiline {
+                format!("{}", it.item.source.loline)
+            } else {
+                format!("{}-{}", it.item.source.loline, it.item.source.hiline)
+            };
             write!(fmt.buf,
                    "<a class='source'
-                       href='{root}src/{crate}/{path}.html\\#{line}'>[src]</a>",
+                       href='{root}src/{crate}/{path}.html\\#{href}'>[src]</a>",
                    root = it.cx.root_path,
                    crate = it.cx.layout.crate,
                    path = path.connect("/"),
-                   line = it.item.source.loline);
+                   href = href);
         }
 
         // Write the breadcrumb trail header for the top