-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trait tags on docs.rs #17758
Trait tags on docs.rs #17758
Conversation
e7a11db
to
771f4fc
Compare
I love the end result. I'll let others chime in on the impl though. |
5631e4a
to
4076e8b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good! I'm not sure I like creating a new root-level folder, but there are no better alternatives right now. Thank you, this is really cool!
Co-authored-by: Carter Weinberg <[email protected]>
I considered putting it in Putting this in |
It should! In the future it may be worth combining a lot of the root folders we have into something like |
The entries in |
could you add the new flags to https://github.com/bevyengine/bevy/blob/main/.github/workflows/docs.yml#L64? |
Thanks, lost that change when splitting apart the PR. |
Objective
Bevy's ECS provides several core traits such as
Component
,SystemParam
, etc that determine where a type can be used. When reading the docs, this currently requires scrolling down to and scanning the "Trait Implementations" section. Make these core traits more visible.Solution
Add a color-coded labels below the type heading denoting the following types:
Component
Resource
Asset
Event
Plugin
&PluginGroup
ScheduleLabel
&SystemSet
SystemParam
As docs.rs does not provide an option for post-processing the html, these are added via JS with traits implementations being detected by scanning the DOM. Rustdoc's html output is unstable, which could potentially lead to this detection (or the adding of the labels) to break, however it only needs to work when a new release is deployed and falls back to the status quo of not displaying these labels.
Idea by JMS55, implementation by Jondolf (see https://github.com/Jondolf/bevy_docs_extension_demo/).
Testing
Run this in Bevy's root folder:
Showcase
Check it out on docs.rs
Release Notes
On docs.rs, Bevy now displays labels indicating which core traits a type implements:

If you want to add these to your own crate, check out these instructions.