@@ -66,6 +66,9 @@ pub struct CompileOptions<'a> {
66
66
pub target_rustc_args : Option < Vec < String > > ,
67
67
/// Extra arguments passed to all selected targets for rustdoc.
68
68
pub local_rustdoc_args : Option < Vec < String > > ,
69
+ /// Whether the `--document-private-items` flags was specified and should
70
+ /// be forwarded to `rustdoc`.
71
+ pub rustdoc_document_private_items : bool ,
69
72
/// The directory to copy final artifacts to. Note that even if `out_dir` is
70
73
/// set, a copy of artifacts still could be found a `target/(debug\release)`
71
74
/// as usual.
@@ -89,6 +92,7 @@ impl<'a> CompileOptions<'a> {
89
92
target_rustdoc_args : None ,
90
93
target_rustc_args : None ,
91
94
local_rustdoc_args : None ,
95
+ rustdoc_document_private_items : false ,
92
96
export_dir : None ,
93
97
} )
94
98
}
@@ -271,6 +275,7 @@ pub fn compile_ws<'a>(
271
275
ref target_rustdoc_args,
272
276
ref target_rustc_args,
273
277
ref local_rustdoc_args,
278
+ rustdoc_document_private_items,
274
279
ref export_dir,
275
280
} = * options;
276
281
@@ -434,9 +439,20 @@ pub fn compile_ws<'a>(
434
439
}
435
440
bcx. extra_compiler_args . insert ( units[ 0 ] , args) ;
436
441
}
437
- if let Some ( args) = local_rustdoc_args {
438
- for unit in & units {
439
- if unit. mode . is_doc ( ) || unit. mode . is_doc_test ( ) {
442
+ for unit in & units {
443
+ if unit. mode . is_doc ( ) || unit. mode . is_doc_test ( ) {
444
+ let mut extra_args = local_rustdoc_args. clone ( ) ;
445
+
446
+ // Add `--document-private-items` rustdoc flag if requested or if
447
+ // the target is a binary. Binary crates get their private items
448
+ // documented by default.
449
+ if rustdoc_document_private_items || unit. target . is_bin ( ) {
450
+ let mut args = extra_args. take ( ) . unwrap_or ( vec ! [ ] ) ;
451
+ args. push ( "--document-private-items" . into ( ) ) ;
452
+ extra_args = Some ( args) ;
453
+ }
454
+
455
+ if let Some ( args) = extra_args {
440
456
bcx. extra_compiler_args . insert ( * unit, args. clone ( ) ) ;
441
457
}
442
458
}
0 commit comments