Skip to content

Commit ebdfe33

Browse files
authored
Rollup merge of rust-lang#44138 - steveklabnik:rustdoc-deprecations, r=QuietMisdreavus
Deprecate several flags in rustdoc Part of rust-lang#44136 cc @rust-lang/dev-tools @rust-lang/docs This is a very basic PR to start deprecating some flags; `rustdoc` doesn't really have fancy output options like `rustc` does, so I went with `eprintln!`. Happy to change it if people feel that's not appropriate. Also, I have no idea if we can or should write tests here, so I didn't try. If someone feels strongly about it, then let's do it, but given that the only outcome here is a side effect...
2 parents 7a4f394 + 045ce18 commit ebdfe33

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

src/librustdoc/lib.rs

+41
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ pub fn opts() -> Vec<RustcOptGroup> {
170170
stable("no-default", |o| {
171171
o.optflag("", "no-defaults", "don't run the default passes")
172172
}),
173+
stable("document-private-items", |o| {
174+
o.optflag("", "document-private-items", "document private items")
175+
}),
173176
stable("test", |o| o.optflag("", "test", "run code examples as tests")),
174177
stable("test-args", |o| {
175178
o.optmulti("", "test-args", "arguments to pass to the test runner",
@@ -275,6 +278,9 @@ pub fn main_args(args: &[String]) -> isize {
275278
// Check for unstable options.
276279
nightly_options::check_nightly_options(&matches, &opts());
277280

281+
// check for deprecated options
282+
check_deprecated_options(&matches);
283+
278284
if matches.opt_present("h") || matches.opt_present("help") {
279285
usage("rustdoc");
280286
return 0;
@@ -458,6 +464,18 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
458464
let mut passes = matches.opt_strs("passes");
459465
let mut plugins = matches.opt_strs("plugins");
460466

467+
// We hardcode in the passes here, as this is a new flag and we
468+
// are generally deprecating passes.
469+
if matches.opt_present("document-private-items") {
470+
default_passes = false;
471+
472+
passes = vec![
473+
String::from("strip-hidden"),
474+
String::from("collapse-docs"),
475+
String::from("unindent-comments"),
476+
];
477+
}
478+
461479
// First, parse the crate and extract all relevant information.
462480
let mut paths = SearchPaths::new();
463481
for s in &matches.opt_strs("L") {
@@ -550,3 +568,26 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
550568
});
551569
rx.recv().unwrap()
552570
}
571+
572+
/// Prints deprecation warnings for deprecated options
573+
fn check_deprecated_options(matches: &getopts::Matches) {
574+
let deprecated_flags = [
575+
"input-format",
576+
"output-format",
577+
"plugin-path",
578+
"plugins",
579+
"no-defaults",
580+
"passes",
581+
];
582+
583+
for flag in deprecated_flags.into_iter() {
584+
if matches.opt_present(flag) {
585+
eprintln!("WARNING: the '{}' flag is considered deprecated", flag);
586+
eprintln!("WARNING: please see https://github.com/rust-lang/rust/issues/44136");
587+
}
588+
}
589+
590+
if matches.opt_present("no-defaults") {
591+
eprintln!("WARNING: (you may want to use --document-private-items)");
592+
}
593+
}

src/test/rustdoc/empty-mod-private.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
// ignore-tidy-linelength
12-
// compile-flags: --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports
12+
// compile-flags: --document-private-items
1313

1414
// @has 'empty_mod_private/index.html' '//a[@href="foo/index.html"]' 'foo'
1515
// @has 'empty_mod_private/sidebar-items.js' 'foo'

src/test/rustdoc/issue-15347.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// compile-flags:--no-defaults --passes collapse-docs --passes unindent-comments
11+
// compile-flags: --no-defaults --passes collapse-docs --passes unindent-comments
1212

1313
// @has issue_15347/fn.foo.html
1414
#[doc(hidden)]

src/test/rustdoc/pub-method.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
// ignore-tidy-linelength
12-
// compile-flags: --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports
12+
// compile-flags: --document-private-items
1313

1414
#![crate_name = "foo"]
1515

0 commit comments

Comments
 (0)