Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate several flags in rustdoc #44138

Merged
merged 3 commits into from
Oct 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ pub fn opts() -> Vec<RustcOptGroup> {
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",
Expand Down Expand Up @@ -275,6 +278,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;
Expand Down Expand Up @@ -458,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") {
Expand Down Expand Up @@ -550,3 +568,26 @@ 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");
}
}

if matches.opt_present("no-defaults") {
eprintln!("WARNING: (you may want to use --document-private-items)");
}
}
2 changes: 1 addition & 1 deletion src/test/rustdoc/empty-mod-private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/issue-15347.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/pub-method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down