diff options
| author | kennytm <kennytm@gmail.com> | 2017-10-12 16:14:22 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2017-10-13 01:58:36 +0800 |
| commit | 445bbde7844eacb3de968e2584db2d44e6c4cbab (patch) | |
| tree | 7a16afc1e827ce53ffc5a9f4e86918b6b77ae5be /src/bootstrap | |
| parent | 1807f27a338e8e3f8c3a9c99fde2223b5942e640 (diff) | |
| parent | 7ea286e854d88529af76ca486ed676c9fb06e8ee (diff) | |
| download | rust-445bbde7844eacb3de968e2584db2d44e6c4cbab.tar.gz rust-445bbde7844eacb3de968e2584db2d44e6c4cbab.zip | |
Rollup merge of #44989 - QuietMisdreavus:what-is-your-quest, r=GuillaumeGomez
let rustdoc print the crate version into docs This PR adds a new unstable flag to rustdoc, `--crate-version`, which when present will add a new entry to the sidebar of the root module, printing the given version number:  Closes #24336 (The WIP status is because i don't want to merge this until i can get the std docs to use it, which i need help from rustbuild people to make sure i get right.)
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/bin/rustdoc.rs | 8 | ||||
| -rw-r--r-- | src/bootstrap/builder.rs | 6 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs index d7d72d5dd56..d18512b257d 100644 --- a/src/bootstrap/bin/rustdoc.rs +++ b/src/bootstrap/bin/rustdoc.rs @@ -48,6 +48,14 @@ fn main() { cmd.arg("-Z").arg("force-unstable-if-unmarked"); } + // Bootstrap's Cargo-command builder sets this variable to the current Rust version; let's pick + // it up so we can make rustdoc print this into the docs + if let Some(version) = env::var_os("RUSTDOC_CRATE_VERSION") { + // This "unstable-options" can be removed when `--crate-version` is stabilized + cmd.arg("-Z").arg("unstable-options") + .arg("--crate-version").arg(version); + } + std::process::exit(match cmd.status() { Ok(s) => s.code().unwrap_or(1), Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e), diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index e7a5196178c..1d63e112ca6 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -418,7 +418,8 @@ impl<'a> Builder<'a> { .env("RUSTC_SYSROOT", self.sysroot(compiler)) .env("RUSTC_LIBDIR", self.sysroot_libdir(compiler, self.build.build)) .env("CFG_RELEASE_CHANNEL", &self.build.config.channel) - .env("RUSTDOC_REAL", self.rustdoc(host)); + .env("RUSTDOC_REAL", self.rustdoc(host)) + .env("RUSTDOC_CRATE_VERSION", self.build.rust_version()); cmd } @@ -574,6 +575,9 @@ impl<'a> Builder<'a> { cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string()); } + // For `cargo doc` invocations, make rustdoc print the Rust version into the docs + cargo.env("RUSTDOC_CRATE_VERSION", self.build.rust_version()); + // Environment variables *required* throughout the build // // FIXME: should update code to not require this env var |
