Skip to content

Commit

Permalink
Hide Crate Version on narrow Screens
Browse files Browse the repository at this point in the history
  • Loading branch information
dns2utf8 committed Jun 24, 2021
1 parent e2efcf1 commit cc9ef7d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/etc/htmldocck.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ def check_tree_attr(tree, path, attr, pat, regexp):

def check_tree_text(tree, path, pat, regexp):
path = normalize_xpath(path)
print("normalize_xpath -> {}".format(path))
ret = False
try:
for e in tree.findall(path):
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
write!(
buffer,
"<div class=\"block version\">\
<div class=\"narrow-helper\"></div>
<p>Version {}</p>\
</div>",
Escape(version),
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
"<item-left class=\"{stab}{add}import-item\">\
<code>{vis}{imp}</code>\
</item-left>\
<item-right class=\"docblock-short\">{stab_tags}</item-right>\n",
<item-right class=\"docblock-short\">{stab_tags}</item-right>",
stab = stab.unwrap_or_default(),
add = add,
vis = myitem.visibility.print_with_space(myitem.def_id, cx),
Expand Down Expand Up @@ -361,7 +361,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
"<item-left class=\"{stab}{add}module-item\">\
<a class=\"{class}\" href=\"{href}\" \
title=\"{title}\">{name}</a>{unsafety_flag}</item-left>\
<item-right class=\"docblock-short\">{stab_tags}{docs}</item-right>\n",
<item-right class=\"docblock-short\">{stab_tags}{docs}</item-right>",
name = *myitem.name.as_ref().unwrap(),
stab_tags = extra_info_tags(myitem, item, cx.tcx()),
docs = MarkdownSummaryLine(&doc_value, &myitem.links(cx)).into_string(),
Expand All @@ -381,7 +381,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
}

if curty.is_some() {
w.write_str("</item-table>\n");
w.write_str("</item-table>");
}
}

Expand Down
19 changes: 17 additions & 2 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1619,9 +1619,25 @@ details.undocumented[open] > summary::before {
}

.sidebar > .block.version {
overflow: hidden;
border-bottom: none;
margin-top: 12px;
margin-bottom: 0;
height: 100%;
padding-left: 12px;
}
.sidebar > .block.version > div.narrow-helper {
float: left;
width: 1px;
height: 100%;
}
.sidebar > .block.version > p {
/* hide Version text if too narrow */
margin: 0;
min-width: 55px;
/* vertically center */
display: flex;
align-items: center;
height: 100%;
}

nav.sub {
Expand Down Expand Up @@ -1779,7 +1795,6 @@ details.undocumented[open] > summary::before {
.search-results .result-name, .search-results div.desc, .search-results .result-description {
width: 100%;
}
/* Display second row of staggered layouts */
.search-results div.desc, .search-results .result-description, item-right {
padding-left: 2em;
}
Expand Down

0 comments on commit cc9ef7d

Please sign in to comment.