Skip to content

Commit

Permalink
Rollup merge of rust-lang#69494 - GuillaumeGomez:stabilize-crate-vers…
Browse files Browse the repository at this point in the history
…ion, r=ehuss,aleksator,ollie27

Stabilize --crate-version option in rustdoc

I don't see any reason to not stabilize it anymore, so let's go!

cc @kinnison @ehuss

r? @ollie27
  • Loading branch information
Centril authored Mar 23, 2020
2 parents 0e40d7e + da5d03d commit 6d0c041
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
5 changes: 0 additions & 5 deletions src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ fn main() {
// 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
if !has_unstable {
cmd.arg("-Z").arg("unstable-options");
}
cmd.arg("--crate-version").arg(version);
has_unstable = true;
}

// Needed to be able to run all rustdoc tests.
Expand Down
7 changes: 6 additions & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ impl Step for Standalone {
}

let mut cmd = builder.rustdoc_cmd(compiler);
// Needed for --index-page flag
cmd.arg("-Z").arg("unstable-options");

cmd.arg("--html-after-content")
.arg(&footer)
.arg("--html-before-content")
Expand Down Expand Up @@ -395,7 +398,7 @@ impl Step for Std {

// Keep a whitelist so we do not build internal stdlib crates, these will be
// build by the rustc step later if enabled.
cargo.arg("-Z").arg("unstable-options").arg("-p").arg(package);
cargo.arg("-p").arg(package);
// Create all crate output directories first to make sure rustdoc uses
// relative links.
// FIXME: Cargo should probably do this itself.
Expand All @@ -406,6 +409,8 @@ impl Step for Std {
.arg("rust.css")
.arg("--markdown-no-toc")
.arg("--generate-redirect-pages")
.arg("-Z")
.arg("unstable-options")
.arg("--resource-suffix")
.arg(crate::channel::CFG_RELEASE_NUM)
.arg("--index-page")
Expand Down
12 changes: 12 additions & 0 deletions src/doc/rustdoc/src/command-line-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,15 @@ the same CSS rules as the official `light` theme.
`--check-theme` is a separate mode in `rustdoc`. When `rustdoc` sees the
`--check-theme` flag, it discards all other flags and only performs the CSS rule
comparison operation.

### `--crate-version`: control the crate version

Using this flag looks like this:

```bash
$ rustdoc src/lib.rs --crate-version 1.3.37
```

When `rustdoc` receives this flag, it will print an extra "Version (version)" into the sidebar of
the crate root's docs. You can use this flag to differentiate between different versions of your
library's documentation.
12 changes: 0 additions & 12 deletions src/doc/rustdoc/src/unstable-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,6 @@ Markdown file, the URL given to `--markdown-playground-url` will take precedence
`--playground-url` and `#![doc(html_playground_url = "url")]` are present when rendering crate docs,
the attribute will take precedence.

### `--crate-version`: control the crate version

Using this flag looks like this:

```bash
$ rustdoc src/lib.rs -Z unstable-options --crate-version 1.3.37
```

When `rustdoc` receives this flag, it will print an extra "Version (version)" into the sidebar of
the crate root's docs. You can use this flag to differentiate between different versions of your
library's documentation.

### `--sort-modules-by-appearance`: control how items on module pages are sorted

Using this flag looks like this:
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ fn opts() -> Vec<RustcOptGroup> {
unstable("display-warnings", |o| {
o.optflag("", "display-warnings", "to print code warnings when testing doc")
}),
unstable("crate-version", |o| {
stable("crate-version", |o| {
o.optopt("", "crate-version", "crate version to print into documentation", "VERSION")
}),
unstable("sort-modules-by-appearance", |o| {
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/crate-version.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// compile-flags: --crate-version=1.3.37 -Z unstable-options
// compile-flags: --crate-version=1.3.37

// @has 'crate_version/index.html' '//div[@class="block version"]/p' 'Version 1.3.37'

0 comments on commit 6d0c041

Please sign in to comment.