Commit Graph

6 Commits

Author SHA1 Message Date
laund f0dbbcc303 bsn: improve docs and add tests (#24464)
# Objective

Improve documentation of bevy_scene/bsn.

Rendered: https://share.yadamiel.com/docs/doc/bevy/scene/index.html

Closes: #24299
Closes: #24540
Closes: #24541

## Solution

This PR depends on/includes changes from 
- #24402

Docs changes (approx)

- removing confusing `Inheritance` concept in favour of caching
    - #24367
- fix now-changed syntax
    - #24367
- cleaning up the duplication between macro docs and module docs
- clean up the syntax snippet to be a single table
- a bunch of smaller fixes

## Testing

- `cargo doc -Zrustdoc-mergeable-info -p bevy_scene --lib` locally works
fine
- the other cargo doc command also works fine (see cargo.toml diff for
full command, its *ugh*)


## Todo
- [x] show how scenes actually get evaluated, not a full expansion but a
rough idea of it
- [ ] come up with something better for the macro inline docs than a
complex example macro call
- [x] probably remove the #24402 commits again, they're annoying to have
in the history

---------

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2026-06-08 22:44:03 +00:00
Mira e3b63dca7b Update trait tags for resources-as-components (#24222)
# Objective

Follow up on resources-as-components.
Update trait tags in rustdoc-generated documentation:
- do not add component tag on resources, as that's offers no new
information
- mark immutable resources as immutable, like with component trait

## Testing

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

## Showcase

Before:
<img width="323" height="72" alt="Screenshot_20260509_233133"
src="https://github.com/user-attachments/assets/b0448b13-3ce0-4c6e-8c3b-9e91a0ba521f"
/>
After: 
<img width="331" height="70" alt="Screenshot_20260509_233051"
src="https://github.com/user-attachments/assets/650d0adf-e075-4e67-98f0-41ac7bf30dfe"
/>
2026-05-13 05:46:41 +00:00
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