From c193df8ef295ddd10f262231c21b0ab439ec299e Mon Sep 17 00:00:00 2001 From: Denis Cornehl Date: Thu, 17 Oct 2024 06:49:07 +0200 Subject: [PATCH 1/9] feat: create rebuild-queue and show it under the releases/queue page --- src/build_queue.rs | 2 ++ src/web/releases.rs | 25 ++++++++++++++++++----- templates/releases/build_queue.html | 31 +++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/build_queue.rs b/src/build_queue.rs index 8a0187c98..e427f132b 100644 --- a/src/build_queue.rs +++ b/src/build_queue.rs @@ -15,6 +15,8 @@ use std::sync::Arc; use tokio::runtime::Runtime; use tracing::{debug, error, info}; +pub(crate) const REBUILD_PRIORITY: i32 = 20; + #[derive(Debug, Clone, Eq, PartialEq, serde::Serialize)] pub(crate) struct QueuedCrate { #[serde(skip)] diff --git a/src/web/releases.rs b/src/web/releases.rs index c06e5e633..6c992f011 100644 --- a/src/web/releases.rs +++ b/src/web/releases.rs @@ -1,7 +1,7 @@ //! Releases web handlers use crate::{ - build_queue::QueuedCrate, + build_queue::{QueuedCrate, REBUILD_PRIORITY}, cdn, impl_axum_webpage, utils::{report_error, retry_async}, web::{ @@ -782,16 +782,24 @@ pub(crate) async fn activity_handler(mut conn: DbConnection) -> AxumResult, + rebuild_queue: Vec, active_cdn_deployments: Vec, in_progress_builds: Vec<(String, String)>, csp_nonce: String, + expand_rebuild_queue: bool, } impl_axum_webpage! { BuildQueuePage } +#[derive(Deserialize)] +pub(crate) struct BuildQueueParams { + expand: Option, +} + pub(crate) async fn build_queue_handler( Extension(build_queue): Extension>, mut conn: DbConnection, + Query(params): Query, ) -> AxumResult { let mut active_cdn_deployments: Vec<_> = cdn::queued_or_active_crate_invalidations(&mut conn) .await? @@ -823,6 +831,7 @@ pub(crate) async fn build_queue_handler( .map(|rec| (rec.name, rec.version)) .collect(); + let mut rebuild_queue = Vec::new(); let queue: Vec = build_queue .queued_crates() .await? @@ -834,10 +843,14 @@ pub(crate) async fn build_queue_handler( }) }) .map(|mut krate| { - // The priority here is inverted: in the database if a crate has a higher priority it - // will be built after everything else, which is counter-intuitive for people not - // familiar with docs.rs's inner workings. - krate.priority = -krate.priority; + if krate.priority >= REBUILD_PRIORITY { + rebuild_queue.push(krate.clone()); + } else { + // The priority here is inverted: in the database if a crate has a higher priority it + // will be built after everything else, which is counter-intuitive for people not + // familiar with docs.rs's inner workings. + krate.priority = -krate.priority; + } krate }) @@ -846,9 +859,11 @@ pub(crate) async fn build_queue_handler( Ok(BuildQueuePage { description: "crate documentation scheduled to build & deploy", queue, + rebuild_queue, active_cdn_deployments, in_progress_builds, csp_nonce: String::new(), + expand_rebuild_queue: params.expand.is_some(), }) } diff --git a/templates/releases/build_queue.html b/templates/releases/build_queue.html index 000eaf41c..da3ca52ad 100644 --- a/templates/releases/build_queue.html +++ b/templates/releases/build_queue.html @@ -87,6 +87,37 @@ There is nothing in the queue {%- endif %} + +
+ Rebuild Queue +
+ +
+

+ We continiously rebuild the latest versions for all crates so they can + benefit from new features in rustdoc. +

+ {%- if !expand_rebuild_queue -%} +

There are currently {{ rebuild_queue.len() }} crates in the rebuild queue.

+

Show

+ {%- endif -%} +
+ + {%- if expand_rebuild_queue -%} +
    + {%- if !rebuild_queue.is_empty() -%} + {% for crate_item in rebuild_queue -%} +
  1. + + {{- crate_item.name }} {{ crate_item.version -}} + +
  2. + {%- endfor %} + {%- else %} + There is nothing in the rebuild queue + {%- endif %} +
