rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.34k stars 12.72k forks source link

rustdoc: proposal to tame gutter affordances #57164

Open JohnHeitmann opened 5 years ago

JohnHeitmann commented 5 years ago

I have a few small proposals to reduce the visual clutter of rustdoc pages:

  1. Move all toggle buttons to the right. Benefits: consistency (sometimes they are already on the right), and moves element clutter to a part of the page that doesn't have the reader's initial focus.
  2. Similarly, move the ⓘ link to the right.
  3. On the following doc bits remove toggles completely and show docs unconditionally:
    1. Item description
    2. Enum variant
    3. Struct and trait method descriptions (methods directly on the item, not foreign)
  4. "Smart" disclosure of short declarations. If a declaration is at most a few lines long, show it unconditionally with no toggle. Ditto attributes in declarations. Long declarations like Iterator retain their current undisclosed behavior.
    1. ... alternately: always show ~4 lines and truncate beyond that with ...
  5. On mobile: be a bit more extreme in clutter reduction and remove completely any toggles that default to open.
  6. On mobile: for blocks that do have a closed toggle, do not wrap the exposed heading, instead truncate with "..." before the toggle. I think declarations tend to have enough information leftward to make this work well, but I haven't tried it yet. It might be a horrible idea in practice.

Quick 'n Dirty mockups just to give the gist:

screen shot 2018-12-27 at 11 27 41 pm

screen shot 2018-12-27 at 11 27 18 pm

The size and indentation of the toggles as they are implemented today do give some ambient hints about the hierarchy of the page, so I'd also want to tweak spacing & sizing a bit to better emphasize hierarchy. You can see in the mock (where I haven't tweaked spacing yet) that the pub fn line looks very similar in priority to the impl Vec line, which is probably not desirable.

Bonus Objectives:

  1. A better icon for ⓘ that more closely indicates what it is.
  2. Remove or tweak ⓘ where it doesn't seem to add value. e.g. nearly every method on Vec: https://doc.rust-lang.org/std/vec/struct.Vec.html#method.new . I'm pretty ignorant about this feature. Maybe I'll come around on it once I understand it better.

If this gets positive reception, I can build a demo of these changes.

JohnHeitmann commented 5 years ago

One more tweak proposal: Change the text "fields omitted" to either "private fields omitted" or nothing at all in order to distinguish between the "These are private" case and the "We're hiding these for decluttering" case. Until just now I thought that text was for decluttering.

steveklabnik commented 4 years ago

cc @GuillaumeGomez