7

rustdoc: Recent UI and UX changes in generated documentation

 3 years ago
source link: https://blog.guillaume-gomez.fr/articles/2022-04-08+rustdoc%3A+Recent+UI+and+UX+changes+in+generated+documentation
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

rustdoc: Recent UI and UX changes in generated documentation

Rustdoc is the tool used to generate documentation of the Rust crates. It's also the tool used to generate documentation on docs.rs. Recently, we made a lot of UI (user interface) changes aiming to improve the UX (user experience) when browsing the documentation. All this was possible thanks to @jsha leading this effort.

The goal of this blog post is to explain why we did them as also show some before/after comparisons.

Removal of non-pertinent attributes

We removed the display of the #[must_use] attribute as we considered it was not pertinent enough. So no more:

86277.png

Pull request: https://github.com/rust-lang/rust/pull/86277

Fix alignment of method headings

Methods are now aligned with their Implementations heading and we increased the font size of the Implementations heading to indicate it is higher in the hierarchy.

Before:

90155-old.png

After:

90155-new.png

Pull request: https://github.com/rust-lang/rust/pull/90155

Improve display of headings in documentation blocks

We removed the underline of some headings (everything under <h2> for the non-"top" documentation blocks) in the documentation blocks and also made them smaller.

Before:

90156-before.png

After:

90156-after.png

It was attracting the attention because they were actually bigger than the item itself and the underline was creating a "content split".

Pull request: https://github.com/rust-lang/rust/pull/90156

Only display the "Run button" on hover

So the "Run button":

92058.png

which was displayed in all code examples before will now only appear when you hover the code example. It allowed to make the documentation less "noisy", making them easier to read.

Pull request: https://github.com/rust-lang/rust/pull/92058

Fix/improve font size handling

This one doesn't really have a visual effects for most people, but in case you have set a different default font size, the display of rustdoc now uses it instead of overwriting it like before.

For technical details: instead of specifying the size of the font in pixels, we started using rem.

Pull request: https://github.com/rust-lang/rust/pull/92448

Move search crate filtering drop-down

This one is quite a big change. We moved the search crate-filtering drop-down into the results page directly. So from this:

92490-1.png

To this:

92490-2.png
92490-3.png

It allows to reduce the number of information displayed on the documentation while keeping the same amount of functionalities.

To be noted that this is the first step of a bigger plan to refactor how the search works: we intend to improve the UI in order to help the users write down the search request. More information in the coming months. :)

Pull request: https://github.com/rust-lang/rust/pull/92490

Improve source links display

This is another big change: the change of source links appearance. We made this change for two reasons:

  1. It wasn't obvious for non-native english speakers to understand what [src] is about. With source, it's more clear.
  2. The [] were attracting the eyes. It reduces this attraction a bit.
Before:

92602-before.png
After:

92602-after.png

Pull request: https://github.com/rust-lang/rust/pull/92602

Make the current item name link to the top of the page

This isn't a UI change but definitely a UX one. You can now click on the item name in the sidebar to go back to the top of page.

92795.png

Pull request: https://github.com/rust-lang/rust/pull/92795

Remove horizontal lines at the top of the page

Under the search input and under the title (where the name of the item is), there were horizontal lines. This separation was not useful and just making the page "heavier" for the eye.

Before:

92797-before.png

After:

92797-after.png

Pull request: https://github.com/rust-lang/rust/pull/92797

Improve sidebar display

The sidebar was certainly one of the elements that needed the most changes. It got cleaned up and unified with the rest of the page.

Desktop

Before:

92692-1.png
After:

92692-2.png

Mobile

Before:

92692-3.png
92692-4.png

After:

92692-5.png
92692-6.png

To see all the changes, I recommend you to go read the pull request.

Move item information on their own line on mobile

It was getting very crowded with all the item information. To make it easier to read, we moved the item information on its own line.

Before:

92861-before.png

After:

92861-after.png

Pull request: https://github.com/rust-lang/rust/pull/92861

Remove item extra information distraction

There is already the indent to allow the readers to see the item. Removing this arrow also allowed us to align it with the text below it.

Before:

92651-before.png

After:

92651-after.png

Pull request: https://github.com/rust-lang/rust/pull/92651

More spacing to distinguish items

Previously, there was not much spacing between the bottom of item A and the top of item B. That made it not clear whether item B's title was related to A or B. We increased the spacing at the bottom of item A so it would be clear where A ends and B begins.

We also made similar changes to the "Trait implementations" section that made it easier to see where one implementation ends and the next begins; and oft-requested improvement.

All this was also done in #92651.

Before:

92651-old.png

After:

92651-new.png

Unify search input and buttons size

It was a weird incoherence: the height, the border radius and the hover were behaving differently between buttons and the search input.

Before:

93113-before.png

After:

93113-after.png

Pull request: https://github.com/rust-lang/rust/pull/93113

Make scrollbar in the sidebar always visible for visual consistency

The problem here was that if you went from a page with not many elements into another one with enough elements to make the scrollbar in the sidebar appear, it was creating an unneeded change in layout by adding a new element (the scrollbar).

Before:

90983-before.png

After:

90983-after.png

Pull request: https://github.com/rust-lang/rust/pull/90983

Add rustdoc version into the help popup

This one isn't so much as a UI/UX change but more as a nice thing to have. So now, when you open the help popup (the ? button or by pressing the ? key), you will be able to see the version of rustdoc used to generate this documentation:

88964.png

Pull request: https://github.com/rust-lang/rust/pull/88964

Improve source code viewer sidebar

The source code viewer sidebar was suboptimal to say the least:

  • Its appearance didn't match the rest of rustdoc.
  • When expanded, it was over the source code.
  • Its content could be better looking.

The source code viewer sidebar is now more consistent and usable.

Before:

91356-1.png
91356-2.png

After:

91356-3.png
91356-4.png

Pull request: https://github.com/rust-lang/rust/pull/91356

Improve display of enum variants

There were multiple issues with the old way of displaying enum variants:

  • It was very verbose.
  • The bottom borders were distracting.
  • The doc blocks were weirdly placed.
  • The UX part wasn't great because headings were not HTML headings (we were using <div>).

Before:

90089-old.png

After:

90089-new.png

Pull request: https://github.com/rust-lang/rust/pull/90089

Use correct heading levels

In some cases, we had some <h2> inside some <h3>. It was very bad UX for screen reader users. This pull request fixed it. Althougth it was a very important improvement in itself, there was no UI changes. It's just to show that UX is also something very important for us.

Conclusion

So as you saw, this is a mix of very small changes and much bigger ones. We're still continuing our effort to make Rust documentation easier to use for everyone so expect more improvements to be added in the next months!

And finally, many thanks to @jsha for their review and help on this blog post!

Posted on the 08/04/2022 at 17:20 by @GuillaumeGomez

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK