From 4788e8c34ac900f3595e7fe6070f0cf210851cf7 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:48:30 +0000 Subject: [PATCH 01/13] Add the library workspace to the suggested rust-analyzer config --- src/bootstrap/src/core/build_steps/setup.rs | 1 + src/etc/rust_analyzer_settings.json | 1 + 2 files changed, 2 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/setup.rs b/src/bootstrap/src/core/build_steps/setup.rs index f7b26712cabd6..eb7f29ee23d76 100644 --- a/src/bootstrap/src/core/build_steps/setup.rs +++ b/src/bootstrap/src/core/build_steps/setup.rs @@ -46,6 +46,7 @@ static SETTINGS_HASHES: &[&str] = &[ "47d227f424bf889b0d899b9cc992d5695e1b78c406e183cd78eafefbe5488923", "b526bd58d0262dd4dda2bff5bc5515b705fb668a46235ace3e057f807963a11a", "828666b021d837a33e78d870b56d34c88a5e2c85de58b693607ec574f0c27000", + "811fb3b063c739d261fd8590dd30242e117908f5a095d594fa04585daa18ec4d", ]; static RUST_ANALYZER_SETTINGS: &str = include_str!("../../../../etc/rust_analyzer_settings.json"); diff --git a/src/etc/rust_analyzer_settings.json b/src/etc/rust_analyzer_settings.json index d329fe997cd79..a20105f0ef378 100644 --- a/src/etc/rust_analyzer_settings.json +++ b/src/etc/rust_analyzer_settings.json @@ -10,6 +10,7 @@ ], "rust-analyzer.linkedProjects": [ "Cargo.toml", + "library/Cargo.toml", "src/tools/x/Cargo.toml", "src/bootstrap/Cargo.toml", "src/tools/rust-analyzer/Cargo.toml", From 86493d4a29b5e8da3738511d5ddcbe7bb84b1ceb Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 22 Sep 2024 17:06:00 +0200 Subject: [PATCH 02/13] Extend rustdoc template check to detect unneeded comments --- src/tools/tidy/src/rustdoc_templates.rs | 34 ++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/tools/tidy/src/rustdoc_templates.rs b/src/tools/tidy/src/rustdoc_templates.rs index 6c8530e6366f6..2173dbf7e746a 100644 --- a/src/tools/tidy/src/rustdoc_templates.rs +++ b/src/tools/tidy/src/rustdoc_templates.rs @@ -20,7 +20,39 @@ pub fn check(librustdoc_path: &Path, bad: &mut bool) { while let Some((pos, line)) = lines.next() { let line = line.trim(); - if TAGS.iter().any(|(_, tag)| line.ends_with(tag)) { + if let Some(need_next_line_check) = TAGS.iter().find_map(|(tag, end_tag)| { + // We first check if the line ends with a jinja tag. + if !line.ends_with(end_tag) { + return None; + // Then we check if this a comment tag. + } else if *tag != "{#" { + return Some(false); + // And finally we check if the comment is empty (ie, only there to strip + // extra whitespace characters). + } else if let Some(start_pos) = line.rfind(tag) { + Some(line[start_pos + 2..].trim() == "#}") + } else { + Some(false) + } + }) { + // All good, the line is ending is a jinja tag. But maybe this tag is useless + // if the next line starts with a jinja tag as well! + // + // However, only (empty) comment jinja tags are concerned about it. + if need_next_line_check + && lines.peek().is_some_and(|(_, next_line)| { + let next_line = next_line.trim_start(); + TAGS.iter().any(|(tag, _)| next_line.starts_with(tag)) + }) + { + // It seems like ending this line with a jinja tag is not needed after all. + tidy_error!( + bad, + "`{}` at line {}: unneeded `{{# #}}` tag at the end of the line", + path.path().display(), + pos + 1, + ); + } continue; } let Some(next_line) = lines.peek().map(|(_, next_line)| next_line.trim()) else { From 912e1ae023587d9b1aabe71412c4239d22ffb200 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 22 Sep 2024 17:06:19 +0200 Subject: [PATCH 03/13] Remove unneeded jinja comments in templates --- src/librustdoc/html/templates/item_info.html | 2 +- src/librustdoc/html/templates/page.html | 62 +++++++++---------- .../html/templates/short_item_info.html | 10 +-- src/librustdoc/html/templates/sidebar.html | 2 +- .../html/templates/type_layout.html | 20 +++--- 5 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/librustdoc/html/templates/item_info.html b/src/librustdoc/html/templates/item_info.html index 9e65ae95e15d2..9fee268622e81 100644 --- a/src/librustdoc/html/templates/item_info.html +++ b/src/librustdoc/html/templates/item_info.html @@ -1,7 +1,7 @@ {% if !items.is_empty() %} {% for item in items %} - {{item|safe}} {# #} + {{item|safe}} {% endfor %} {% endif %} diff --git a/src/librustdoc/html/templates/page.html b/src/librustdoc/html/templates/page.html index 65c4304e20207..a05d6ca831329 100644 --- a/src/librustdoc/html/templates/page.html +++ b/src/librustdoc/html/templates/page.html @@ -12,13 +12,13 @@ {# #} {# #} + href="{{static_root_path|safe}}{{files.rustdoc_css}}"> {% if !layout.default_settings.is_empty() %} {# #} + > {% endif %} {# #} - {# #} + {% if page.css_class.contains("crate") %} - {# #} + {% else if page.css_class == "src" %} {# #} - {# #} + {% else if !page.css_class.contains("mod") %} - {# #} + {% else if !page.css_class.contains("sys") %} - {# #} + {% endif %} - {# #} + {% if layout.scrape_examples_extension %} - {# #} + {% endif %} {# #} + {% if layout.css_file_extension.is_some() %} {# #} + href="{{page.root_path|safe}}theme{{page.resource_suffix}}.css"> {% endif %} {% if !layout.favicon.is_empty() %} - {# #} + {% else %} {# #} {# #} + href="{{static_root_path|safe}}{{files.rust_favicon_svg}}"> {% endif %} {{ layout.external_html.in_header|safe }} {# #} @@ -69,60 +69,60 @@
{# #} This old browser is unsupported and will most likely display funky things. {# #}
{# #} - {# #} + {{ layout.external_html.before_content|safe }} {% if page.css_class != "src" %} {% endif %} -