mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Add back support for BROWSER
envvar in cargo doc --open
.
Fixes #6064. Fixes #5965.
This commit is contained in:
parent
0c0f9aeccf
commit
23a2efe7fb
@ -1,10 +1,13 @@
|
||||
use crate::core::resolver::ResolveOpts;
|
||||
use crate::core::Workspace;
|
||||
use crate::core::{Shell, Workspace};
|
||||
use crate::ops;
|
||||
use crate::util::CargoResult;
|
||||
use failure::Fail;
|
||||
use opener;
|
||||
use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
/// Strongly typed options for the `cargo doc` command.
|
||||
#[derive(Debug)]
|
||||
@ -77,6 +80,25 @@ pub fn doc(ws: &Workspace<'_>, options: &DocOptions<'_>) -> CargoResult<()> {
|
||||
if path.exists() {
|
||||
let mut shell = options.compile_opts.config.shell();
|
||||
shell.status("Opening", path.display())?;
|
||||
open_docs(&path, &mut shell)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn open_docs(path: &Path, shell: &mut Shell) -> CargoResult<()> {
|
||||
match std::env::var_os("BROWSER") {
|
||||
Some(browser) => {
|
||||
if let Err(e) = Command::new(&browser).arg(path).status() {
|
||||
shell.warn(format!(
|
||||
"Couldn't open docs with {}: {}",
|
||||
browser.to_string_lossy(),
|
||||
e.description()
|
||||
))?;
|
||||
}
|
||||
}
|
||||
None => {
|
||||
if let Err(e) = opener::open(&path) {
|
||||
shell.warn(format!("Couldn't open docs: {}", e))?;
|
||||
for cause in (&e as &dyn Fail).iter_chain() {
|
||||
@ -84,7 +106,7 @@ pub fn doc(ws: &Workspace<'_>, options: &DocOptions<'_>) -> CargoResult<()> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -21,7 +21,9 @@ is placed in `target/doc` in rustdoc's usual format.
|
||||
=== Documentation Options
|
||||
|
||||
*--open*::
|
||||
Open the docs in a browser after building them.
|
||||
Open the docs in a browser after building them. This will use your default
|
||||
browser unless you define another one in the `BROWSER` environment
|
||||
variable.
|
||||
|
||||
*--no-deps*::
|
||||
Do not build documentation for dependencies.
|
||||
|
@ -33,7 +33,9 @@ option.
|
||||
=== Documentation Options
|
||||
|
||||
*--open*::
|
||||
Open the docs in a browser after building them.
|
||||
Open the docs in a browser after building them. This will use your default
|
||||
browser unless you define another one in the `BROWSER` environment
|
||||
variable.
|
||||
|
||||
=== Package Selection
|
||||
|
||||
|
@ -28,7 +28,9 @@ is placed in <code>target/doc</code> in rustdoc’s usual format.</p>
|
||||
<dl>
|
||||
<dt class="hdlist1"><strong>--open</strong></dt>
|
||||
<dd>
|
||||
<p>Open the docs in a browser after building them.</p>
|
||||
<p>Open the docs in a browser after building them. This will use your default
|
||||
browser unless you define another one in the <code>BROWSER</code> environment
|
||||
variable.</p>
|
||||
</dd>
|
||||
<dt class="hdlist1"><strong>--no-deps</strong></dt>
|
||||
<dd>
|
||||
|
@ -45,7 +45,9 @@ option.</p>
|
||||
<dl>
|
||||
<dt class="hdlist1"><strong>--open</strong></dt>
|
||||
<dd>
|
||||
<p>Open the docs in a browser after building them.</p>
|
||||
<p>Open the docs in a browser after building them. This will use your default
|
||||
browser unless you define another one in the <code>BROWSER</code> environment
|
||||
variable.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
@ -2,12 +2,12 @@
|
||||
.\" Title: cargo-doc
|
||||
.\" Author: [see the "AUTHOR(S)" section]
|
||||
.\" Generator: Asciidoctor 2.0.10
|
||||
.\" Date: 2019-09-05
|
||||
.\" Date: 2019-11-11
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "CARGO\-DOC" "1" "2019-09-05" "\ \&" "\ \&"
|
||||
.TH "CARGO\-DOC" "1" "2019-11-11" "\ \&" "\ \&"
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.ss \n[.ss] 0
|
||||
@ -41,7 +41,9 @@ is placed in \fBtarget/doc\fP in rustdoc\(cqs usual format.
|
||||
.sp
|
||||
\fB\-\-open\fP
|
||||
.RS 4
|
||||
Open the docs in a browser after building them.
|
||||
Open the docs in a browser after building them. This will use your default
|
||||
browser unless you define another one in the \fBBROWSER\fP environment
|
||||
variable.
|
||||
.RE
|
||||
.sp
|
||||
\fB\-\-no\-deps\fP
|
||||
|
@ -1,13 +1,13 @@
|
||||
'\" t
|
||||
.\" Title: cargo-help
|
||||
.\" Author: [see the "AUTHOR(S)" section]
|
||||
.\" Generator: Asciidoctor 2.0.8
|
||||
.\" Date: 2019-06-07
|
||||
.\" Generator: Asciidoctor 2.0.10
|
||||
.\" Date: 2019-06-03
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "CARGO\-HELP" "1" "2019-06-07" "\ \&" "\ \&"
|
||||
.TH "CARGO\-HELP" "1" "2019-06-03" "\ \&" "\ \&"
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.ss \n[.ss] 0
|
||||
|
@ -1,13 +1,13 @@
|
||||
'\" t
|
||||
.\" Title: cargo-init
|
||||
.\" Author: [see the "AUTHOR(S)" section]
|
||||
.\" Generator: Asciidoctor 2.0.8
|
||||
.\" Date: 2019-06-07
|
||||
.\" Generator: Asciidoctor 2.0.10
|
||||
.\" Date: 2019-06-03
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "CARGO\-INIT" "1" "2019-06-07" "\ \&" "\ \&"
|
||||
.TH "CARGO\-INIT" "1" "2019-06-03" "\ \&" "\ \&"
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.ss \n[.ss] 0
|
||||
|
@ -1,13 +1,13 @@
|
||||
'\" t
|
||||
.\" Title: cargo-install
|
||||
.\" Author: [see the "AUTHOR(S)" section]
|
||||
.\" Generator: Asciidoctor 2.0.8
|
||||
.\" Date: 2019-07-15
|
||||
.\" Generator: Asciidoctor 2.0.10
|
||||
.\" Date: 2019-10-09
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "CARGO\-INSTALL" "1" "2019-07-15" "\ \&" "\ \&"
|
||||
.TH "CARGO\-INSTALL" "1" "2019-10-09" "\ \&" "\ \&"
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.ss \n[.ss] 0
|
||||
|
@ -1,13 +1,13 @@
|
||||
'\" t
|
||||
.\" Title: cargo-login
|
||||
.\" Author: [see the "AUTHOR(S)" section]
|
||||
.\" Generator: Asciidoctor 2.0.8
|
||||
.\" Date: 2019-06-07
|
||||
.\" Generator: Asciidoctor 2.0.10
|
||||
.\" Date: 2019-06-03
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "CARGO\-LOGIN" "1" "2019-06-07" "\ \&" "\ \&"
|
||||
.TH "CARGO\-LOGIN" "1" "2019-06-03" "\ \&" "\ \&"
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.ss \n[.ss] 0
|
||||
|
@ -1,13 +1,13 @@
|
||||
'\" t
|
||||
.\" Title: cargo-new
|
||||
.\" Author: [see the "AUTHOR(S)" section]
|
||||
.\" Generator: Asciidoctor 2.0.8
|
||||
.\" Date: 2019-06-07
|
||||
.\" Generator: Asciidoctor 2.0.10
|
||||
.\" Date: 2019-06-03
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "CARGO\-NEW" "1" "2019-06-07" "\ \&" "\ \&"
|
||||
.TH "CARGO\-NEW" "1" "2019-06-03" "\ \&" "\ \&"
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.ss \n[.ss] 0
|
||||
|
@ -1,13 +1,13 @@
|
||||
'\" t
|
||||
.\" Title: cargo-owner
|
||||
.\" Author: [see the "AUTHOR(S)" section]
|
||||
.\" Generator: Asciidoctor 2.0.8
|
||||
.\" Date: 2019-06-07
|
||||
.\" Generator: Asciidoctor 2.0.10
|
||||
.\" Date: 2019-06-03
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "CARGO\-OWNER" "1" "2019-06-07" "\ \&" "\ \&"
|
||||
.TH "CARGO\-OWNER" "1" "2019-06-03" "\ \&" "\ \&"
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.ss \n[.ss] 0
|
||||
|
@ -2,12 +2,12 @@
|
||||
.\" Title: cargo-rustdoc
|
||||
.\" Author: [see the "AUTHOR(S)" section]
|
||||
.\" Generator: Asciidoctor 2.0.10
|
||||
.\" Date: 2019-09-05
|
||||
.\" Date: 2019-11-11
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "CARGO\-RUSTDOC" "1" "2019-09-05" "\ \&" "\ \&"
|
||||
.TH "CARGO\-RUSTDOC" "1" "2019-11-11" "\ \&" "\ \&"
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.ss \n[.ss] 0
|
||||
@ -58,7 +58,9 @@ option.
|
||||
.sp
|
||||
\fB\-\-open\fP
|
||||
.RS 4
|
||||
Open the docs in a browser after building them.
|
||||
Open the docs in a browser after building them. This will use your default
|
||||
browser unless you define another one in the \fBBROWSER\fP environment
|
||||
variable.
|
||||
.RE
|
||||
.SS "Package Selection"
|
||||
.sp
|
||||
|
@ -1,13 +1,13 @@
|
||||
'\" t
|
||||
.\" Title: cargo-search
|
||||
.\" Author: [see the "AUTHOR(S)" section]
|
||||
.\" Generator: Asciidoctor 2.0.8
|
||||
.\" Date: 2019-06-07
|
||||
.\" Generator: Asciidoctor 2.0.10
|
||||
.\" Date: 2019-06-03
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "CARGO\-SEARCH" "1" "2019-06-07" "\ \&" "\ \&"
|
||||
.TH "CARGO\-SEARCH" "1" "2019-06-03" "\ \&" "\ \&"
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.ss \n[.ss] 0
|
||||
|
@ -1,13 +1,13 @@
|
||||
'\" t
|
||||
.\" Title: cargo-uninstall
|
||||
.\" Author: [see the "AUTHOR(S)" section]
|
||||
.\" Generator: Asciidoctor 2.0.8
|
||||
.\" Date: 2019-06-07
|
||||
.\" Generator: Asciidoctor 2.0.10
|
||||
.\" Date: 2019-06-03
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "CARGO\-UNINSTALL" "1" "2019-06-07" "\ \&" "\ \&"
|
||||
.TH "CARGO\-UNINSTALL" "1" "2019-06-03" "\ \&" "\ \&"
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.ss \n[.ss] 0
|
||||
|
@ -1,13 +1,13 @@
|
||||
'\" t
|
||||
.\" Title: cargo-version
|
||||
.\" Author: [see the "AUTHOR(S)" section]
|
||||
.\" Generator: Asciidoctor 2.0.8
|
||||
.\" Date: 2019-06-07
|
||||
.\" Generator: Asciidoctor 2.0.10
|
||||
.\" Date: 2019-06-03
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "CARGO\-VERSION" "1" "2019-06-07" "\ \&" "\ \&"
|
||||
.TH "CARGO\-VERSION" "1" "2019-06-03" "\ \&" "\ \&"
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.ss \n[.ss] 0
|
||||
|
@ -1,13 +1,13 @@
|
||||
'\" t
|
||||
.\" Title: cargo-yank
|
||||
.\" Author: [see the "AUTHOR(S)" section]
|
||||
.\" Generator: Asciidoctor 2.0.8
|
||||
.\" Date: 2019-06-07
|
||||
.\" Generator: Asciidoctor 2.0.10
|
||||
.\" Date: 2019-06-03
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "CARGO\-YANK" "1" "2019-06-07" "\ \&" "\ \&"
|
||||
.TH "CARGO\-YANK" "1" "2019-06-03" "\ \&" "\ \&"
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.ss \n[.ss] 0
|
||||
|
@ -2,12 +2,12 @@
|
||||
.\" Title: cargo
|
||||
.\" Author: [see the "AUTHOR(S)" section]
|
||||
.\" Generator: Asciidoctor 2.0.10
|
||||
.\" Date: 2019-09-05
|
||||
.\" Date: 2019-10-09
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "CARGO" "1" "2019-09-05" "\ \&" "\ \&"
|
||||
.TH "CARGO" "1" "2019-10-09" "\ \&" "\ \&"
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.ss \n[.ss] 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user