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

let rustdoc print the crate version into docs #44989

Merged
merged 2 commits into from Oct 13, 2017

Conversation

Projects
None yet
8 participants
@QuietMisdreavus
Copy link
Member

QuietMisdreavus commented Oct 2, 2017

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:

Screenshot of a test crate, showing "Version 1.3.37" under the crate name

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.)

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Oct 2, 2017

Some changes occurred in HTML/CSS.

cc @GuillaumeGomez

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Oct 2, 2017

r? @steveklabnik

(rust_highfive has picked a reviewer for you, use r? to override)

@QuietMisdreavus

This comment has been minimized.

Copy link
Member Author

QuietMisdreavus commented Oct 2, 2017

Pings for everyone!

@rust-lang/docs Does this look right? Is this a good place for this? Right now it only shows up on the root module's page - nothing else will show this. Should we put it everywhere?

@GuillaumeGomez and @steveklabnik specifically (possibly dev-tools more broadly, but for now i'll stick with rustdoc peers) - This is a new command-line flag. In dev-tools meeting today the prevailing air was that this was not RFC worthy since it was straightforward enough, but i want to make extra sure that the other rustdoc stakeholders are on board.

@alexcrichton @Mark-Simulacrum (other rustbuild experts?) - How can I get bootstrap to use this flag when rendering docs for std and friends?

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Oct 3, 2017

Seems to be good. What happens with a very long version name? Does it goes on two lines or does it just stick out of the sidebar?

@QuietMisdreavus

This comment has been minimized.

Copy link
Member Author

QuietMisdreavus commented Oct 3, 2017

Looks like it wraps within the sidebar:

image

...unless you use a long word without a breaking separator, in which case it sticks out from the sidebar:

image

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Oct 3, 2017

This is a (smaaall) bug then. :p

@steveklabnik

This comment has been minimized.

Copy link
Member

steveklabnik commented Oct 5, 2017

This sounds good to me!

@camsteffen

This comment has been minimized.

Copy link
Contributor

camsteffen commented Oct 9, 2017

Use these styles to fix the wrapping issue on most modern browsers.

overflow-wrap: break-word;
word-wrap: break-word; /* deprecated */
word-break: break-word; /* Chrome, non-standard */

@QuietMisdreavus QuietMisdreavus force-pushed the QuietMisdreavus:what-is-your-quest branch from 8cdaec5 to fcee950 Oct 9, 2017

@QuietMisdreavus

This comment has been minimized.

Copy link
Member Author

QuietMisdreavus commented Oct 9, 2017

Wow, thanks! That looks much better!

image

I've force-pushed to include that CSS into the update.

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Oct 9, 2017

Now it's all good. Thanks!

@bors: r+ rollup

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 9, 2017

📋 Looks like this PR is still in progress, ignoring approval

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Oct 9, 2017

Ah damn, well, r=me once done.

@QuietMisdreavus

This comment has been minimized.

Copy link
Member Author

QuietMisdreavus commented Oct 9, 2017

Yeah, the rustdoc piece is basically done, but i'd like to see if i can get rustbuild to use this when generating the docs for std and friends before calling it done. I'll ask around again.

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Oct 9, 2017

You'll need to edit src/bootstrap/builder.rs and add RUSTDOC_CRATE_VERSION to the rustdoc_cmd environment variables. The value can be pulled from channel::CFG_RELEASE_NUM (1.22.0) or if you want the SHA, self.build.rust_info.version(...) will work.

Let me know if you'd like more detailed instructions, or I can probably get you a commit implementing this within a few days.

@QuietMisdreavus QuietMisdreavus changed the title [WIP] let rustdoc print the crate version into docs let rustdoc print the crate version into docs Oct 9, 2017

@QuietMisdreavus

This comment has been minimized.

Copy link
Member Author

QuietMisdreavus commented Oct 9, 2017

@Mark-Simulacrum That got me most of the way there. It turns out that the docs weren't using rustdoc_cmd at all, instead going through cargo. I wound up adding RUSTDOCFLAGS to each doc invocation to get the crate version in, but that can introduce problems in compiler-docs mode, since external crates will also get that version number. I also don't know how this will interact if/when Cargo starts providing this flag itself, but for the moment this does what i want:

image

If you think this is fine, then i'm ready to call this good.

@QuietMisdreavus QuietMisdreavus force-pushed the QuietMisdreavus:what-is-your-quest branch from b0b746c to ce71c9e Oct 9, 2017

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Oct 9, 2017

Hm, I'm suspecting that RUSTDOCFLAGS may not apply correctly with compiler docs, since we want the version to display on more than just the last crate. I think I'd move to unconditionally setting something like RUSTDOC_CRATE_VERSION in cargo (src/bootstrap/builder.rs) and then using that in src/bin/rustdoc.rs to set the unstable option.

@QuietMisdreavus QuietMisdreavus force-pushed the QuietMisdreavus:what-is-your-quest branch 3 times, most recently from 21cb80a to 5a847c6 Oct 10, 2017

@QuietMisdreavus

This comment has been minimized.

Copy link
Member Author

QuietMisdreavus commented Oct 10, 2017

Ooh, i like that option. I've force-pushed with an update that uses that instead.

@Mark-Simulacrum
Copy link
Member

Mark-Simulacrum left a comment

I'm happy with the rustbuild changes after this small nit.

@@ -574,6 +574,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());

