Skip to content

Commit

Permalink
Auto merge of #2988 - lifthrasiir:doc-open-with-target, r=alexcrichton
Browse files Browse the repository at this point in the history
Make `cargo doc --open --target TARGET` work as expected.

Currently `cargo doc --open` opens `$TARGET/doc` unconditionally, but it is incorrect if the explicit target is specified.

The target directory should be same to what `Layout::new()` generates, and ideally it should use the same data source (it hadn't been so far), but I'm yet to find a good way to signal that. At least I'm pretty sure that `Compilation` is not a good position to put them (it assumes the bipartite "root"-"deps" separation which doesn't quite work in documentation).
  • Loading branch information
bors authored Aug 14, 2016
2 parents c205132 + 60afff0 commit a6e47ca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cargo/ops/cargo_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ pub fn doc(ws: &Workspace,
// 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 target_dir = ws.target_dir();
let mut target_dir = ws.target_dir();
if let Some(triple) = options.compile_opts.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() {
Expand Down

0 comments on commit a6e47ca

Please sign in to comment.