]> git.lizzy.rs Git - rust.git/blobdiff - src/bootstrap/doc.rs
Rollup merge of #104656 - c410-f3r:moar-errors, r=petrochenkov
[rust.git] / src / bootstrap / doc.rs
index 218c7199731743222017c4858fe1bc1e4fe39fb5..3180a12c85be759984d013d5a5907127a4e0e373 100644 (file)
@@ -85,18 +85,6 @@ fn run(self, builder: &Builder<'_>) {
     StyleGuide, "src/doc/style-guide", "style-guide";
 );
 
-fn open(builder: &Builder<'_>, path: impl AsRef<Path>) {
-    if builder.config.dry_run || !builder.config.cmd.open() {
-        return;
-    }
-
-    let path = path.as_ref();
-    builder.info(&format!("Opening doc {}", path.display()));
-    if let Err(err) = opener::open(path) {
-        builder.info(&format!("{}\n", err));
-    }
-}
-
 // "library/std" -> ["library", "std"]
 //
 // Used for deciding whether a particular step is one requested by the user on
@@ -163,7 +151,7 @@ fn run(self, builder: &Builder<'_>) {
         let index = out.join("index.html");
         let rustbook = builder.tool_exe(Tool::Rustbook);
         let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
-        if builder.config.dry_run || up_to_date(&src, &index) && up_to_date(&rustbook, &index) {
+        if builder.config.dry_run() || up_to_date(&src, &index) && up_to_date(&rustbook, &index) {
             return;
         }
         builder.info(&format!("Rustbook ({}) - {}", target, name));
@@ -240,11 +228,9 @@ fn run(self, builder: &Builder<'_>) {
             invoke_rustdoc(builder, compiler, &shared_assets, target, path);
         }
 
-        if builder.was_invoked_explicitly::<Self>(Kind::Doc) {
-            let out = builder.doc_out(target);
-            let index = out.join("book").join("index.html");
-            open(builder, &index);
-        }
+        let out = builder.doc_out(target);
+        let index = out.join("book").join("index.html");
+        builder.maybe_open_in_browser::<Self>(index);
     }
 }
 
@@ -345,8 +331,8 @@ fn run(self, builder: &Builder<'_>) {
                 && up_to_date(&footer, &html)
                 && up_to_date(&favicon, &html)
                 && up_to_date(&full_toc, &html)
-                && (builder.config.dry_run || up_to_date(&version_info, &html))
-                && (builder.config.dry_run || up_to_date(&rustdoc, &html))
+                && (builder.config.dry_run() || up_to_date(&version_info, &html))
+                && (builder.config.dry_run() || up_to_date(&rustdoc, &html))
             {
                 continue;
             }
@@ -386,7 +372,7 @@ fn run(self, builder: &Builder<'_>) {
         // with no particular explicit doc requested (e.g. library/core).
         if builder.paths.is_empty() || builder.was_invoked_explicitly::<Self>(Kind::Doc) {
             let index = out.join("index.html");
-            open(builder, &index);
+            builder.open_in_browser(&index);
         }
     }
 }
@@ -416,11 +402,11 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
 
         let version_input = builder.src.join("src").join("doc").join("version_info.html.template");
         let version_info = out.join("version_info.html");
-        if !builder.config.dry_run && !up_to_date(&version_input, &version_info) {
+        if !builder.config.dry_run() && !up_to_date(&version_input, &version_info) {
             let info = t!(fs::read_to_string(&version_input))
                 .replace("VERSION", &builder.rust_release())
-                .replace("SHORT_HASH", builder.rust_info.sha_short().unwrap_or(""))
-                .replace("STAMP", builder.rust_info.sha().unwrap_or(""));
+                .replace("SHORT_HASH", builder.rust_info().sha_short().unwrap_or(""))
+                .replace("STAMP", builder.rust_info().sha().unwrap_or(""));
             t!(fs::write(&version_info, &info));
         }
 
@@ -520,7 +506,7 @@ fn run(self, builder: &Builder<'_>) {
         for requested_crate in requested_crates {
             if STD_PUBLIC_CRATES.iter().any(|k| *k == requested_crate.as_str()) {
                 let index = out.join(requested_crate).join("index.html");
-                open(builder, &index);
+                builder.open_in_browser(index);
             }
         }
     }
@@ -740,7 +726,7 @@ fn run(self, builder: &Builder<'_>) {
         // Let's open the first crate documentation page:
         if let Some(krate) = to_open {
             let index = out.join(krate).join("index.html");
-            open(builder, &index);
+            builder.open_in_browser(index);
         }
     }
 }
@@ -914,7 +900,7 @@ fn run(self, builder: &Builder<'_>) {
 }
 
 fn symlink_dir_force(config: &Config, src: &Path, dst: &Path) -> io::Result<()> {
-    if config.dry_run {
+    if config.dry_run() {
         return Ok(());
     }
     if let Ok(m) = fs::symlink_metadata(dst) {
@@ -979,7 +965,7 @@ fn run(self, builder: &Builder<'_>) {
         cmd.arg("--rustc");
         cmd.arg(&rustc);
         cmd.arg("--rustc-target").arg(&self.target.rustc_target_arg());
-        if builder.config.verbose() {
+        if builder.is_verbose() {
             cmd.arg("--verbose");
         }
         if self.validate {
@@ -1000,10 +986,9 @@ fn run(self, builder: &Builder<'_>) {
             name: INTERNER.intern_str("rustc"),
             src: INTERNER.intern_path(out_base),
         });
-        if builder.was_invoked_explicitly::<Self>(Kind::Doc) {
-            let out = builder.doc_out(self.target);
-            let index = out.join("rustc").join("index.html");
-            open(builder, &index);
-        }
+
+        let out = builder.doc_out(self.target);
+        let index = out.join("rustc").join("index.html");
+        builder.maybe_open_in_browser::<Self>(index);
     }
 }