d-bootstrap-use-local-css
authorDebian Rust Maintainers <pkg-rust-maintainers@alioth-lists.debian.net>
Thu, 14 Jul 2022 11:17:39 +0000 (13:17 +0200)
committerFabian Grünbichler <debian@fabian.gruenbichler.email>
Sat, 30 Dec 2023 13:52:00 +0000 (14:52 +0100)
===================================================================

Gbp-Pq: Name d-bootstrap-use-local-css.patch

src/bootstrap/doc.rs

index 3c6ac96790cb140c67f4ae5c7a6bfab45e123ba5..bf34a126950167361c6d2e939cbfb46d02ec5c6e 100644 (file)
@@ -359,7 +359,27 @@ impl Step for Standalone {
                 .arg("--index-page")
                 .arg(&builder.src.join("src/doc/index.md"))
                 .arg("--markdown-playground-url")
-                .arg("https://play.rust-lang.org/")
+                .arg("https://play.rust-lang.org/");
+
+            // Debian: librustdoc now generates a resource-suffix for static
+            // files with rustc_hash::FxHasher, so we need to find it.
+            let _dir = out.join("static.files");
+            if _dir.is_dir() {
+                let _css = _dir.read_dir().expect("Debian: failed to read static.files/ when is_dir() == true")
+                    .find_map(|entry| entry.ok().map(|entry| {
+                        let name = entry.file_name().into_string()
+                            .expect("Debian: rustc files should have UTF-8 name");
+                        if name.starts_with("rustdoc-") && name.ends_with(".css") {
+                            Some(name)
+                        } else { None }
+                    })).flatten();
+                if let Some(name) = _css {
+                    cmd.arg("--markdown-css").arg(name);
+                }
+            }
+
+            cmd.arg("--markdown-css")
+                .arg("rust.css")
                 .arg("-o")
                 .arg(&out)
                 .arg(&path);
@@ -368,11 +388,6 @@ impl Step for Standalone {
                 cmd.arg("--disable-minification");
             }
 
-            if filename == "not_found.md" {
-                cmd.arg("--markdown-css").arg("https://doc.rust-lang.org/rust.css");
-            } else {
-                cmd.arg("--markdown-css").arg("rust.css");
-            }
             builder.run(&mut cmd);
         }