bootstrap: ensure(doc::Std) no longer opens a browser

In general, the rationale for `--open` is to only open HTML files if
they were "explicitly" invoked from the CLI (e.g. `x doc --open
library/core`). The existing logic did not do that. Instead it opened
the docs unconditionally when a subset of the crates was requested. This
is unfortunate for other Steps in bootstrap, which may wish to `ensure()`
the standard library docs without opening them.

Change `Std` to check if it was explicitly invoked, rather than assuming
it's the case.
This commit is contained in:
Jynn Nelson 2025-10-28 13:04:02 -04:00
parent f5e2df741b
commit 706d600232

View file

@ -709,12 +709,12 @@ impl Step for Std {
if builder.paths.iter().any(|path| path.ends_with("library")) {
// For `x.py doc library --open`, open `std` by default.
let index = out.join("std").join("index.html");
builder.open_in_browser(index);
builder.maybe_open_in_browser::<Self>(index);
} else {
for requested_crate in crates {
if STD_PUBLIC_CRATES.iter().any(|&k| k == requested_crate) {
let index = out.join(requested_crate).join("index.html");
builder.open_in_browser(index);
builder.maybe_open_in_browser::<Self>(index);
break;
}
}