bevy/.github/workflows
SpecificProtagonist 5b0d898866
Trait tags on docs.rs (#17758)
# 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`
  - immutable components are labeled as such
- `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:
```bash
 RUSTDOCFLAGS="--html-after-content docs-rs/trait-tags.html --cfg docsrs_dep" RUSTFLAGS="--cfg docsrs_dep" cargo doc --no-deps -p <some_bevy_package>
```

---

## Showcase
Check it out on
[docs.rs](https://docs.rs/bevy_docs_extension_demo/0.1.1/bevy_docs_extension_demo/struct.TestAllTraits.html)

![trait
tags](https://github.com/user-attachments/assets/a30d8324-41fd-432a-8e49-6d475f143725)

## Release Notes

On docs.rs, Bevy now displays labels indicating which core traits a type
implements:
![trait tags
small](https://github.com/user-attachments/assets/c69b565f-e4bc-4277-9f6b-40830031077d)

If you want to add these to your own crate, check out [these
instructions](https://github.com/bevyengine/bevy/blob/main/docs-rs#3rd-party-crates).

---------

Co-authored-by: Joona Aalto <jondolf.dev@gmail.com>
Co-authored-by: Carter Weinberg <weinbergcarter@gmail.com>
2025-02-11 22:13:38 +00:00
..
action-on-PR-labeled.yml Update label used for breaking changes (#15958) 2024-10-16 17:50:39 +00:00
ci-comment-failures.yml screenshot comparison: fix upload for macOS... again (#15914) 2024-10-14 23:20:56 +00:00
ci.yml Bump crate-ci/typos from 1.29.4 to 1.29.5 (#17655) 2025-02-03 07:36:25 +00:00
dependencies.yml add cancel in progress support to automated CI checks (#11130) 2024-02-28 16:07:29 +00:00
docs.yml Trait tags on docs.rs (#17758) 2025-02-11 22:13:38 +00:00
post-release.yml Fix workflows for version bump (#17162) 2025-01-05 20:27:58 +00:00
send-screenshots-to-pixeleagle.yml Show working urls to screenshot comparisons in output (#17125) 2025-01-03 17:38:12 +00:00
validation-jobs.yml run example in CI on windows using static dxc (#17783) 2025-02-10 22:35:41 +00:00
weekly.yml Tiny ci improvements (#17627) 2025-02-02 06:32:07 +00:00
welcome.yml Fix Welcome Contributors CI (#15123) 2024-09-09 17:52:11 +00:00