From f00d72b78b5fbcc865500184b883f5991e2cf68d Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 2 Oct 2013 19:35:30 +0200 Subject: [PATCH] Make source links highlight the entire definition and not just the first line --- src/librustdoc/html/render.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index b7ee60b9f5474..b39a2bcbfb5e4 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, "[src]", + href='{root}src/{crate}/{path}.html\\#{href}'>[src]", 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