]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #50669 - QuietMisdreavus:deprecated-attrs, r=GuillaumeGomez
authorkennytm <kennytm@gmail.com>
Wed, 16 May 2018 15:22:48 +0000 (23:22 +0800)
committerGitHub <noreply@github.com>
Wed, 16 May 2018 15:22:48 +0000 (23:22 +0800)
rustdoc: deprecate `#![doc(passes, plugins, no_default_passes)]`

Closes https://github.com/rust-lang/rust/issues/48164

Blocked on https://github.com/rust-lang/rust/pull/50541 - this includes those changes, which were necessary to create the UI test

cc https://github.com/rust-lang/rust/issues/44136

Turns out, there were special attributes to mess with rustdoc passes and plugins! Who knew! Since we deprecated the CLI flags for this functionality, it makes sense that we do the same for the attributes.

This PR also introduces a `#![doc(document_private_items)]` attribute, to match the `--document-private-items` flag introduced in https://github.com/rust-lang/rust/pull/44138 when the passes/plugins flags were deprecated.

I haven't done a search to see whether these attributes are being used at all, but if the flags were any indication, i don't expect to see any users of these.

1  2 
src/librustdoc/lib.rs

diff --combined src/librustdoc/lib.rs
index 7d98feaf539474856e043cd263a356020abffa6d,2c08bfa9a7446ee80e75077fbfb1cfcf2a84362b..a14a27d5d619347aacf6c8f765fbab3ad3e9b8c2
@@@ -48,7 -48,6 +48,7 @@@ extern crate test as testing
  extern crate rustc_errors as errors;
  extern crate pulldown_cmark;
  extern crate tempdir;
 +extern crate minifier;
  
  extern crate serialize as rustc_serialize; // used by deriving
  
@@@ -299,11 -298,6 +299,11 @@@ pub fn opts() -> Vec<RustcOptGroup> 
                       "How errors and other messages are produced",
                       "human|json|short")
          }),
 +        unstable("disable-minification", |o| {
 +             o.optflag("",
 +                       "disable-minification",
 +                       "Disable minification applied on JS files")
 +        }),
      ]
  }
  
@@@ -484,7 -478,6 +484,7 @@@ pub fn main_args(args: &[String]) -> is
      let linker = matches.opt_str("linker").map(PathBuf::from);
      let sort_modules_alphabetically = !matches.opt_present("sort-modules-by-appearance");
      let resource_suffix = matches.opt_str("resource-suffix");
 +    let enable_minification = !matches.opt_present("disable-minification");
  
      let edition = matches.opt_str("edition").unwrap_or("2015".to_string());
      let edition = match edition.parse() {
                                    css_file_extension,
                                    renderinfo,
                                    sort_modules_alphabetically,
 -                                  themes)
 +                                  themes,
 +                                  enable_minification)
                      .expect("failed to generate documentation");
                  0
              }
@@@ -654,6 -646,20 +654,20 @@@ where R: 'static + Send
  
          krate.version = crate_version;
  
+         let diag = core::new_handler(error_format, None);
+         fn report_deprecated_attr(name: &str, diag: &errors::Handler) {
+             let mut msg = diag.struct_warn(&format!("the `#![doc({})]` attribute is \
+                                                      considered deprecated", name));
+             msg.warn("please see https://github.com/rust-lang/rust/issues/44136");
+             if name == "no_default_passes" {
+                 msg.help("you may want to use `#![doc(document_private_items)]`");
+             }
+             msg.emit();
+         }
          // Process all of the crate attributes, extracting plugin metadata along
          // with the passes which we are supposed to run.
          for attr in krate.module.as_ref().unwrap().attrs.lists("doc") {
              let name = name.as_ref().map(|s| &s[..]);
              if attr.is_word() {
                  if name == Some("no_default_passes") {
+                     report_deprecated_attr("no_default_passes", &diag);
                      default_passes = false;
                  }
              } else if let Some(value) = attr.value_str() {
                  let sink = match name {
-                     Some("passes") => &mut passes,
-                     Some("plugins") => &mut plugins,
+                     Some("passes") => {
+                         report_deprecated_attr("passes = \"...\"", &diag);
+                         &mut passes
+                     },
+                     Some("plugins") => {
+                         report_deprecated_attr("plugins = \"...\"", &diag);
+                         &mut plugins
+                     },
                      _ => continue,
                  };
                  for p in value.as_str().split_whitespace() {
                      sink.push(p.to_string());
                  }
              }
+             if attr.is_word() && name == Some("document_private_items") {
+                 default_passes = false;
+                 passes = vec![
+                     String::from("collapse-docs"),
+                     String::from("unindent-comments"),
+                 ];
+             }
          }
  
          if default_passes {