This comment has been minimized.

@Mark-Simulacrum

Mark-Simulacrum Oct 10, 2017

Member

Let's also add this to rustdoc_cmd above to make certain it's passed in all cases.

This comment has been minimized.

@QuietMisdreavus

QuietMisdreavus Oct 11, 2017

Author Member

Force-pushed with this update.

@QuietMisdreavus QuietMisdreavus force-pushed the QuietMisdreavus:what-is-your-quest branch from 5a847c6 to 7ea286e Oct 11, 2017

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Oct 11, 2017

@bors r=GuillaumeGomez

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 11, 2017

📌 Commit 7ea286e has been approved by GuillaumeGomez

kennytm added a commit to kennytm/rust that referenced this pull request Oct 12, 2017

Rollup merge of rust-lang#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:

![Screenshot of a test crate, showing "Version 1.3.37" under the crate name](https://user-images.githubusercontent.com/5217170/31104096-805e3f4c-a7a0-11e7-96fc-368b6fe063d6.png)

Closes rust-lang#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.)

bors added a commit that referenced this pull request Oct 12, 2017

Auto merge of #45233 - kennytm:rollup, r=kennytm
Rollup of 10 pull requests

- Successful merges: #44989, #45005, #45049, #45105, #45121, #45163, #45166, #45172, #45190, #45231
- Failed merges: #45138

bors added a commit that referenced this pull request Oct 12, 2017

Auto merge of #45233 - kennytm:rollup, r=kennytm
Rollup of 10 pull requests

- Successful merges: #44989, #45005, #45049, #45105, #45121, #45163, #45166, #45172, #45190, #45231
- Failed merges: #45138

bors added a commit that referenced this pull request Oct 12, 2017

Auto merge of #45233 - kennytm:rollup, r=kennytm
Rollup of 10 pull requests

- Successful merges: #44989, #45005, #45049, #45105, #45121, #45163, #45166, #45172, #45190, #45231
- Failed merges: #45138

kennytm added a commit to kennytm/rust that referenced this pull request Oct 12, 2017

Rollup merge of rust-lang#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:

![Screenshot of a test crate, showing "Version 1.3.37" under the crate name](https://user-images.githubusercontent.com/5217170/31104096-805e3f4c-a7a0-11e7-96fc-368b6fe063d6.png)

Closes rust-lang#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.)

bors added a commit that referenced this pull request Oct 12, 2017

Auto merge of #45233 - kennytm:rollup, r=<try>
[WIP] Rollup of 10 pull requests

- Successful merges: #44989, #45005, #45049, #45105, #45121, #45163, #45166, #45172, #45190, #45231
- Failed merges: #45138

bors added a commit that referenced this pull request Oct 12, 2017

Auto merge of #45233 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests

- Successful merges: #44989, #45005, #45049, #45105, #45121, #45166, #45172, #45190, #45231
- Failed merges: #45138

@bors bors merged commit 7ea286e into rust-lang:master Oct 13, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@QuietMisdreavus QuietMisdreavus deleted the QuietMisdreavus:what-is-your-quest branch Oct 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.