Skip to content

Commit cc9ef7d

Browse files
committed
Hide Crate Version on narrow Screens
1 parent e2efcf1 commit cc9ef7d

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

src/etc/htmldocck.py

-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ def check_tree_attr(tree, path, attr, pat, regexp):
365365

366366
def check_tree_text(tree, path, pat, regexp):
367367
path = normalize_xpath(path)
368-
print("normalize_xpath -> {}".format(path))
369368
ret = False
370369
try:
371370
for e in tree.findall(path):

src/librustdoc/html/render/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
16941694
write!(
16951695
buffer,
16961696
"<div class=\"block version\">\
1697+
<div class=\"narrow-helper\"></div>
16971698
<p>Version {}</p>\
16981699
</div>",
16991700
Escape(version),

src/librustdoc/html/render/print_item.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
329329
"<item-left class=\"{stab}{add}import-item\">\
330330
<code>{vis}{imp}</code>\
331331
</item-left>\
332-
<item-right class=\"docblock-short\">{stab_tags}</item-right>\n",
332+
<item-right class=\"docblock-short\">{stab_tags}</item-right>",
333333
stab = stab.unwrap_or_default(),
334334
add = add,
335335
vis = myitem.visibility.print_with_space(myitem.def_id, cx),
@@ -361,7 +361,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
361361
"<item-left class=\"{stab}{add}module-item\">\
362362
<a class=\"{class}\" href=\"{href}\" \
363363
title=\"{title}\">{name}</a>{unsafety_flag}</item-left>\
364-
<item-right class=\"docblock-short\">{stab_tags}{docs}</item-right>\n",
364+
<item-right class=\"docblock-short\">{stab_tags}{docs}</item-right>",
365365
name = *myitem.name.as_ref().unwrap(),
366366
stab_tags = extra_info_tags(myitem, item, cx.tcx()),
367367
docs = MarkdownSummaryLine(&doc_value, &myitem.links(cx)).into_string(),
@@ -381,7 +381,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
381381
}
382382

383383
if curty.is_some() {
384-
w.write_str("</item-table>\n");
384+
w.write_str("</item-table>");
385385
}
386386
}
387387

src/librustdoc/html/static/rustdoc.css

+17-2
Original file line numberDiff line numberDiff line change
@@ -1619,9 +1619,25 @@ details.undocumented[open] > summary::before {
16191619
}
16201620

16211621
.sidebar > .block.version {
1622+
overflow: hidden;
16221623
border-bottom: none;
1623-
margin-top: 12px;
16241624
margin-bottom: 0;
1625+
height: 100%;
1626+
padding-left: 12px;
1627+
}
1628+
.sidebar > .block.version > div.narrow-helper {
1629+
float: left;
1630+
width: 1px;
1631+
height: 100%;
1632+
}
1633+
.sidebar > .block.version > p {
1634+
/* hide Version text if too narrow */
1635+
margin: 0;
1636+
min-width: 55px;
1637+
/* vertically center */
1638+
display: flex;
1639+
align-items: center;
1640+
height: 100%;
16251641
}
16261642

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

0 commit comments

Comments
 (0)