Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add information on how crate sizes are computed #2665

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions gui-tests/crate-sizes.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Checks that the size popup work as expected.
go-to: |DOC_PATH| + "/crate/sysinfo/latest"
// By default, they're hidden.
assert-css: (
"div.package-page-container div.package-menu .documented-info .size .info",
{"display": "none"},
)
// When we hover the parent element, it should make them appear.
move-cursor-to: "div.package-page-container div.package-menu .documented-info .size"
wait-for-css: (
"div.package-page-container div.package-menu .documented-info .size .info",
{"display": "block"},
)
// And when we move the mouse cursor away, it's hidden again.
move-cursor-to: "#clipboard"
assert-css: (
"div.package-page-container div.package-menu .documented-info .size .info",
{"display": "none"},
)

// When clicked, the popup should remain visible.
click: "div.package-page-container div.package-menu .documented-info .size"
wait-for-css: (
"div.package-page-container div.package-menu .documented-info .size .info",
{"display": "block"},
)
move-cursor-to: "#clipboard"
assert-css: (
"div.package-page-container div.package-menu .documented-info .size .info",
{"display": "block"},
)
// Clicking somewhere else will change focus, making the popup disappear.
click: "#main"
wait-for-css: (
"div.package-page-container div.package-menu .documented-info .size .info",
{"display": "none"},
)
10 changes: 8 additions & 2 deletions templates/crate/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@
{%- if let Some(source_size) = source_size -%}
<li class="pure-menu-heading">Size</li>
<li class="pure-menu-item">
<span class="documented-info">Source code size: {{(*source_size)|filesizeformat}}</span>
<span class="documented-info">Source code size: {{(*source_size)|filesizeformat}} <span class="size" tabindex=0>
{{- crate::icons::IconCircleInfo.render_solid(false, false, "") -}}
<span class="info">This is the summed size of all the files inside the crates.io package for this release.</span>
</span>
</li>
{%- if let Some(doc_size) = documentation_size -%}
<li class="pure-menu-item">
<span class="documented-info">Documentation size: {{(*doc_size)|filesizeformat}}</span>
<span class="documented-info">Documentation size: {{(*doc_size)|filesizeformat}} <span class="size" tabindex=0>
{{- crate::icons::IconCircleInfo.render_solid(false, false, "") -}}
<span class="info">This is the summed size of all files generated by rustdoc for all configured targets</span>
</span>
</li>
{%- endif -%}
{%- endif -%}
Expand Down
14 changes: 14 additions & 0 deletions templates/style/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,20 @@ div.package-page-container {
width: 100%;
}

.documented-info .size .info {
display: none;
position: absolute;
top: 90%;
background: var(--color-background-code);
z-index: 1;
border: 1px solid var(--color-menu-border);
}

.documented-info .size:hover .info,
.documented-info .size:focus .info {
display: block;
}

li.pure-menu-heading:first-child {
margin-top: 0;
}
Expand Down
Loading