diff --git a/src/cargo/ops/cargo_doc.rs b/src/cargo/ops/cargo_doc.rs index df394f5f0f0..7d13a6446f5 100644 --- a/src/cargo/ops/cargo_doc.rs +++ b/src/cargo/ops/cargo_doc.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; use std::fs; +use std::iter::FromIterator; use std::path::Path; use std::process::Command; @@ -65,6 +66,23 @@ pub fn doc(ws: &Workspace, options: &DocOptions) -> CargoResult<()> { } } + // Don't bother locking here as if this is getting deleted there's + // nothing we can do about it and otherwise if it's getting overwritten + // then that's also ok! + let mut target_dir = ws.clone().target_dir().clone(); + if let Some(ref triple) = options.compile_opts.build_config.requested_target { + target_dir.push(Path::new(triple).file_stem().unwrap()); + } + + let unit_names = Vec::from_iter(lib_names.keys().chain(bin_names.keys())); + for unit_name in &unit_names { + let path = target_dir.join("doc").join(&unit_name).join("index.html"); + // Duplicating shell here and not declaring it outside the loop to avoid + // a BorrowMutError + let mut shell = options.compile_opts.config.shell(); + shell.status("Generating", path.display())?; + } + ops::compile(ws, &options.compile_opts)?; if options.open_result { @@ -79,19 +97,9 @@ pub fn doc(ws: &Workspace, options: &DocOptions) -> CargoResult<()> { .join("\n ") ); } else { - match lib_names.keys().chain(bin_names.keys()).nth(0) { - Some(s) => s.to_string(), - None => return Ok(()), - } + unit_names[0].to_string() }; - // Don't bother locking here as if this is getting deleted there's - // nothing we can do about it and otherwise if it's getting overwritten - // then that's also ok! - let mut target_dir = ws.target_dir(); - if let Some(ref triple) = options.compile_opts.build_config.requested_target { - target_dir.push(Path::new(triple).file_stem().unwrap()); - } let path = target_dir.join("doc").join(&name).join("index.html"); let path = path.into_path_unlocked(); if fs::metadata(&path).is_ok() { diff --git a/tests/testsuite/cargotest/support/mod.rs b/tests/testsuite/cargotest/support/mod.rs index 677f90a316f..f2fc5673d2e 100644 --- a/tests/testsuite/cargotest/support/mod.rs +++ b/tests/testsuite/cargotest/support/mod.rs @@ -1174,6 +1174,7 @@ fn substitute_macros(input: &str) -> String { ("[REPLACING]", " Replacing"), ("[UNPACKING]", " Unpacking"), ("[SUMMARY]", " Summary"), + ("[GENERATING]", " Generating"), ("[EXE]", if cfg!(windows) { ".exe" } else { "" }), ("[/]", if cfg!(windows) { "\\" } else { "/" }), ]; diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index 415f26039eb..c59c16ffad8 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -36,6 +36,7 @@ fn simple() { p.cargo("doc"), execs().with_status(0).with_stderr(&format!( "\ +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html [..] foo v0.0.1 ({dir}) [..] foo v0.0.1 ({dir}) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] @@ -98,6 +99,7 @@ fn doc_twice() { p.cargo("doc"), execs().with_status(0).with_stderr(&format!( "\ +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html [DOCUMENTING] foo v0.0.1 ({dir}) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", @@ -151,6 +153,7 @@ fn doc_deps() { p.cargo("doc"), execs().with_status(0).with_stderr(&format!( "\ +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html [..] bar v0.0.1 ({dir}/bar) [..] bar v0.0.1 ({dir}/bar) [DOCUMENTING] foo v0.0.1 ({dir}) @@ -232,6 +235,7 @@ fn doc_no_deps() { p.cargo("doc").arg("--no-deps"), execs().with_status(0).with_stderr(&format!( "\ +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html [CHECKING] bar v0.0.1 ({dir}/bar) [DOCUMENTING] foo v0.0.1 ({dir}) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] @@ -505,6 +509,8 @@ fn doc_lib_bin_same_name_documents_lib() { p.cargo("doc"), execs().with_status(0).with_stderr(&format!( "\ +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html [DOCUMENTING] foo v0.0.1 ({dir}) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", @@ -558,6 +564,8 @@ fn doc_lib_bin_same_name_documents_lib_when_requested() { p.cargo("doc").arg("--lib"), execs().with_status(0).with_stderr(&format!( "\ +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html [DOCUMENTING] foo v0.0.1 ({dir}) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", @@ -611,6 +619,8 @@ fn doc_lib_bin_same_name_documents_named_bin_when_requested() { p.cargo("doc").arg("--bin").arg("foo"), execs().with_status(0).with_stderr(&format!( "\ +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html [CHECKING] foo v0.0.1 ({dir}) [DOCUMENTING] foo v0.0.1 ({dir}) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] @@ -665,6 +675,8 @@ fn doc_lib_bin_same_name_documents_bins_when_requested() { p.cargo("doc").arg("--bins"), execs().with_status(0).with_stderr(&format!( "\ +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html [CHECKING] foo v0.0.1 ({dir}) [DOCUMENTING] foo v0.0.1 ({dir}) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] @@ -729,6 +741,7 @@ fn doc_dash_p() { p.cargo("doc").arg("-p").arg("a"), execs().with_status(0).with_stderr( "\ +[GENERATING] [..][/]foo[/]target[/]doc[/]a[/]index.html [..] b v0.0.1 (file://[..]) [..] b v0.0.1 (file://[..]) [DOCUMENTING] a v0.0.1 (file://[..]) @@ -1001,6 +1014,7 @@ fn doc_release() { p.cargo("doc").arg("--release").arg("-v"), execs().with_status(0).with_stderr( "\ +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html [DOCUMENTING] foo v0.0.1 ([..]) [RUNNING] `rustdoc [..] src[/]lib.rs [..]` [FINISHED] release [optimized] target(s) in [..] diff --git a/tests/testsuite/profile_targets.rs b/tests/testsuite/profile_targets.rs index 8a8ba41160a..f4a63e536cd 100644 --- a/tests/testsuite/profile_targets.rs +++ b/tests/testsuite/profile_targets.rs @@ -689,6 +689,8 @@ fn profile_selection_doc() { // // `*` = wants panic, but it is cleared when args are built. assert_that(p.cargo("doc -vv"), execs().with_status(0).with_stderr_unordered("\ +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html [COMPILING] bar [..] [DOCUMENTING] bar [..] [RUNNING] `rustc --crate-name bar bar[/]src[/]lib.rs --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..] diff --git a/tests/testsuite/rustdoc.rs b/tests/testsuite/rustdoc.rs index 75a80835977..72ac0f1dd75 100644 --- a/tests/testsuite/rustdoc.rs +++ b/tests/testsuite/rustdoc.rs @@ -20,6 +20,7 @@ fn rustdoc_simple() { p.cargo("rustdoc").arg("-v"), execs().with_status(0).with_stderr(format!( "\ +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html [DOCUMENTING] foo v0.0.1 ({url}) [RUNNING] `rustdoc --crate-name foo src[/]lib.rs \ -o {dir}[/]target[/]doc \ @@ -51,6 +52,7 @@ fn rustdoc_args() { p.cargo("rustdoc").arg("-v").arg("--").arg("--cfg=foo"), execs().with_status(0).with_stderr(format!( "\ +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html [DOCUMENTING] foo v0.0.1 ({url}) [RUNNING] `rustdoc --crate-name foo src[/]lib.rs \ -o {dir}[/]target[/]doc \ @@ -109,6 +111,7 @@ fn rustdoc_foo_with_bar_dependency() { foo.cargo("rustdoc").arg("-v").arg("--").arg("--cfg=foo"), execs().with_status(0).with_stderr(format!( "\ +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html [CHECKING] bar v0.0.1 ([..]) [RUNNING] `rustc [..]bar[/]src[/]lib.rs [..]` [DOCUMENTING] foo v0.0.1 ({url}) @@ -177,6 +180,7 @@ fn rustdoc_only_bar_dependency() { .arg("--cfg=foo"), execs().with_status(0).with_stderr(format!( "\ +[GENERATING] [..][/]foo[/]target[/]doc[/]bar[/]index.html [DOCUMENTING] bar v0.0.1 ([..]) [RUNNING] `rustdoc --crate-name bar [..]bar[/]src[/]lib.rs \ -o {dir}[/]target[/]doc \ @@ -214,6 +218,8 @@ fn rustdoc_same_name_documents_lib() { p.cargo("rustdoc").arg("-v").arg("--").arg("--cfg=foo"), execs().with_status(0).with_stderr(format!( "\ +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html [DOCUMENTING] foo v0.0.1 ([..]) [RUNNING] `rustdoc --crate-name foo src[/]lib.rs \ -o {dir}[/]target[/]doc \ @@ -271,6 +277,7 @@ fn rustdoc_target() { assert_that( p.cargo("rustdoc --verbose --target x86_64-unknown-linux-gnu"), execs().with_status(0).with_stderr("\ +[GENERATING] [..][/]foo[/]target[/][..][/]doc[/]a[/]index.html [DOCUMENTING] a v0.0.1 ([..]) [RUNNING] `rustdoc --crate-name a src[/]lib.rs \ --target x86_64-unknown-linux-gnu \ diff --git a/tests/testsuite/rustdocflags.rs b/tests/testsuite/rustdocflags.rs index 3102d240896..220004b2271 100644 --- a/tests/testsuite/rustdocflags.rs +++ b/tests/testsuite/rustdocflags.rs @@ -105,6 +105,7 @@ fn rerun() { execs().with_status(0).with_stderr( "\ [DOCUMENTING] foo v0.0.1 ([..]) +[GENERATING] [..][/]foo[/]target[/]doc[/]foo[/]index.html [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", ),