From 4adf6aed697f2d3915fdcc0ee3c5387f9d833dc5 Mon Sep 17 00:00:00 2001 From: steveklabnik Date: Mon, 28 Aug 2017 19:30:45 -0400 Subject: [PATCH 1/3] Deprecate several flags in rustdoc Part of #44136 Upgrades cargo due to https://github.com/rust-lang/cargo/pull/4451 --- src/librustdoc/lib.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 890e1169c0591..90952588c55df 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -275,6 +275,9 @@ pub fn main_args(args: &[String]) -> isize { // Check for unstable options. nightly_options::check_nightly_options(&matches, &opts()); + // check for deprecated options + check_deprecated_options(&matches); + if matches.opt_present("h") || matches.opt_present("help") { usage("rustdoc"); return 0; @@ -550,3 +553,22 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R { }); rx.recv().unwrap() } + +/// Prints deprecation warnings for deprecated options +fn check_deprecated_options(matches: &getopts::Matches) { + let deprecated_flags = [ + "input-format", + "output-format", + "plugin-path", + "plugins", + "no-defaults", + "passes", + ]; + + for flag in deprecated_flags.into_iter() { + if matches.opt_present(flag) { + eprintln!("WARNING: the '{}' flag is considered deprecated", flag); + eprintln!("WARNING: please see https://github.com/rust-lang/rust/issues/44136"); + } + } +} From aad8787586a46fc8eb2a89260fafd8598d378b67 Mon Sep 17 00:00:00 2001 From: steveklabnik Date: Thu, 21 Sep 2017 14:10:07 -0400 Subject: [PATCH 2/3] Create a new flag, --document-private-items Fixes #44136 --- src/librustdoc/lib.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 90952588c55df..20da99a6b1376 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -170,6 +170,9 @@ pub fn opts() -> Vec { stable("no-default", |o| { o.optflag("", "no-defaults", "don't run the default passes") }), + stable("document-private-items", |o| { + o.optflag("", "document-private-items", "document private items") + }), stable("test", |o| o.optflag("", "test", "run code examples as tests")), stable("test-args", |o| { o.optmulti("", "test-args", "arguments to pass to the test runner", @@ -461,6 +464,18 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R { let mut passes = matches.opt_strs("passes"); let mut plugins = matches.opt_strs("plugins"); + // We hardcode in the passes here, as this is a new flag and we + // are generally deprecating passes. + if matches.opt_present("document-private-items") { + default_passes = false; + + passes = vec![ + String::from("strip-hidden"), + String::from("collapse-docs"), + String::from("unindent-comments"), + ]; + } + // First, parse the crate and extract all relevant information. let mut paths = SearchPaths::new(); for s in &matches.opt_strs("L") { @@ -571,4 +586,8 @@ fn check_deprecated_options(matches: &getopts::Matches) { eprintln!("WARNING: please see https://github.com/rust-lang/rust/issues/44136"); } } + + if matches.opt_present("no-defaults") { + eprintln!("WARNING: (you may want to use --document-private-items)"); + } } From 045ce183cc6f34ec8315b2a99d22b9563c714a08 Mon Sep 17 00:00:00 2001 From: steveklabnik Date: Tue, 17 Oct 2017 13:54:46 -0400 Subject: [PATCH 3/3] modify tests to use new flag --- src/test/rustdoc/empty-mod-private.rs | 2 +- src/test/rustdoc/issue-15347.rs | 2 +- src/test/rustdoc/pub-method.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/rustdoc/empty-mod-private.rs b/src/test/rustdoc/empty-mod-private.rs index 6b86af62a663a..6c6af19be88f9 100644 --- a/src/test/rustdoc/empty-mod-private.rs +++ b/src/test/rustdoc/empty-mod-private.rs @@ -9,7 +9,7 @@ // except according to those terms. // ignore-tidy-linelength -// compile-flags: --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports +// compile-flags: --document-private-items // @has 'empty_mod_private/index.html' '//a[@href="foo/index.html"]' 'foo' // @has 'empty_mod_private/sidebar-items.js' 'foo' diff --git a/src/test/rustdoc/issue-15347.rs b/src/test/rustdoc/issue-15347.rs index 266a30891941d..c50df6edd484a 100644 --- a/src/test/rustdoc/issue-15347.rs +++ b/src/test/rustdoc/issue-15347.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-flags:--no-defaults --passes collapse-docs --passes unindent-comments +// compile-flags: --no-defaults --passes collapse-docs --passes unindent-comments // @has issue_15347/fn.foo.html #[doc(hidden)] diff --git a/src/test/rustdoc/pub-method.rs b/src/test/rustdoc/pub-method.rs index 5998734e4a20c..24d566e082eea 100644 --- a/src/test/rustdoc/pub-method.rs +++ b/src/test/rustdoc/pub-method.rs @@ -9,7 +9,7 @@ // except according to those terms. // ignore-tidy-linelength -// compile-flags: --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports +// compile-flags: --document-private-items #![crate_name = "foo"]