+ {%- endif -%} {%- endblock body -%} From 3b7d6bc5aa03852c64120ed16a3917f648d40238 Mon Sep 17 00:00:00 2001 From: Zahid Kizmaz Date: Sun, 20 Oct 2024 00:51:07 +0200 Subject: [PATCH 2/9] test: add tests for rebuild-queue functionality --- src/web/releases.rs | 63 ++++++++++++++++++++++++++++- templates/releases/build_queue.html | 4 +- 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/src/web/releases.rs b/src/web/releases.rs index 6c992f011..c546bf656 100644 --- a/src/web/releases.rs +++ b/src/web/releases.rs @@ -1076,7 +1076,7 @@ mod tests { } #[test] - fn search_result_can_retrive_sort_by_from_pagination() { + fn search_result_can_retrieve_sort_by_from_pagination() { wrapper(|env| { let mut crates_io = mockito::Server::new(); env.override_config(|config| { @@ -1853,6 +1853,67 @@ mod tests { }); } + #[test] + fn test_releases_rebuild_queue_empty() { + wrapper(|env| { + let web = env.frontend(); + + let empty = kuchikiki::parse_html().one(web.get("/releases/queue").send()?.text()?); + + assert!(empty + .select(".about > p") + .expect("missing heading") + .any(|el| el.text_contents().contains("We continuously rebuild"))); + + assert!(empty + .select(".about > p") + .expect("missing heading") + .any(|el| el.text_contents().contains("crates in the rebuild queue"))); + + Ok(()) + }); + } + + #[test] + fn test_releases_rebuild_queue_with_crates() { + wrapper(|env| { + let web = env.frontend(); + let queue = env.build_queue(); + queue.add_crate("foo", "1.0.0", REBUILD_PRIORITY, None)?; + queue.add_crate("bar", "0.1.0", REBUILD_PRIORITY + 1, None)?; + queue.add_crate("baz", "0.0.1", REBUILD_PRIORITY - 1, None)?; + + let full = kuchikiki::parse_html().one(web.get("/releases/queue").send()?.text()?); + let items = full + .select(".rebuild-queue-list > li") + .expect("missing list items") + .collect::>(); + + // empty because expand_rebuild_queue is not set + assert_eq!(items.len(), 0); + assert!(full + .select(".about > p") + .expect("missing heading") + .any(|el| el + .text_contents() + .contains("There are currently 2 crates in the rebuild queue"))); + + let full = + kuchikiki::parse_html().one(web.get("/releases/queue?expand=1").send()?.text()?); + let items = full + .select(".rebuild-queue-list > li") + .expect("missing list items") + .collect::>(); + + assert_eq!(items.len(), 2); + assert!(items.iter().any(|li| li.text_contents().contains("foo"))); + assert!(items.iter().any(|li| li.text_contents().contains("bar"))); + assert!(!items.iter().any(|li| li.text_contents().contains("baz"))); + + Ok(()) + }); + } + #[test] fn home_page_links() { wrapper(|env| { diff --git a/templates/releases/build_queue.html b/templates/releases/build_queue.html index da3ca52ad..280b6fdac 100644 --- a/templates/releases/build_queue.html +++ b/templates/releases/build_queue.html @@ -94,7 +94,7 @@

- We continiously rebuild the latest versions for all crates so they can + We continuously rebuild the latest versions for all crates so they can benefit from new features in rustdoc.

