rust/compiler
bors 6d05c430d2 Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease
rustdoc: show crate name beside smaller logo

*Blocked on https://github.com/rust-lang/cargo/pull/12800*

## Summary

In this PR, the crate name and version are always shown in the sidebar, even in subpages, and the lateral navigation is always shown in the sidebar, even in modules.

Clicking the crate name does the same thing clicking the logo always did: take you to the crate root (the crate's home page, at least within Rustdoc).

The Rust logo is also no longer shown by default for non-Rust docs.

### Screenshots

<details><summary>Before</summary>

| | Macro | Module |
|--|-------|--------|
| In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/d5db0a46-2bb6-44a2-a3aa-2d915ecb8595) |![image](https://github.com/rust-lang/rust/assets/1593513/61f8c1ee-c298-4e2c-b791-18ecb79ab83b)
| In module[^1] | ![image](https://github.com/rust-lang/rust/assets/1593513/73abca59-0b69-4650-a1e2-7278ca34795c) | ![image](https://github.com/rust-lang/rust/assets/1593513/0baf02c2-2ec7-4674-80e5-a6a74a973376)

[^1]: This PR also includes a bug fix for derive macros not showing up in the lateral navigation part of the sidebar

</details>

#### Whole sidebar screenshots

| | Macro | Module |
|--|-------|--------|
| In crate | ![image](https://github.com/rust-lang/rust/assets/1593513/75d1bd07-41f7-4f11-ba24-fd5476e0586a) | ![image](https://github.com/rust-lang/rust/assets/1593513/52960259-2b65-4131-b380-01826f0a0eb7)
| In module | ![image](https://github.com/rust-lang/rust/assets/1593513/06e57928-8cb0-41bd-b152-be16cc53e5ec) | ![image](https://github.com/rust-lang/rust/assets/1593513/37291c69-2a07-4467-a382-d9b029084a47)

#### Different logo configurations

|         | Short crate name | Long crate name |
|---------|------------------|-----------------|
| Root    | ![short-root]    | ![long-root]
| Subpage | ![short-subpage] | ![long-subpage]

[short-root]: https://github.com/rust-lang/rust/assets/1593513/9e2b4fa8-f581-4106-b562-1e0372c13f79
[short-subpage]: https://github.com/rust-lang/rust/assets/1593513/8331cdb8-fa13-4671-a1e2-dcc1cdca7451
[long-root]: https://github.com/rust-lang/rust/assets/1593513/7d377fec-0f1d-4343-9f82-0e35a8f58056
[long-subpage]: https://github.com/rust-lang/rust/assets/1593513/3b3094a4-63c9-477c-8c15-b6075837df30

##### Without a logo

![image](https://github.com/rust-lang/rust/assets/1593513/66672b79-6c59-4be8-a527-25ef6f0b04ab)

### Preview pages

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/rocket_sync_db_pools/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust-compiler/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rust/std/index.html

https://notriddle.com/rustdoc-html-demo-5/sidebar-layout-rocket/tokio/index.html

## Motivation

This improves visual information density (the construct with the logo and crate name is *shorter* than the logo on its own, because it's not square) and navigation clarity (we can now see what clicking the Rust logo does, specifically).

Compare this with the layout at [Phoenix's Hexdocs] (which is what this proposal is closely based on), the old proposal on [Internals Discourse] (which always says "Rust standard library" in the sidebar, but doesn't do the side-by-side layout).

[Phoenix's Hexdocs]: https://hexdocs.pm/phoenix/1.7.7/overview.html
[Internals Discourse]: https://internals.rust-lang.org/t/poc-of-a-new-design-for-the-generated-rustdoc/11018

## Guide-level explanation

This PR cleans up some of the sidebar navigation.

It makes the logo in the desktop sidebar a bit smaller, and puts the crate name and version next to it (either beside it, or below it, depending on if there's space), making it clearer what clicking on it does: click the crate name to open the crate's home page. It also removes the Rust logo from non-official-Rust crates, again to make the navigation and supply chain clearer (since the crate name has been added, the logo is no longer necessary for navigation).

It adds a bit more clarifying information for lateral navigation. On items that don't add their own sidebar items, it just shows its siblings directly below the crate name and logo, but for other items, it shows "In crate alloc" instead of just "In alloc". It also shows the lateral navigation tools on module pages, making modules consistent with every other item.

## Drawbacks

While this actually takes up less screen real estate than the old layout on desktop, it takes up more HTML. It's also a bit more visually complex.

## Rationale and alternatives

I could do what the Internals POC did and keep the vertically stacked layout all the time, instead of doing a horizontal stack where possible. It would take up more screen real estate, though.

## Prior art

This design is lifted almost verbatim from Hexdocs. It seems to work for them. [`opentelemetry_process_propagator`], for example, has a long application name.

[`opentelemetry_process_propagator`]: https://hexdocs.pm/opentelemetry_process_propagator/OpentelemetryProcessPropagator.html

## Unresolved questions

Maybe we should encourage crate authors to include their own logo more often? It certainly helps give people a better sense of "place." This seems to be blocked on coming up with an API to do it without requiring them to host the file somewhere.

## Future possibilities

Beyond this, plenty of other changes could be made to improve the layout, like

* Fix things so that clicking an item in the sidebar doesn't cause it to scroll back to the top.
  * The [Internals demo](https://utherii.github.io/new.html) does this right: clicking an item in the sidebar changes the content area, but the sidebar itself does not change. This is nice, because clicking is cheap and I can skim the opening few paragraphs while browsing.
  * The layout of the docs sidebar causes trouble to implement this, because it's different on different pages, but at least fix this on the file browser.
* Come up with a less cluttered way to do disclosure. There's a lot of `[-]` on the page.
  * We don't lack ideas to fix this one. We have *too many*.
* Do a better job of separating local navigation (vec::Vec links to vec::IntoIter) and the table of contents (vec::Vec links to vec::Vec::new).
  * A possibility: add a Back arrow next to the "In [module]" header?
    ![image](https://github.com/rust-lang/rust/assets/1593513/e969faf7-7722-457a-b8c6-8d962e9e1e23)
* Give readers more control of how much rustdoc shows them, and giving doc authors more control of how much it generates. Basically, https://github.com/rust-lang/rust/pull/115660 is great, let's do it too.

But those are mostly orthogonal, not future possibilities unlocked by this change.
2023-10-11 06:28:36 +00:00
..
rustc Split out the stable part of smir into its own crate to prevent accidental usage of forever unstable things 2023-09-25 14:38:27 +00:00
rustc_abi Remove unnecessary features from rustc_abi 2023-10-04 11:43:57 +02:00
rustc_arena rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_ast rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_ast_lowering Rollup merge of #116431 - estebank:issue-80476, r=compiler-errors 2023-10-05 00:56:30 -07:00
rustc_ast_passes Rollup merge of #116393 - compiler-errors:auto-bad, r=WaffleLapkin 2023-10-04 05:02:07 +02:00
rustc_ast_pretty Move let expression checking to parsing 2023-09-11 15:51:18 +00:00
rustc_attr Factor out insert_or_error. 2023-10-06 14:57:09 +11:00
rustc_baked_icu_data
rustc_borrowck Auto merge of #114811 - estebank:impl-ambiguity, r=wesleywiser 2023-10-06 18:44:32 +00:00
rustc_builtin_macros Don't escape_debug the condition of assert!. 2023-10-10 09:08:11 +11:00
rustc_codegen_cranelift Merge commit '81dc066758ec150b43822d4a0c84aae20fe10f40' into sync_cg_clif-2023-10-09 2023-10-09 08:52:46 +00:00
rustc_codegen_gcc Use IntoDynSyncSend 2023-10-09 17:13:35 -04:00
rustc_codegen_llvm Make FnDef 1-ZST in LLVM debuginfo. 2023-10-08 16:42:45 +00:00
rustc_codegen_ssa rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_const_eval Auto merge of #116551 - RalfJung:nondet-nan, r=oli-obk 2023-10-10 11:42:27 +00:00
rustc_data_structures Remove unused dominator iterator 2023-10-10 21:39:59 +02:00
rustc_driver
rustc_driver_impl rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_error_codes Auto merge of #114811 - estebank:impl-ambiguity, r=wesleywiser 2023-10-06 18:44:32 +00:00
rustc_error_messages
rustc_errors rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_expand Add two setter functions to Features. 2023-10-05 18:01:11 +11:00
rustc_feature Use a closure when setting State::Active. 2023-10-05 19:56:19 +11:00
rustc_fluent_macro rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_fs_util
rustc_graphviz rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_hir Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrum 2023-10-01 05:56:47 +00:00
rustc_hir_analysis Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease 2023-10-11 06:28:36 +00:00
rustc_hir_pretty Record asyncness span in HIR 2023-09-21 19:18:14 +00:00
rustc_hir_typeck Rollup merge of #116250 - estebank:closure-arg-inference-span, r=petrochenkov 2023-10-10 18:44:44 +02:00
rustc_incremental rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_index Preserve DebugInfo in DeadStoreElimination. 2023-10-06 15:46:11 +00:00
rustc_infer Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease 2023-10-11 06:28:36 +00:00
rustc_interface Don't use a thread to load the dep graph 2023-09-24 00:30:43 +02:00
rustc_lexer
rustc_lint rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_lint_defs Remove rustc_lint_defs::lint_array 2023-09-28 23:01:25 +02:00
rustc_llvm rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_log use env variable to control thread ids in rustc_log 2023-10-10 09:39:47 +08:00
rustc_macros
rustc_metadata rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_middle Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease 2023-10-11 06:28:36 +00:00
rustc_mir_build Auto merge of #116427 - cjgillot:no-internal, r=oli-obk 2023-10-05 09:59:14 +00:00
rustc_mir_dataflow Preserve DebugInfo in DeadStoreElimination. 2023-10-06 15:46:11 +00:00
rustc_mir_transform Auto merge of #113915 - cjgillot:ssa-call, r=tmiasko 2023-10-10 20:37:55 +00:00
rustc_monomorphize rustc_monomorphize: Introduce check_fn_args_move_size() 2023-10-07 10:29:37 +02:00
rustc_parse Rollup merge of #116400 - estebank:issue-78585, r=WaffleLapkin 2023-10-06 16:37:47 -07:00
rustc_parse_format rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_passes Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease 2023-10-11 06:28:36 +00:00
rustc_plugin_impl rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_privacy rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_query_impl rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_query_system Rollup merge of #115863 - chenyukang:yukang-add-message-tidy-check, r=davidtwco 2023-10-03 12:24:11 +02:00
rustc_resolve rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_serialize rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_session Rollup merge of #116595 - RalfJung:mir-enable-passes, r=oli-obk 2023-10-10 14:07:48 +02:00
rustc_smir Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease 2023-10-11 06:28:36 +00:00
rustc_span rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_symbol_mangling rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_target rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_trait_selection Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease 2023-10-11 06:28:36 +00:00
rustc_traits Detect cycle errors hidden by opaques during monomorphization 2023-09-13 17:35:44 +00:00
rustc_transmute Remove the MaybeTransmutableQuery<&'l Dfa<...>, C> impl. 2023-10-06 11:25:32 +11:00
rustc_ty_utils rustdoc: remove rust logo from non-Rust crates 2023-10-08 20:17:53 -07:00
rustc_type_ir Auto merge of #116069 - compiler-errors:debug-tuple, r=Nilstrieb 2023-09-24 15:16:18 +00:00
stable_mir Rollup merge of #116560 - ouz-a:efficient_ids, r=oli-obk 2023-10-10 18:44:46 +02:00