let rustdoc print the crate version into docs

This commit is contained in:
QuietMisdreavus
2017-10-02 18:29:03 -05:00
parent 1db1144277
commit fcee950660
5 changed files with 44 additions and 0 deletions

View File

@@ -243,6 +243,9 @@ pub fn opts() -> Vec<RustcOptGroup> {
unstable("display-warnings", |o| {
o.optflag("", "display-warnings", "to print code warnings when testing doc")
}),
unstable("crate-version", |o| {
o.optopt("", "crate-version", "crate version to print into documentation", "VERSION")
}),
]
}
@@ -460,6 +463,7 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
let triple = matches.opt_str("target");
let maybe_sysroot = matches.opt_str("sysroot").map(PathBuf::from);
let crate_name = matches.opt_str("crate-name");
let crate_version = matches.opt_str("crate-version");
let plugin_path = matches.opt_str("plugin-path");
let cr = PathBuf::from(cratefile);
@@ -484,6 +488,8 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
krate.name = name
}
krate.version = crate_version;
// 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") {