<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/src/librustdoc/html/render/sidebar.rs, branch 1.82.0</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=1.82.0</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=1.82.0'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2024-08-30T03:16:08+00:00</updated>
<entry>
<title>Remove `#[macro_use] extern crate tracing` from rustdoc.</title>
<updated>2024-08-30T03:16:08+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-08-30T03:16:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=37d1ce91b5d81c9a7239eb33e17e3d73f7f81aea'/>
<id>urn:sha1:37d1ce91b5d81c9a7239eb33e17e3d73f7f81aea</id>
<content type='text'>
</content>
</entry>
<entry>
<title>rustdoc: use `&lt;wbr&gt;` in sidebar headers</title>
<updated>2024-07-29T17:30:56+00:00</updated>
<author>
<name>Michael Howell</name>
<email>michael@notriddle.com</email>
</author>
<published>2024-07-07T02:07:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=1d339b07ca84743710dc87dc0bc4c0597006ed59'/>
<id>urn:sha1:1d339b07ca84743710dc87dc0bc4c0597006ed59</id>
<content type='text'>
This also improves sidebar layout, so instead of

    BTreeM
    ap

you get this

    BTree
    Map
</content>
</entry>
<entry>
<title>Reformat `use` declarations.</title>
<updated>2024-07-28T22:26:52+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-07-28T22:13:50+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=84ac80f1921afc243d71fd0caaa4f2838c294102'/>
<id>urn:sha1:84ac80f1921afc243d71fd0caaa4f2838c294102</id>
<content type='text'>
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
</content>
</entry>
<entry>
<title>Replace askama with rinja</title>
<updated>2024-07-23T09:19:55+00:00</updated>
<author>
<name>Guillaume Gomez</name>
<email>guillaume.gomez@huawei.com</email>
</author>
<published>2024-07-18T18:56:36+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=8d40b9ea6c253b58fcc28af5eaaf55d44b6ee165'/>
<id>urn:sha1:8d40b9ea6c253b58fcc28af5eaaf55d44b6ee165</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Re-format code with new rustfmt</title>
<updated>2023-11-16T02:45:48+00:00</updated>
<author>
<name>Mark Rousskov</name>
<email>mark.simulacrum@gmail.com</email>
</author>
<published>2023-11-13T13:24:55+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=917f6540edc20de22e1fb3069e7b325209109350'/>
<id>urn:sha1:917f6540edc20de22e1fb3069e7b325209109350</id>
<content type='text'>
</content>
</entry>
<entry>
<title>feat: render Object Safety informations non-object safe traits</title>
<updated>2023-10-29T21:57:45+00:00</updated>
<author>
<name>Alexis (Poliorcetics) Bourget</name>
<email>ab_github@poliorcetiq.eu</email>
</author>
<published>2023-07-01T17:13:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=51e22be682e4ed5864e36400cbbc10836ee52c7e'/>
<id>urn:sha1:51e22be682e4ed5864e36400cbbc10836ee52c7e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>rustdoc: use JS to inline target type impl docs into alias</title>
<updated>2023-10-22T22:56:14+00:00</updated>
<author>
<name>Michael Howell</name>
<email>michael@notriddle.com</email>
</author>
<published>2023-10-06T01:44:52+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=fa10e4d667aea7ca869eb53f9af925a5fa120c84'/>
<id>urn:sha1:fa10e4d667aea7ca869eb53f9af925a5fa120c84</id>
<content type='text'>
This is an attempt to balance three problems, each of which would
be violated by a simpler implementation:

- A type alias should show all the `impl` blocks for the target
  type, and vice versa, if they're applicable. If nothing was
  done, and rustdoc continues to match them up in HIR, this
  would not work.

- Copying the target type's docs into its aliases' HTML pages
  directly causes far too much redundant HTML text to be generated
  when a crate has large numbers of methods and large numbers
  of type aliases.

- Using JavaScript exclusively for type alias impl docs would
  be a functional regression, and could make some docs very hard
  to find for non-JS readers.

- Making sure that only applicable docs are show in the
  resulting page requires a type checkers. Do not reimplement
  the type checker in JavaScript.

So, to make it work, rustdoc stashes these type-alias-inlined docs
in a JSONP "database-lite". The file is generated in `write_shared.rs`,
included in a `&lt;script&gt;` tag added in `print_item.rs`, and `main.js`
takes care of patching the additional docs into the DOM.

The format of `trait.impl` and `type.impl` JS files are superficially
similar. Each line, except the JSONP wrapper itself, belongs to a crate,
and they are otherwise separate (rustdoc should be idempotent). The
"meat" of the file is HTML strings, so the frontend code is very simple.
Links are relative to the doc root, though, so the frontend needs to fix
that up, and inlined docs can reuse these files.

However, there are a few differences, caused by the sophisticated
features that type aliases have. Consider this crate graph:

```text
 ---------------------------------
 | crate A: struct Foo&lt;T&gt;        |
 |          type Bar = Foo&lt;i32&gt;  |
 |          impl X for Foo&lt;i8&gt;   |
 |          impl Y for Foo&lt;i32&gt;  |
 ---------------------------------
     |
 ----------------------------------
 | crate B: type Baz = A::Foo&lt;i8&gt; |
 |          type Xyy = A::Foo&lt;i8&gt; |
 |          impl Z for Xyy        |
 ----------------------------------
```

The type.impl/A/struct.Foo.js JS file has a structure kinda like this:

```js
JSONP({
"A": [["impl Y for Foo&lt;i32&gt;", "Y", "A::Bar"]],
"B": [["impl X for Foo&lt;i8&gt;", "X", "B::Baz", "B::Xyy"], ["impl Z for Xyy", "Z", "B::Baz"]],
});
```

When the type.impl file is loaded, only the current crate's docs are
actually used. The main reason to bundle them together is that there's
enough duplication in them for DEFLATE to remove the redundancy.

The contents of a crate are a list of impl blocks, themselves
represented as lists. The first item in the sublist is the HTML block,
the second item is the name of the trait (which goes in the sidebar),
and all others are the names of type aliases that successfully match.

This way:

- There's no need to generate these files for types that have no aliases
  in the current crate. If a dependent crate makes a type alias, it'll
  take care of generating its own docs.
- There's no need to reimplement parts of the type checker in
  JavaScript. The Rust backend does the checking, and includes its
  results in the file.
- Docs defined directly on the type alias are dropped directly in the
  HTML by `render_assoc_items`, and are accessible without JavaScript.
  The JSONP file will not list impl items that are known to be part
  of the main HTML file already.

[JSONP]: https://en.wikipedia.org/wiki/JSONP
</content>
</entry>
<entry>
<title>Revert "rustdoc: add impl items from aliased type into sidebar"</title>
<updated>2023-10-22T22:54:36+00:00</updated>
<author>
<name>Michael Howell</name>
<email>michael@notriddle.com</email>
</author>
<published>2023-10-06T01:44:44+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=36b8d58b41c6071bff0f5640b0e01f83cae8cd21'/>
<id>urn:sha1:36b8d58b41c6071bff0f5640b0e01f83cae8cd21</id>
<content type='text'>
This reverts commit d882b2118e505d86a9f770ef862fb1ee6e91ced8.
</content>
</entry>
<entry>
<title>Revert "rustdoc: factor all-impls-for-item out into its own method"</title>
<updated>2023-10-22T22:54:35+00:00</updated>
<author>
<name>Michael Howell</name>
<email>michael@notriddle.com</email>
</author>
<published>2023-10-06T01:44:43+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ab125a2e0b52601a5de1b85a937a4eea2309669c'/>
<id>urn:sha1:ab125a2e0b52601a5de1b85a937a4eea2309669c</id>
<content type='text'>
This reverts commit c3e5ad448b87be31e570c048cf7ba3b1e7daec44.
</content>
</entry>
<entry>
<title>Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease</title>
<updated>2023-10-11T06:28:36+00:00</updated>
<author>
<name>bors</name>
<email>bors@rust-lang.org</email>
</author>
<published>2023-10-11T06:28:36+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=6d05c430d2f0573bf98320bb1d2457a72ea1e67f'/>
<id>urn:sha1:6d05c430d2f0573bf98320bb1d2457a72ea1e67f</id>
<content type='text'>
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

&lt;details&gt;&lt;summary&gt;Before&lt;/summary&gt;

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

&lt;/details&gt;

#### 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.
</content>
</entry>
</feed>
