File tree Expand file tree Collapse file tree 2 files changed +8
-26
lines changed Expand file tree Collapse file tree 2 files changed +8
-26
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ pub fn doc(ws: &Workspace<'_>, options: &DocOptions<'_>) -> CargoResult<()> {
39
39
40
40
let mut lib_names = HashMap :: new ( ) ;
41
41
let mut bin_names = HashMap :: new ( ) ;
42
+ let mut names = Vec :: new ( ) ;
42
43
for package in & pkgs {
43
44
for target in package. targets ( ) . iter ( ) . filter ( |t| t. documented ( ) ) {
44
45
if target. is_lib ( ) {
@@ -62,27 +63,16 @@ pub fn doc(ws: &Workspace<'_>, options: &DocOptions<'_>) -> CargoResult<()> {
62
63
package
63
64
) ;
64
65
}
66
+ names. push ( target. crate_name ( ) ) ;
65
67
}
66
68
}
67
69
68
70
ops:: compile ( ws, & options. compile_opts ) ?;
69
71
70
72
if options. open_result {
71
- let name = if pkgs. len ( ) > 1 {
72
- failure:: bail!(
73
- "Passing multiple packages and `open` is not supported.\n \
74
- Please re-run this command with `-p <spec>` where `<spec>` \
75
- is one of the following:\n {}",
76
- pkgs. iter( )
77
- . map( |p| p. name( ) . as_str( ) )
78
- . collect:: <Vec <_>>( )
79
- . join( "\n " )
80
- ) ;
81
- } else {
82
- match lib_names. keys ( ) . chain ( bin_names. keys ( ) ) . nth ( 0 ) {
83
- Some ( s) => s. to_string ( ) ,
84
- None => return Ok ( ( ) ) ,
85
- }
73
+ let name = match names. first ( ) {
74
+ Some ( s) => s. to_string ( ) ,
75
+ None => return Ok ( ( ) ) ,
86
76
} ;
87
77
88
78
// Don't bother locking here as if this is getting deleted there's
Original file line number Diff line number Diff line change @@ -1012,6 +1012,7 @@ fn doc_all_member_dependency_same_name() {
1012
1012
}
1013
1013
1014
1014
#[ test]
1015
+ #[ cfg( not( any( target_os = "windows" , target_os = "macos" ) ) ) ]
1015
1016
fn doc_workspace_open_help_message ( ) {
1016
1017
let p = project ( )
1017
1018
. file (
@@ -1029,19 +1030,10 @@ fn doc_workspace_open_help_message() {
1029
1030
1030
1031
// The order in which bar is compiled or documented is not deterministic
1031
1032
p. cargo ( "doc --all --open" )
1032
- . with_status ( 101 )
1033
+ . env ( "BROWSER" , "echo" )
1033
1034
. with_stderr_contains ( "[..] Documenting bar v0.1.0 ([..])" )
1034
1035
. with_stderr_contains ( "[..] Documenting foo v0.1.0 ([..])" )
1035
- . with_stderr_contains (
1036
- "error: Passing multiple packages and `open` \
1037
- is not supported.",
1038
- )
1039
- . with_stderr_contains (
1040
- "Please re-run this command with `-p <spec>` \
1041
- where `<spec>` is one of the following:",
1042
- )
1043
- . with_stderr_contains ( " foo" )
1044
- . with_stderr_contains ( " bar" )
1036
+ . with_stderr_contains ( "[..] Opening [..]/foo/index.html" )
1045
1037
. run ( ) ;
1046
1038
}
1047
1039
You can’t perform that action at this time.
0 commit comments