4 Commits

Author SHA1 Message Date
Doonv 16f622c739 Fix docs.rs extensions README providing invalid Cargo.toml snippet (#23578)
# Objective

The README in `docs-rs/` tells you to add this line to your
`Cargo.toml`:
```toml
[lints.rust]
unexpected_cfgs = { check-cfg = ['cfg(docsrs_dep)'] }
```

However this does not compile due to this error:
```
error: missing field `level`
  --> Cargo.toml:41:19
   |
41 | unexpected_cfgs = { check-cfg = ['cfg(docsrs_dep)'] }
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

## Solution

Looking at Bevy's own `Cargo.toml`, this lint is used with the `warn`
level.
```toml
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }
```

So I updated the docs.rs README to be the same.

## Testing

I copied and pasted the new snippet into my `Cargo.toml` and it worked.
2026-03-30 21:18:45 +00:00
Mira 78f36cf47c Trait tag for Message (#21462)
Found by JMS55:
> Hey, I think we regressed the doc labels
The tags that we have for events, components, resources, etc
They don't account for the message/event split

## Showcase

<img width="610" height="109" alt="Screenshot from 2025-10-08 18-50-30"
src="https://github.com/user-attachments/assets/1e605c09-575e-49a5-a92f-4024d82852be"
/>
<img width="613" height="106" alt="Screenshot from 2025-10-08 18-50-17"
src="https://github.com/user-attachments/assets/dc64d745-a3b8-4e29-bf0c-508ee829ec77"
/>
<img width="606" height="108" alt="Screenshot from 2025-10-08 18-48-58"
src="https://github.com/user-attachments/assets/dde2af49-9b54-4bbb-9ab3-fa66d699a28f"
/>
2025-10-08 18:17:45 +00:00
SpecificProtagonist d0caea0882 Relationship(…Target) html trait tag (#18140)
# Objective

Fixes #18117

These are component subtraits, but unlike for `Event` (before that bound
got removed) this still shows it as a component because it's actually
used as such.

## Testing

```sh
 RUSTDOCFLAGS="--html-after-content docs-rs/trait-tags.html --cfg docsrs_dep" RUSTFLAGS="--cfg docsrs_dep" cargo doc --no-deps --package bevy_ecs
```

---

## Showcase

![Screenshot from 2025-03-03
17-31-24](https://github.com/user-attachments/assets/4b152b3f-f9c3-4ee6-a3d4-ad10f09040b6)
2025-03-04 08:05:16 +00:00
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