{%- if !expand_rebuild_queue -%} @@ -104,7 +104,7 @@
{%- if expand_rebuild_queue -%} -
    +
      {%- if !rebuild_queue.is_empty() -%} {% for crate_item in rebuild_queue -%}
    1. From 97cfecf9d2ce0c348424141171dbdb15c66e5797 Mon Sep 17 00:00:00 2001 From: Zahid Kizmaz Date: Mon, 21 Oct 2024 22:35:42 +0200 Subject: [PATCH 3/9] chore: improve wording and add use same css class for as build-queue --- templates/releases/build_queue.html | 2 +- templates/style/style.scss | 136 ++++++++++++++++++---------- 2 files changed, 90 insertions(+), 48 deletions(-) diff --git a/templates/releases/build_queue.html b/templates/releases/build_queue.html index 280b6fdac..497854398 100644 --- a/templates/releases/build_queue.html +++ b/templates/releases/build_queue.html @@ -84,7 +84,7 @@
    2. {%- endfor %} {%- else %} - There is nothing in the queue + There is nothing in the build queue {%- endif %}
    diff --git a/templates/style/style.scss b/templates/style/style.scss index 4a01e6bd7..3617dace9 100644 --- a/templates/style/style.scss +++ b/templates/style/style.scss @@ -7,18 +7,19 @@ font-style: normal; font-weight: 400; src: - local('Fira Sans'), - url("FiraSans-Regular.woff2") format('woff2'), - url("FiraSans-Regular.woff") format('woff'); + local('Fira Sans'), + url("FiraSans-Regular.woff2") format('woff2'), + url("FiraSans-Regular.woff") format('woff'); } + @font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 500; src: - local('Fira Sans Medium'), - url("FiraSans-Medium.woff2") format('woff2'), - url("FiraSans-Medium.woff") format('woff'); + local('Fira Sans Medium'), + url("FiraSans-Medium.woff2") format('woff2'), + url("FiraSans-Medium.woff") format('woff'); } /* See SourceSerif4-LICENSE.md for the Source Serif 4 license. */ @@ -27,27 +28,29 @@ font-style: normal; font-weight: 400; src: - local('Source Serif 4'), - url("SourceSerif4-Regular.ttf.woff2") format('woff2'), - url("SourceSerif4-Regular.ttf.woff") format('woff'); + local('Source Serif 4'), + url("SourceSerif4-Regular.ttf.woff2") format('woff2'), + url("SourceSerif4-Regular.ttf.woff") format('woff'); } + @font-face { font-family: 'Source Serif'; font-style: italic; font-weight: 400; src: - local('Source Serif 4'), - url("SourceSerif4-It.ttf.woff2") format('woff2'), - url("SourceSerif4-It.ttf.woff") format('woff'); + local('Source Serif 4'), + url("SourceSerif4-It.ttf.woff2") format('woff2'), + url("SourceSerif4-It.ttf.woff") format('woff'); } + @font-face { font-family: 'Source Serif'; font-style: normal; font-weight: 700; src: - local('Source Serif 4'), - url("SourceSerif4-Bold.ttf.woff2") format('woff2'), - url("SourceSerif4-Bold.ttf.woff") format('woff'); + local('Source Serif 4'), + url("SourceSerif4-Bold.ttf.woff2") format('woff2'), + url("SourceSerif4-Bold.ttf.woff") format('woff'); } /* See SourceCodePro-LICENSE.md for the Source Code Pro license. */ @@ -58,24 +61,26 @@ /* Avoid using locally installed font because bad versions are in circulation: * see https://github.com/rust-lang/rust/issues/24355 */ src: - url("SourceCodePro-Regular.ttf.woff2") format('woff2'), - url("SourceCodePro-Regular.ttf.woff") format('woff'); + url("SourceCodePro-Regular.ttf.woff2") format('woff2'), + url("SourceCodePro-Regular.ttf.woff") format('woff'); } + @font-face { font-family: 'Source Code Pro'; font-style: normal; font-weight: 600; src: - url("SourceCodePro-Semibold.ttf.woff2") format('woff2'), - url("SourceCodePro-Semibold.ttf.woff") format('woff'); + url("SourceCodePro-Semibold.ttf.woff2") format('woff2'), + url("SourceCodePro-Semibold.ttf.woff") format('woff'); } + @font-face { font-family: 'Source Code Pro'; font-style: italic; font-weight: 400; src: - url("SourceCodePro-It.ttf.woff2") format('woff2'), - url("SourceCodePro-It.ttf.woff") format('woff'); + url("SourceCodePro-It.ttf.woff2") format('woff2'), + url("SourceCodePro-It.ttf.woff") format('woff'); } html, @@ -102,7 +107,8 @@ body { padding: 0; margin: 0; position: relative; - min-height: 100vh; /* Tall enough to stick the footer to the bottom */ + min-height: 100vh; + /* Tall enough to stick the footer to the bottom */ * { -webkit-box-sizing: border-box; @@ -113,37 +119,55 @@ body { h1 { font-size: 1.5em; } + h3 { font-size: 1.3em; } - h1, h2, h3, h4 { - font-family: "Fira Sans",sans-serif; + + h1, + h2, + h3, + h4 { + font-family: "Fira Sans", sans-serif; font-weight: 500; margin: 20px 0 15px 0; padding-bottom: 6px; } - h2, h3, h4 { + + h2, + h3, + h4 { border-bottom: 1px solid; } + pre { background-color: var(--color-background-code); padding: 14px; } - code, kbd, pre, samp { - font-family: "Source Code Pro",monospace; + + code, + kbd, + pre, + samp { + font-family: "Source Code Pro", monospace; } + a { text-decoration: none; background: transparent; } + p { margin: 0 0 .6em 0; } - ol, ul { + + ol, + ul { padding-left: 25px; } - input, #search { + input, + #search { background-color: var(--color-background-input); color: var(--input-color); line-height: normal; @@ -177,7 +201,7 @@ body { background-color: var(--color-background); color: var(--color-standard); - > h1 { + >h1 { color: var(--color-standard); } @@ -186,15 +210,16 @@ body { fill: var(--color-background); } - text.highcharts-title, g.highcharts-axis-labels > text { + text.highcharts-title, + g.highcharts-axis-labels>text { fill: var(--chart-title-color) !important; } - g.highcharts-legend-item > text { + g.highcharts-legend-item>text { fill: var(--chart-grid) !important; } - g.highcharts-grid > path { + g.highcharts-grid>path { stroke: var(--chart-grid) !important; } } @@ -262,7 +287,8 @@ div.recent-releases-container { padding: 0; } - ol.queue-list li { + ol.queue-list li, + ol.rebuild-queue-list li { list-style-type: decimal; margin-left: 20px; @@ -280,7 +306,8 @@ div.recent-releases-container { background-color: var(--background-color); } - .release, .build-in-progress { + .release, + .build-in-progress { display: block; border-bottom: 1px solid var(--color-border); padding: 0.4em $search-result-right-left-padding; @@ -338,6 +365,7 @@ div.recent-releases-container { span.fa-check { color: var(--color-macro); } + span.fa-times { color: var(--color-struct); } @@ -384,10 +412,10 @@ div.recent-releases-container { } .yanked { - color: var(--color-warn-msg); - background-color: var(--color-warn-background); - padding: .2em .8em .2em .5em; - border-radius: 1em; + color: var(--color-warn-msg); + background-color: var(--color-warn-background); + padding: .2em .8em .2em .5em; + border-radius: 1em; } } @@ -399,6 +427,7 @@ div.package-container { margin: 0; padding: 20px 0 0 16px; } + p { margin: 0; padding: 0 0 20px 16px; @@ -469,7 +498,7 @@ div.package-page-container { margin: 20px 5px 15px 5px; } - li.pure-menu-item > .documented-info { + li.pure-menu-item>.documented-info { font-size: 13px; display: block; width: 100%; @@ -575,7 +604,7 @@ div.package-page-container { border-bottom: 1px solid var(--color-menu-border); } - tbody > tr:last-child > td { + tbody>tr:last-child>td { border-bottom-width: 0; } @@ -697,7 +726,7 @@ div.docsrs-package-container { border-radius: 2px; } - .pure-menu-has-children > .pure-menu-link:after { + .pure-menu-has-children>.pure-menu-link:after { font-size: 14px; } @@ -774,7 +803,12 @@ div.search-page-search-form { background-color: inherit; } - h1, h2, h3, h4, h5, h6 { + h1, + h2, + h3, + h4, + h5, + h6 { border-bottom-color: var(--color-border) !important; color: var(--color-standard) !important; } @@ -789,8 +823,8 @@ div.search-page-search-form { } /* Don't put a newline after code fragments in headers */ -h3 > code, -h4 > code { +h3>code, +h4>code { display: inline-block; } @@ -873,13 +907,17 @@ ul.pure-menu-list { max-width: 46px; ul { - li:not(.toggle-source), .text { + + li:not(.toggle-source), + .text { display: none; } + li.toggle-source { .left { display: none; } + .right { display: inline-block; margin-left: -4px; @@ -897,13 +935,16 @@ ul.pure-menu-list { display: inline-flex; overflow: scroll; } + #line-numbers { text-align: right; letter-spacing: normal; } -#line-numbers > code > a { + +#line-numbers>code>a { padding: 0 8px; } + // This class is used to the source code and the line number container in the // `crate/**/source/*` view .source-code { @@ -921,6 +962,7 @@ ul.pure-menu-list { width: calc(100% - 46px); } } + #source-code { overflow: scroll; width: 100%; From bcb44ad0d09d06f2856ee7af0a29e0f9818343d0 Mon Sep 17 00:00:00 2001 From: Zahid Kizmaz Date: Mon, 21 Oct 2024 22:42:24 +0200 Subject: [PATCH 4/9] chore: add margin to paragraphs in about classes in html This will align the text of the paragraphs with the rest of the items in the class. --- templates/style/style.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/style/style.scss b/templates/style/style.scss index 3617dace9..a2f930397 100644 --- a/templates/style/style.scss +++ b/templates/style/style.scss @@ -297,6 +297,10 @@ div.recent-releases-container { } } + .about p { + margin-left: 20px; + } + strong { font-weight: 500; } From ade785ab41eb1d3a32da12f782dafe63f17d4333 Mon Sep 17 00:00:00 2001 From: Zahid Kizmaz Date: Tue, 22 Oct 2024 08:56:54 +0200 Subject: [PATCH 5/9] chore: revert prettier changes --- templates/style/style.scss | 138 +++++++++++++------------------------ 1 file changed, 48 insertions(+), 90 deletions(-) diff --git a/templates/style/style.scss b/templates/style/style.scss index a2f930397..21832fff8 100644 --- a/templates/style/style.scss +++ b/templates/style/style.scss @@ -7,19 +7,18 @@ font-style: normal; font-weight: 400; src: - local('Fira Sans'), - url("FiraSans-Regular.woff2") format('woff2'), - url("FiraSans-Regular.woff") format('woff'); + local('Fira Sans'), + url("FiraSans-Regular.woff2") format('woff2'), + url("FiraSans-Regular.woff") format('woff'); } - @font-face { font-family: 'Fira Sans'; font-style: normal; font-weight: 500; src: - local('Fira Sans Medium'), - url("FiraSans-Medium.woff2") format('woff2'), - url("FiraSans-Medium.woff") format('woff'); + local('Fira Sans Medium'), + url("FiraSans-Medium.woff2") format('woff2'), + url("FiraSans-Medium.woff") format('woff'); } /* See SourceSerif4-LICENSE.md for the Source Serif 4 license. */ @@ -28,29 +27,27 @@ font-style: normal; font-weight: 400; src: - local('Source Serif 4'), - url("SourceSerif4-Regular.ttf.woff2") format('woff2'), - url("SourceSerif4-Regular.ttf.woff") format('woff'); + local('Source Serif 4'), + url("SourceSerif4-Regular.ttf.woff2") format('woff2'), + url("SourceSerif4-Regular.ttf.woff") format('woff'); } - @font-face { font-family: 'Source Serif'; font-style: italic; font-weight: 400; src: - local('Source Serif 4'), - url("SourceSerif4-It.ttf.woff2") format('woff2'), - url("SourceSerif4-It.ttf.woff") format('woff'); + local('Source Serif 4'), + url("SourceSerif4-It.ttf.woff2") format('woff2'), + url("SourceSerif4-It.ttf.woff") format('woff'); } - @font-face { font-family: 'Source Serif'; font-style: normal; font-weight: 700; src: - local('Source Serif 4'), - url("SourceSerif4-Bold.ttf.woff2") format('woff2'), - url("SourceSerif4-Bold.ttf.woff") format('woff'); + local('Source Serif 4'), + url("SourceSerif4-Bold.ttf.woff2") format('woff2'), + url("SourceSerif4-Bold.ttf.woff") format('woff'); } /* See SourceCodePro-LICENSE.md for the Source Code Pro license. */ @@ -61,26 +58,24 @@ /* Avoid using locally installed font because bad versions are in circulation: * see https://github.com/rust-lang/rust/issues/24355 */ src: - url("SourceCodePro-Regular.ttf.woff2") format('woff2'), - url("SourceCodePro-Regular.ttf.woff") format('woff'); + url("SourceCodePro-Regular.ttf.woff2") format('woff2'), + url("SourceCodePro-Regular.ttf.woff") format('woff'); } - @font-face { font-family: 'Source Code Pro'; font-style: normal; font-weight: 600; src: - url("SourceCodePro-Semibold.ttf.woff2") format('woff2'), - url("SourceCodePro-Semibold.ttf.woff") format('woff'); + url("SourceCodePro-Semibold.ttf.woff2") format('woff2'), + url("SourceCodePro-Semibold.ttf.woff") format('woff'); } - @font-face { font-family: 'Source Code Pro'; font-style: italic; font-weight: 400; src: - url("SourceCodePro-It.ttf.woff2") format('woff2'), - url("SourceCodePro-It.ttf.woff") format('woff'); + url("SourceCodePro-It.ttf.woff2") format('woff2'), + url("SourceCodePro-It.ttf.woff") format('woff'); } html, @@ -107,8 +102,7 @@ body { padding: 0; margin: 0; position: relative; - min-height: 100vh; - /* Tall enough to stick the footer to the bottom */ + min-height: 100vh; /* Tall enough to stick the footer to the bottom */ * { -webkit-box-sizing: border-box; @@ -119,55 +113,37 @@ body { h1 { font-size: 1.5em; } - h3 { font-size: 1.3em; } - - h1, - h2, - h3, - h4 { - font-family: "Fira Sans", sans-serif; + h1, h2, h3, h4 { + font-family: "Fira Sans",sans-serif; font-weight: 500; margin: 20px 0 15px 0; padding-bottom: 6px; } - - h2, - h3, - h4 { + h2, h3, h4 { border-bottom: 1px solid; } - pre { background-color: var(--color-background-code); padding: 14px; } - - code, - kbd, - pre, - samp { - font-family: "Source Code Pro", monospace; + code, kbd, pre, samp { + font-family: "Source Code Pro",monospace; } - a { text-decoration: none; background: transparent; } - p { margin: 0 0 .6em 0; } - - ol, - ul { + ol, ul { padding-left: 25px; } - input, - #search { + input, #search { background-color: var(--color-background-input); color: var(--input-color); line-height: normal; @@ -201,7 +177,7 @@ body { background-color: var(--color-background); color: var(--color-standard); - >h1 { + > h1 { color: var(--color-standard); } @@ -210,16 +186,15 @@ body { fill: var(--color-background); } - text.highcharts-title, - g.highcharts-axis-labels>text { + text.highcharts-title, g.highcharts-axis-labels > text { fill: var(--chart-title-color) !important; } - g.highcharts-legend-item>text { + g.highcharts-legend-item > text { fill: var(--chart-grid) !important; } - g.highcharts-grid>path { + g.highcharts-grid > path { stroke: var(--chart-grid) !important; } } @@ -287,8 +262,7 @@ div.recent-releases-container { padding: 0; } - ol.queue-list li, - ol.rebuild-queue-list li { + ol.queue-list li, ol.rebuild-queue-list li { list-style-type: decimal; margin-left: 20px; @@ -296,7 +270,7 @@ div.recent-releases-container { color: var(--color-url); } } - + .about p { margin-left: 20px; } @@ -310,8 +284,7 @@ div.recent-releases-container { background-color: var(--background-color); } - .release, - .build-in-progress { + .release, .build-in-progress { display: block; border-bottom: 1px solid var(--color-border); padding: 0.4em $search-result-right-left-padding; @@ -369,7 +342,6 @@ div.recent-releases-container { span.fa-check { color: var(--color-macro); } - span.fa-times { color: var(--color-struct); } @@ -416,10 +388,10 @@ div.recent-releases-container { } .yanked { - color: var(--color-warn-msg); - background-color: var(--color-warn-background); - padding: .2em .8em .2em .5em; - border-radius: 1em; + color: var(--color-warn-msg); + background-color: var(--color-warn-background); + padding: .2em .8em .2em .5em; + border-radius: 1em; } } @@ -431,7 +403,6 @@ div.package-container { margin: 0; padding: 20px 0 0 16px; } - p { margin: 0; padding: 0 0 20px 16px; @@ -502,7 +473,7 @@ div.package-page-container { margin: 20px 5px 15px 5px; } - li.pure-menu-item>.documented-info { + li.pure-menu-item > .documented-info { font-size: 13px; display: block; width: 100%; @@ -608,7 +579,7 @@ div.package-page-container { border-bottom: 1px solid var(--color-menu-border); } - tbody>tr:last-child>td { + tbody > tr:last-child > td { border-bottom-width: 0; } @@ -730,7 +701,7 @@ div.docsrs-package-container { border-radius: 2px; } - .pure-menu-has-children>.pure-menu-link:after { + .pure-menu-has-children > .pure-menu-link:after { font-size: 14px; } @@ -807,12 +778,7 @@ div.search-page-search-form { background-color: inherit; } - h1, - h2, - h3, - h4, - h5, - h6 { + h1, h2, h3, h4, h5, h6 { border-bottom-color: var(--color-border) !important; color: var(--color-standard) !important; } @@ -827,8 +793,8 @@ div.search-page-search-form { } /* Don't put a newline after code fragments in headers */ -h3>code, -h4>code { +h3 > code, +h4 > code { display: inline-block; } @@ -911,17 +877,13 @@ ul.pure-menu-list { max-width: 46px; ul { - - li:not(.toggle-source), - .text { + li:not(.toggle-source), .text { display: none; } - li.toggle-source { .left { display: none; } - .right { display: inline-block; margin-left: -4px; @@ -939,16 +901,13 @@ ul.pure-menu-list { display: inline-flex; overflow: scroll; } - #line-numbers { text-align: right; letter-spacing: normal; } - -#line-numbers>code>a { +#line-numbers > code > a { padding: 0 8px; } - // This class is used to the source code and the line number container in the // `crate/**/source/*` view .source-code { @@ -966,7 +925,6 @@ ul.pure-menu-list { width: calc(100% - 46px); } } - #source-code { overflow: scroll; width: 100%; From 40aecd298c9437aeff28f11088ff3e940ef096ab Mon Sep 17 00:00:00 2001 From: Zahid Kizmaz Date: Thu, 24 Oct 2024 00:27:42 +0200 Subject: [PATCH 6/9] fix: separate build and rebuild queue Crates can be in only one of the queues and cover this case with tests --- src/web/releases.rs | 52 +++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/src/web/releases.rs b/src/web/releases.rs index c546bf656..58c4c33fa 100644 --- a/src/web/releases.rs +++ b/src/web/releases.rs @@ -22,6 +22,7 @@ use axum::{ use base64::{engine::general_purpose::STANDARD as b64, Engine}; use chrono::{DateTime, Utc}; use futures_util::stream::TryStreamExt; +use itertools::Itertools; use once_cell::sync::Lazy; use rinja::Template; use serde::{Deserialize, Serialize}; @@ -832,7 +833,7 @@ pub(crate) async fn build_queue_handler( .collect(); let mut rebuild_queue = Vec::new(); - let queue: Vec = build_queue + let mut queue = build_queue .queued_crates() .await? .into_iter() @@ -842,19 +843,20 @@ pub(crate) async fn build_queue_handler( *name == krate.name && *version == krate.version }) }) - .map(|mut krate| { - if krate.priority >= REBUILD_PRIORITY { - rebuild_queue.push(krate.clone()); - } else { - // The priority here is inverted: in the database if a crate has a higher priority it - // will be built after everything else, which is counter-intuitive for people not - // familiar with docs.rs's inner workings. - krate.priority = -krate.priority; - } + .collect_vec(); - krate - }) - .collect(); + queue.retain_mut(|krate| { + if krate.priority >= REBUILD_PRIORITY { + rebuild_queue.push(krate.clone()); + false + } else { + // The priority here is inverted: in the database if a crate has a higher priority it + // will be built after everything else, which is counter-intuitive for people not + // familiar with docs.rs's inner workings. + krate.priority = -krate.priority; + true + } + }); Ok(BuildQueuePage { description: "crate documentation scheduled to build & deploy", @@ -1900,15 +1902,29 @@ mod tests { let full = kuchikiki::parse_html().one(web.get("/releases/queue?expand=1").send()?.text()?); - let items = full + let build_queue_list = full + .select(".queue-list > li") + .expect("missing list items") + .collect::>(); + let rebuild_queue_list = full .select(".rebuild-queue-list > li") .expect("missing list items") .collect::>(); - assert_eq!(items.len(), 2); - assert!(items.iter().any(|li| li.text_contents().contains("foo"))); - assert!(items.iter().any(|li| li.text_contents().contains("bar"))); - assert!(!items.iter().any(|li| li.text_contents().contains("baz"))); + assert_eq!(build_queue_list.len(), 1); + assert_eq!(rebuild_queue_list.len(), 2); + assert!(rebuild_queue_list + .iter() + .any(|li| li.text_contents().contains("foo"))); + assert!(rebuild_queue_list + .iter() + .any(|li| li.text_contents().contains("bar"))); + assert!(build_queue_list + .iter() + .any(|li| li.text_contents().contains("baz"))); + assert!(!rebuild_queue_list + .iter() + .any(|li| li.text_contents().contains("baz"))); Ok(()) }); From 1255468ea6593c17bf78f0c94f5f151abbd6c0ad Mon Sep 17 00:00:00 2001 From: Zahid Kizmaz Date: Thu, 24 Oct 2024 00:43:04 +0200 Subject: [PATCH 7/9] docs: add documentation to REBUILD_PRIORITY --- src/build_queue.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/build_queue.rs b/src/build_queue.rs index e427f132b..43e04ab3d 100644 --- a/src/build_queue.rs +++ b/src/build_queue.rs @@ -15,6 +15,8 @@ use std::sync::Arc; use tokio::runtime::Runtime; use tracing::{debug, error, info}; +// Threshold priority to decide whether a crate will in the rebuild-queue-list. +// If crate is in the rebuild-queue-list it won't in the build-queue-list. pub(crate) const REBUILD_PRIORITY: i32 = 20; #[derive(Debug, Clone, Eq, PartialEq, serde::Serialize)] From a8dd0091f58d7fa2d33f746ee12f240f71f6d8f4 Mon Sep 17 00:00:00 2001 From: Zahid Kizmaz Date: Thu, 24 Oct 2024 01:00:26 +0200 Subject: [PATCH 8/9] feat: use pluralize in order to have correct pluralization by the crate count --- templates/releases/build_queue.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/releases/build_queue.html b/templates/releases/build_queue.html index 497854398..406484a0c 100644 --- a/templates/releases/build_queue.html +++ b/templates/releases/build_queue.html @@ -98,7 +98,7 @@ benefit from new features in rustdoc.

    {%- if !expand_rebuild_queue -%} -

    There are currently {{ rebuild_queue.len() }} crates in the rebuild queue.

    +

    There are currently {{ rebuild_queue.len() }} crate{{ rebuild_queue.len()|pluralize }} in the rebuild queue.

    Show

    {%- endif -%} From 1139dac4d86841a38eabf5fe2a31654397f75577 Mon Sep 17 00:00:00 2001 From: Zahid Kizmaz Date: Thu, 24 Oct 2024 07:41:43 +0200 Subject: [PATCH 9/9] perf: do not call rebuild_queue.len() multiple times in the template --- templates/releases/build_queue.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/releases/build_queue.html b/templates/releases/build_queue.html index 406484a0c..9418affd4 100644 --- a/templates/releases/build_queue.html +++ b/templates/releases/build_queue.html @@ -98,7 +98,8 @@ benefit from new features in rustdoc.

    {%- if !expand_rebuild_queue -%} -

    There are currently {{ rebuild_queue.len() }} crate{{ rebuild_queue.len()|pluralize }} in the rebuild queue.

    + {% let rebuild_queue_len = rebuild_queue.len() %} +

    There are currently {{ rebuild_queue_len }} crate{{ rebuild_queue_len|pluralize }} in the rebuild queue.

    Show

    {%- endif -%}