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

rustdoc: Only include a stability span if needed. #39740

Merged
merged 3 commits into from
Feb 12, 2017
Merged

rustdoc: Only include a stability span if needed. #39740

merged 3 commits into from
Feb 12, 2017

Conversation

jimmycuadra
Copy link
Contributor

@jimmycuadra jimmycuadra commented Feb 11, 2017

This patch gets rid of the empty stability boxes in docs by only including the span that creates it when the item actually has a stability class.

Here are images of the issue on std::process::Output:

Before:

before

After:

after

This is my first non-trivial patch to Rust, so I'm sure some of my approach is not idiomatic. Let me know how you'd like me to adjust!

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

write!(w, "<span class='stab {stab}'></span>",
stab = stability_class)?;
}
write!(w, "</span>")?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This extra close looks suspicious, and is likely the cause of the failing Travis build (which is failing on a rustdoc test).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

if !s.deprecated_since.is_empty() {
base.push_str(" deprecated");
pub fn stability_class(&self) -> Option<String> {
match self.stability {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe (I'm no expert either) this would be more idiomatic:

self.stability.as_ref().and_then(|ref s| {
// ...
})

one level less of indentation, no need to map None to None. I made a tiny playground script to make sure they both mean the same thing if you wanna take a look https://is.gd/5fSbZf

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, you're right. It was originally written that way, but I changed it because I got confused between Option::map and Option::and_then, thinking the closure couldn't return an option. I'll switch it back.

@aturon
Copy link
Member

aturon commented Feb 11, 2017

Thanks for the changes -- looks great now! The remaining Travis failures appear to be spurious. Let's see what bors says.

@bors: r+

@bors
Copy link
Contributor

bors commented Feb 11, 2017

📌 Commit 1fa9dbc has been approved by aturon

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Feb 12, 2017
…, r=aturon

rustdoc: Only include a stability span if needed.

This patch gets rid of the empty stability boxes in docs by only including the span that creates it when the item actually has a stability class.

Here are images of the issue on `std::process::Output`:

Before:

<img width="340" alt="before" src="https://cloud.githubusercontent.com/assets/122457/22853638/ff88d1b2-f010-11e6-90d6-bf3d10e2fffa.png">

After:

<img width="333" alt="after" src="https://cloud.githubusercontent.com/assets/122457/22853639/06bfe7cc-f011-11e6-9892-f0ea2cc6ec90.png">

This is my first non-trivial patch to Rust, so I'm sure some of my approach is not idiomatic. Let me know how you'd like me to adjust!
bors added a commit that referenced this pull request Feb 12, 2017
Rollup of 7 pull requests

- Successful merges: #39654, #39662, #39697, #39740, #39743, #39756, #39760
- Failed merges:
@bors bors merged commit 1fa9dbc into rust-lang:master Feb 12, 2017
@jimmycuadra jimmycuadra deleted the rustdoc-empty-stability branch February 12, 2017 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants