2016-08-27 16:00:36 +00:00
|
|
|
#![crate_name = "foo"]
|
2023-03-21 15:44:06 +00:00
|
|
|
#![feature(rustc_attrs)]
|
2021-11-26 23:03:16 +00:00
|
|
|
|
2016-08-27 16:00:36 +00:00
|
|
|
// @matches 'foo/index.html' '//h1' 'Crate foo'
|
rustdoc: show crate name beside small logo
This commit changes the layout to something a bit less "look at my logo!!!111"
gigantic, and makes it clearer where clicking the logo will actually take you.
It also means the crate name is persistently at the top of the sidebar, even
when in a sub-item page, and clicking that name takes you back to the root.
| | 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/fe2ce102-d4b8-44e6-9f7b-68636a907f56
[short-subpage]: https://github.com/rust-lang/rust/assets/1593513/29501663-56c0-4151-b7de-d2637e167125
[long-root]: https://github.com/rust-lang/rust/assets/1593513/f6a385c0-b4c5-4a9c-954b-21b38de4192f
[long-subpage]: https://github.com/rust-lang/rust/assets/1593513/97ec47b4-61bf-4ebe-b461-0d2187b8c6ca
https://notriddle.com/rustdoc-html-demo-4/logo-lockup/image/index.html
https://notriddle.com/rustdoc-html-demo-4/logo-lockup/crossbeam_channel/index.html
https://notriddle.com/rustdoc-html-demo-4/logo-lockup/adler/struct.Adler32.html
https://notriddle.com/rustdoc-html-demo-4/logo-lockup/crossbeam_channel/struct.Sender.html
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
In newer versions of rustdoc, the crate name and version are always shown in
the sidebar, even in subpages. Clicking the crate name does the same thing
clicking the logo always did: return you to the crate root.
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.
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.
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
Has anyone written the rationale on why the Rust logo shows up on projects that
aren't the standard library? If we turned it off on non-standard crates by
default, it would line wrap crate names a lot less often.
Or maybe we should encourage crate authors to include their own logo more
often? It certainly helps give people a better sense of "place."
I'm not sure of anything that directly follows up this one. Plenty of other
changes could be made to improve the layout, like
* coming up with a less cluttered way to do disclosure (there's a lot of `[-]`
on the page)
* doing a better job of separating lateral navigation (vec::Vec links to
vec::IntoIter) and the table of contents (vec::Vec links to vec::Vec::new)
* giving readers more control of how much rustdoc hows them, and giving doc
authors more control of how much it generates
* better search that reduces the need to browse
But those are mostly orthogonal, not future possibilities unlocked by this change.
2023-09-18 18:59:49 +00:00
|
|
|
// @matches 'foo/index.html' '//div[@class="sidebar-crate"]/h2/a' 'foo'
|
|
|
|
// @count 'foo/index.html' '//h2[@class="location"]' 0
|
2016-08-27 16:00:36 +00:00
|
|
|
|
|
|
|
// @matches 'foo/foo_mod/index.html' '//h1' 'Module foo::foo_mod'
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-07 00:48:24 +00:00
|
|
|
// @matches 'foo/foo_mod/index.html' '//h2[@class="location"]' 'Module foo_mod'
|
2016-08-27 16:00:36 +00:00
|
|
|
pub mod foo_mod {
|
|
|
|
pub struct __Thing {}
|
|
|
|
}
|
|
|
|
|
2020-09-01 21:12:52 +00:00
|
|
|
extern "C" {
|
2016-08-27 16:00:36 +00:00
|
|
|
// @matches 'foo/fn.foo_ffn.html' '//h1' 'Function foo::foo_ffn'
|
|
|
|
pub fn foo_ffn();
|
|
|
|
}
|
|
|
|
|
|
|
|
// @matches 'foo/fn.foo_fn.html' '//h1' 'Function foo::foo_fn'
|
|
|
|
pub fn foo_fn() {}
|
|
|
|
|
|
|
|
// @matches 'foo/trait.FooTrait.html' '//h1' 'Trait foo::FooTrait'
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-07 00:48:24 +00:00
|
|
|
// @matches 'foo/trait.FooTrait.html' '//h2[@class="location"]' 'FooTrait'
|
2016-08-27 16:00:36 +00:00
|
|
|
pub trait FooTrait {}
|
|
|
|
|
|
|
|
// @matches 'foo/struct.FooStruct.html' '//h1' 'Struct foo::FooStruct'
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-07 00:48:24 +00:00
|
|
|
// @matches 'foo/struct.FooStruct.html' '//h2[@class="location"]' 'FooStruct'
|
2016-08-27 16:00:36 +00:00
|
|
|
pub struct FooStruct;
|
|
|
|
|
|
|
|
// @matches 'foo/enum.FooEnum.html' '//h1' 'Enum foo::FooEnum'
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-07 00:48:24 +00:00
|
|
|
// @matches 'foo/enum.FooEnum.html' '//h2[@class="location"]' 'FooEnum'
|
2016-08-27 16:00:36 +00:00
|
|
|
pub enum FooEnum {}
|
|
|
|
|
2023-08-21 19:53:39 +00:00
|
|
|
// @matches 'foo/type.FooType.html' '//h1' 'Type Alias foo::FooType'
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-07 00:48:24 +00:00
|
|
|
// @matches 'foo/type.FooType.html' '//h2[@class="location"]' 'FooType'
|
2016-08-27 16:00:36 +00:00
|
|
|
pub type FooType = FooStruct;
|
|
|
|
|
|
|
|
// @matches 'foo/macro.foo_macro.html' '//h1' 'Macro foo::foo_macro'
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! foo_macro {
|
2020-09-01 21:12:52 +00:00
|
|
|
() => {};
|
2016-08-27 16:00:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// @matches 'foo/primitive.bool.html' '//h1' 'Primitive Type bool'
|
2023-03-21 15:44:06 +00:00
|
|
|
#[rustc_doc_primitive = "bool"]
|
2016-08-27 16:00:36 +00:00
|
|
|
mod bool {}
|
|
|
|
|
|
|
|
// @matches 'foo/static.FOO_STATIC.html' '//h1' 'Static foo::FOO_STATIC'
|
|
|
|
pub static FOO_STATIC: FooStruct = FooStruct;
|
|
|
|
|
2020-09-01 21:12:52 +00:00
|
|
|
extern "C" {
|
2016-08-27 16:00:36 +00:00
|
|
|
// @matches 'foo/static.FOO_FSTATIC.html' '//h1' 'Static foo::FOO_FSTATIC'
|
|
|
|
pub static FOO_FSTATIC: FooStruct;
|
|
|
|
}
|
|
|
|
|
|
|
|
// @matches 'foo/constant.FOO_CONSTANT.html' '//h1' 'Constant foo::FOO_CONSTANT'
|
|
|
|
pub const FOO_CONSTANT: FooStruct = FooStruct;
|