Skip to content

Commit

Permalink
Improve attributes display and allow expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 6, 2016
1 parent a96247b commit 22dad4b
Show file tree
Hide file tree
Showing 3 changed files with 384 additions and 373 deletions.
17 changes: 9 additions & 8 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2513,15 +2513,16 @@ fn render_attribute(attr: &clean::Attribute, recurse: bool) -> Option<String> {
Some(format!("{} = \"{}\"", k, v))
}
clean::List(ref k, ref values) if attribute_with_values(&*k) => {
let mut display = Vec::new();
let display: Vec<_> = values.iter()
.filter_map(|value| render_attribute(value, true))
.map(|entry| format!("{}", entry))
.collect();

for value in values {
let s = render_attribute(value, true);
if s.len() > 0 {
display.push(format!("{}", s));
}
if display.len() > 0 {
Some(format!("{}({})", k, display.join(", ")))
} else {
None
}
Some(format!("{}({})", k, display.join(", ")))
}
_ => {
None
Expand All @@ -2538,7 +2539,7 @@ fn render_attributes(w: &mut fmt::Formatter, it: &clean::Item) -> fmt::Result {
}
}
if attrs.len() > 0 {
write!(w, "<div class=\"docblock\">{}</div>", &attrs)?;
write!(w, "<div class=\"docblock attributes\">{}</div>", &attrs)?;
}
Ok(())
}
Expand Down
2 changes: 2 additions & 0 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,8 @@
.html('&nbsp;Expand&nbsp;description'));
var wrapper = $("<div class='toggle-wrapper'>").append(mainToggle);
$("#main > .docblock").before(wrapper);
var wrapper = $("<div class='toggle-wrapper toggle-attributes'>").append(mainToggle);
$("#main > pre > .docblock").before(wrapper);
});

$('pre.line-numbers').on('click', 'span', function() {
Expand Down
Loading

0 comments on commit 22dad4b

Please sign in to comment.