Skip to content

Commit f851f97

Browse files
Rollup merge of #85185 - GuillaumeGomez:generate-not-more-docs-than-necessary, r=Mark-Simulacrum
Generate not more docs than necessary This is something that `@Nemo157` was talking about: they wanted that when using `x.py doc std`, it only generated `std` (and the crates "before" it). r? `@Mark-Simulacrum`
2 parents 62b834f + b9b67b7 commit f851f97

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

src/bootstrap/doc.rs

+22-9
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,22 @@ impl Step for Std {
451451

452452
builder.run(&mut cargo.into());
453453
};
454+
455+
let paths = builder
456+
.paths
457+
.iter()
458+
.map(components_simplified)
459+
.filter_map(|path| {
460+
if path.get(0) == Some(&"library") {
461+
Some(path[1].to_owned())
462+
} else if !path.is_empty() {
463+
Some(path[0].to_owned())
464+
} else {
465+
None
466+
}
467+
})
468+
.collect::<Vec<_>>();
469+
454470
// Only build the following crates. While we could just iterate over the
455471
// folder structure, that would also build internal crates that we do
456472
// not want to show in documentation. These crates will later be visited
@@ -464,20 +480,17 @@ impl Step for Std {
464480
let krates = ["core", "alloc", "std", "proc_macro", "test"];
465481
for krate in &krates {
466482
run_cargo_rustdoc_for(krate);
483+
if paths.iter().any(|p| p == krate) {
484+
// No need to document more of the libraries if we have the one we want.
485+
break;
486+
}
467487
}
468488
builder.cp_r(&out_dir, &out);
469489

470490
// Look for library/std, library/core etc in the `x.py doc` arguments and
471491
// open the corresponding rendered docs.
472-
for path in builder.paths.iter().map(components_simplified) {
473-
let requested_crate = if path.get(0) == Some(&"library") {
474-
&path[1]
475-
} else if !path.is_empty() {
476-
&path[0]
477-
} else {
478-
continue;
479-
};
480-
if krates.contains(&requested_crate) {
492+
for requested_crate in paths {
493+
if krates.iter().any(|k| *k == requested_crate.as_str()) {
481494
let index = out.join(requested_crate).join("index.html");
482495
open(builder, &index);
483496
}

src/ci/docker/host-x86_64/mingw-check/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ENV SCRIPT python3 ../x.py --stage 2 test src/tools/expand-yaml-anchors && \
3434
python3 ../x.py build --stage 0 src/tools/build-manifest && \
3535
python3 ../x.py test --stage 0 src/tools/compiletest && \
3636
python3 ../x.py test --stage 2 src/tools/tidy && \
37-
python3 ../x.py doc --stage 0 library/std && \
37+
python3 ../x.py doc --stage 0 library/test && \
3838
/scripts/validate-toolstate.sh && \
3939
# Runs checks to ensure that there are no ES5 issues in our JS code.
4040
es-check es5 ../src/librustdoc/html/static/*.js

0 commit comments

Comments
 (0)