Improve schedule note of .after/.before & encourage to use .chain ins… (#14986)

# Objective

- Fixes #14552 
- Make the current note of `before` and `after` understandable. 
- > The given set is not implicitly added to the schedule when this
system set is added.

## Solution

- Replace note in docs of [`after` and
`before`](https://docs.rs/bevy/latest/bevy/ecs/prelude/trait.IntoSystemConfigs.html#method.before)
- Note of after was removed completely, and links to `before`, because
they notes would be identical.
- Also encourage to use `.chain`, which is much simpler and safer to use

## Testing

- Checked the docs after running `cargo doc` and `cargo run -p ci --
lints`
- Are there any parts that need more testing?
- no need to test, but please review the text. If it is still including
the intended message and especially if its understandable.

---------

Co-authored-by: Jan Hohenheim <jan@hohenheim.ch>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
kivi 2024-09-14 23:03:21 +02:00 committed by GitHub
parent 70808af776
commit 3f425da66e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -311,8 +311,8 @@ where
/// If automatically inserting [`apply_deferred`](crate::schedule::apply_deferred) like /// If automatically inserting [`apply_deferred`](crate::schedule::apply_deferred) like
/// this isn't desired, use [`before_ignore_deferred`](Self::before_ignore_deferred) instead. /// this isn't desired, use [`before_ignore_deferred`](Self::before_ignore_deferred) instead.
/// ///
/// Note: The given set is not implicitly added to the schedule when this system set is added. /// Calling [`.chain`](Self::chain) is often more convenient and ensures that all systems are added to the schedule.
/// It is safe, but no dependencies will be created. /// Please check the [caveats section of `.after`](Self::after) for details.
fn before<M>(self, set: impl IntoSystemSet<M>) -> SystemConfigs { fn before<M>(self, set: impl IntoSystemSet<M>) -> SystemConfigs {
self.into_configs().before(set) self.into_configs().before(set)
} }
@ -323,8 +323,23 @@ where
/// If automatically inserting [`apply_deferred`](crate::schedule::apply_deferred) like /// If automatically inserting [`apply_deferred`](crate::schedule::apply_deferred) like
/// this isn't desired, use [`after_ignore_deferred`](Self::after_ignore_deferred) instead. /// this isn't desired, use [`after_ignore_deferred`](Self::after_ignore_deferred) instead.
/// ///
/// Note: The given set is not implicitly added to the schedule when this system set is added. /// Calling [`.chain`](Self::chain) is often more convenient and ensures that all systems are added to the schedule.
/// It is safe, but no dependencies will be created. ///
/// # Caveats
///
/// If you configure two [`System`]s like `(GameSystem::A).after(GameSystem::B)` or `(GameSystem::A).before(GameSystem::B)`, the `GameSystem::B` will not be automatically scheduled.
///
/// This means that the system `GameSystem::A` and the system or systems in `GameSystem::B` will run independently of each other if `GameSystem::B` was never explicitly scheduled with [`configure_sets`]
/// If that is the case, `.after`/`.before` will not provide the desired behaviour
/// and the systems can run in parallel or in any order determined by the scheduler.
/// Only use `after(GameSystem::B)` and `before(GameSystem::B)` when you know that `B` has already been scheduled for you,
/// e.g. when it was provided by Bevy or a third-party dependency,
/// or you manually scheduled it somewhere else in your app.
///
/// Another caveat is that if `GameSystem::B` is placed in a different schedule than `GameSystem::A`,
/// any ordering calls between them—whether using `.before`, `.after`, or `.chain`—will be silently ignored.
///
/// [`configure_sets`]: https://docs.rs/bevy/latest/bevy/app/struct.App.html#method.configure_sets
fn after<M>(self, set: impl IntoSystemSet<M>) -> SystemConfigs { fn after<M>(self, set: impl IntoSystemSet<M>) -> SystemConfigs {
self.into_configs().after(set) self.into_configs().after(set)
} }