Document Cargo with in-tree rustdoc
This commit is contained in:
parent
79bdc62756
commit
b5f2a71f55
3 changed files with 62 additions and 23 deletions
|
|
@ -965,7 +965,7 @@ macro_rules! tool_doc {
|
|||
(
|
||||
$tool: ident,
|
||||
$path: literal,
|
||||
$(rustc_private_tool = $rustc_private_tool:literal, )?
|
||||
mode = $mode:expr,
|
||||
$(is_library = $is_library:expr,)?
|
||||
$(crates = $crates:expr)?
|
||||
) => {
|
||||
|
|
@ -988,20 +988,29 @@ macro_rules! tool_doc {
|
|||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
let target = run.target;
|
||||
let (build_compiler, mode) = if true $(&& $rustc_private_tool)? {
|
||||
// Rustdoc needs the rustc sysroot available to build.
|
||||
let compilers = RustcPrivateCompilers::new(run.builder, run.builder.top_stage, target);
|
||||
let build_compiler = match $mode {
|
||||
Mode::ToolRustcPrivate => {
|
||||
// Rustdoc needs the rustc sysroot available to build.
|
||||
let compilers = RustcPrivateCompilers::new(run.builder, run.builder.top_stage, target);
|
||||
|
||||
// Build rustc docs so that we generate relative links.
|
||||
run.builder.ensure(Rustc::from_build_compiler(run.builder, compilers.build_compiler(), target));
|
||||
|
||||
(compilers.build_compiler(), Mode::ToolRustcPrivate)
|
||||
} else {
|
||||
// bootstrap/host tools have to be documented with the stage 0 compiler
|
||||
(prepare_doc_compiler(run.builder, run.builder.host_target, 1), Mode::ToolBootstrap)
|
||||
// Build rustc docs so that we generate relative links.
|
||||
run.builder.ensure(Rustc::from_build_compiler(run.builder, compilers.build_compiler(), target));
|
||||
compilers.build_compiler()
|
||||
}
|
||||
Mode::ToolBootstrap => {
|
||||
// bootstrap/host tools should be documented with the stage 0 compiler
|
||||
prepare_doc_compiler(run.builder, run.builder.host_target, 1)
|
||||
}
|
||||
Mode::ToolTarget => {
|
||||
// target tools should be documented with the in-tree compiler
|
||||
prepare_doc_compiler(run.builder, run.builder.host_target, 2)
|
||||
}
|
||||
_ => {
|
||||
panic!("Unexpected tool mode for documenting: {:?}", $mode);
|
||||
}
|
||||
};
|
||||
|
||||
run.builder.ensure($tool { build_compiler, mode, target });
|
||||
run.builder.ensure($tool { build_compiler, mode: $mode, target });
|
||||
}
|
||||
|
||||
/// Generates documentation for a tool.
|
||||
|
|
@ -1087,18 +1096,33 @@ macro_rules! tool_doc {
|
|||
tool_doc!(
|
||||
BuildHelper,
|
||||
"src/build_helper",
|
||||
rustc_private_tool = false,
|
||||
mode = Mode::ToolBootstrap,
|
||||
is_library = true,
|
||||
crates = ["build_helper"]
|
||||
);
|
||||
tool_doc!(Rustdoc, "src/tools/rustdoc", crates = ["rustdoc", "rustdoc-json-types"]);
|
||||
tool_doc!(Rustfmt, "src/tools/rustfmt", crates = ["rustfmt-nightly", "rustfmt-config_proc_macro"]);
|
||||
tool_doc!(Clippy, "src/tools/clippy", crates = ["clippy_config", "clippy_utils"]);
|
||||
tool_doc!(Miri, "src/tools/miri", crates = ["miri"]);
|
||||
tool_doc!(
|
||||
Rustdoc,
|
||||
"src/tools/rustdoc",
|
||||
mode = Mode::ToolRustcPrivate,
|
||||
crates = ["rustdoc", "rustdoc-json-types"]
|
||||
);
|
||||
tool_doc!(
|
||||
Rustfmt,
|
||||
"src/tools/rustfmt",
|
||||
mode = Mode::ToolRustcPrivate,
|
||||
crates = ["rustfmt-nightly", "rustfmt-config_proc_macro"]
|
||||
);
|
||||
tool_doc!(
|
||||
Clippy,
|
||||
"src/tools/clippy",
|
||||
mode = Mode::ToolRustcPrivate,
|
||||
crates = ["clippy_config", "clippy_utils"]
|
||||
);
|
||||
tool_doc!(Miri, "src/tools/miri", mode = Mode::ToolRustcPrivate, crates = ["miri"]);
|
||||
tool_doc!(
|
||||
Cargo,
|
||||
"src/tools/cargo",
|
||||
rustc_private_tool = false,
|
||||
mode = Mode::ToolTarget,
|
||||
crates = [
|
||||
"cargo",
|
||||
"cargo-credential",
|
||||
|
|
@ -1112,25 +1136,25 @@ tool_doc!(
|
|||
"rustfix",
|
||||
]
|
||||
);
|
||||
tool_doc!(Tidy, "src/tools/tidy", rustc_private_tool = false, crates = ["tidy"]);
|
||||
tool_doc!(Tidy, "src/tools/tidy", mode = Mode::ToolBootstrap, crates = ["tidy"]);
|
||||
tool_doc!(
|
||||
Bootstrap,
|
||||
"src/bootstrap",
|
||||
rustc_private_tool = false,
|
||||
mode = Mode::ToolBootstrap,
|
||||
is_library = true,
|
||||
crates = ["bootstrap"]
|
||||
);
|
||||
tool_doc!(
|
||||
RunMakeSupport,
|
||||
"src/tools/run-make-support",
|
||||
rustc_private_tool = false,
|
||||
mode = Mode::ToolBootstrap,
|
||||
is_library = true,
|
||||
crates = ["run_make_support"]
|
||||
);
|
||||
tool_doc!(
|
||||
Compiletest,
|
||||
"src/tools/compiletest",
|
||||
rustc_private_tool = false,
|
||||
mode = Mode::ToolBootstrap,
|
||||
is_library = true,
|
||||
crates = ["compiletest"]
|
||||
);
|
||||
|
|
|
|||
|
|
@ -533,7 +533,7 @@ impl Builder<'_> {
|
|||
if cmd_kind == Kind::Doc {
|
||||
let my_out = match mode {
|
||||
// This is the intended out directory for compiler documentation.
|
||||
Mode::Rustc | Mode::ToolRustcPrivate | Mode::ToolBootstrap => {
|
||||
Mode::Rustc | Mode::ToolRustcPrivate | Mode::ToolBootstrap | Mode::ToolTarget => {
|
||||
self.compiler_doc_out(target)
|
||||
}
|
||||
Mode::Std => {
|
||||
|
|
|
|||
|
|
@ -2462,6 +2462,21 @@ mod snapshot {
|
|||
");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn doc_cargo() {
|
||||
let ctx = TestCtx::new();
|
||||
insta::assert_snapshot!(
|
||||
ctx.config("doc")
|
||||
.path("cargo")
|
||||
.render_steps(), @r"
|
||||
[build] llvm <host>
|
||||
[build] rustc 0 <host> -> rustc 1 <host>
|
||||
[build] rustc 1 <host> -> std 1 <host>
|
||||
[build] rustdoc 1 <host>
|
||||
[doc] rustc 1 <host> -> Cargo 2 <host>
|
||||
");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn doc_core() {
|
||||
let ctx = TestCtx::new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue