Skip to content

Commit 8334419

Browse files
committed
Use local links in the alloc docs.
1 parent 23744c8 commit 8334419

File tree

3 files changed

+17
-32
lines changed

3 files changed

+17
-32
lines changed

src/bootstrap/builder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,8 @@ impl<'a> Builder<'a> {
773773
let my_out = match mode {
774774
// This is the intended out directory for compiler documentation.
775775
Mode::Rustc | Mode::ToolRustc | Mode::Codegen => self.compiler_doc_out(target),
776-
_ => self.crate_doc_out(target),
776+
Mode::Std => out_dir.join(target).join("doc"),
777+
_ => panic!("doc mode {:?} not expected", mode),
777778
};
778779
let rustdoc = self.rustdoc(compiler);
779780
self.clear_if_dirty(&my_out, &rustdoc);

src/bootstrap/doc.rs

+15-24
Original file line numberDiff line numberDiff line change
@@ -417,34 +417,16 @@ impl Step for Std {
417417
builder.ensure(compile::Std { compiler, target });
418418
let out_dir = builder.stage_out(compiler, Mode::Std).join(target).join("doc");
419419

420-
// Here what we're doing is creating a *symlink* (directory junction on
421-
// Windows) to the final output location. This is not done as an
422-
// optimization but rather for correctness. We've got three trees of
423-
// documentation, one for std, one for test, and one for rustc. It's then
424-
// our job to merge them all together.
425-
//
426-
// Unfortunately rustbuild doesn't know nearly as well how to merge doc
427-
// trees as rustdoc does itself, so instead of actually having three
428-
// separate trees we just have rustdoc output to the same location across
429-
// all of them.
430-
//
431-
// This way rustdoc generates output directly into the output, and rustdoc
432-
// will also directly handle merging.
433-
let my_out = builder.crate_doc_out(target);
434-
t!(symlink_dir_force(&builder.config, &my_out, &out_dir));
435420
t!(fs::copy(builder.src.join("src/doc/rust.css"), out.join("rust.css")));
436421

437422
let run_cargo_rustdoc_for = |package: &str| {
438423
let mut cargo =
439424
builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "rustdoc");
440425
compile::std_cargo(builder, target, compiler.stage, &mut cargo);
441426

442-
cargo.arg("-p").arg(package);
443-
// Create all crate output directories first to make sure rustdoc uses
444-
// relative links.
445-
// FIXME: Cargo should probably do this itself.
446-
t!(fs::create_dir_all(out_dir.join(package)));
447427
cargo
428+
.arg("-p")
429+
.arg(package)
448430
.arg("--")
449431
.arg("--markdown-css")
450432
.arg("rust.css")
@@ -462,11 +444,17 @@ impl Step for Std {
462444
// folder structure, that would also build internal crates that we do
463445
// not want to show in documentation. These crates will later be visited
464446
// by the rustc step, so internal documentation will show them.
465-
let krates = ["alloc", "core", "std", "proc_macro", "test"];
447+
//
448+
// Note that the order here is important! The crates need to be
449+
// processed starting from the leaves, otherwise rustdoc will not
450+
// create correct links between crates because rustdoc depends on the
451+
// existence of the output directories to know if it should be a local
452+
// or remote link.
453+
let krates = ["core", "alloc", "std", "proc_macro", "test"];
466454
for krate in &krates {
467455
run_cargo_rustdoc_for(krate);
468456
}
469-
builder.cp_r(&my_out, &out);
457+
builder.cp_r(&out_dir, &out);
470458

471459
// Look for src/libstd, src/libcore etc in the `x.py doc` arguments and
472460
// open the corresponding rendered docs.
@@ -529,8 +517,11 @@ impl Step for Rustc {
529517
// Build rustc.
530518
builder.ensure(compile::Rustc { compiler, target });
531519

532-
// We do not symlink to the same shared folder that already contains std library
533-
// documentation from previous steps as we do not want to include that.
520+
// This uses a shared directory so that librustdoc documentation gets
521+
// correctly built and merged with the rustc documentation. This is
522+
// needed because rustdoc is built in a different directory from
523+
// rustc. rustdoc needs to be able to see everything, for example when
524+
// merging the search index, or generating local (relative) links.
534525
let out_dir = builder.stage_out(compiler, Mode::Rustc).join(target).join("doc");
535526
t!(symlink_dir_force(&builder.config, &out, &out_dir));
536527

src/bootstrap/lib.rs

-7
Original file line numberDiff line numberDiff line change
@@ -612,13 +612,6 @@ impl Build {
612612
INTERNER.intern_path(self.out.join(&*target).join("md-doc"))
613613
}
614614

615-
/// Output directory for all crate documentation for a target (temporary)
616-
///
617-
/// The artifacts here are then copied into `doc_out` above.
618-
fn crate_doc_out(&self, target: Interned<String>) -> PathBuf {
619-
self.out.join(&*target).join("crate-docs")
620-
}
621-
622615
/// Returns `true` if no custom `llvm-config` is set for the specified target.
623616
///
624617
/// If no custom `llvm-config` was specified then Rust's llvm will be used.

0 commit comments

Comments
 (0)