-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[Merged by Bors] - Added documentation on the query filters #1553
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
Conversation
ae4144b
to
70ccc67
Compare
Hmm, I'm not familiar enough with rustdoc to figure out how to make those examples pass CI. Can someone give me some pointers? |
Oh, I see what the issue is. I'm fairly sure you can't use |
crates/bevy_ecs/src/core/filter.rs
Outdated
/// | ||
/// Example: | ||
/// ``` | ||
/// use bevy::prelude::*; |
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.
you can't use use bevy::prelude::*;
from inside bevy_ecs
, you will need to use a more direct path to the struct you want to use... and as bevy_ecs
is one of the core crate, you don't have access to a lot of stuff without adding dev dependencies.
Mutated
, Added
and Changed
should be reachable as they are defined here, but you can't use Name
or Transform
. Simplest solution would probably to create struct in the doc example and have them hidden, see https://doc.rust-lang.org/rustdoc/documentation-tests.html#hiding-portions-of-the-example
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.
Thanks for the review! Yup, I've got the examples compiling by using bevy_ecs::
and hiding some structs.
crates/bevy_ecs/src/core/filter.rs
Outdated
/// ``` | ||
/// use bevy::prelude::*; | ||
/// | ||
/// fn print_moving_objects_system(query: Query<(Name,), (Mutated<Transform>,)>) { |
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.
no need to wrap the types in tuples, you can have
fn print_moving_objects_system(query: Query<Name, Mutated<Transform>>) {
for name in query.iter() {
println!("Entity Moved: {}", name)
}
}
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.
Cool! I didn't know that, I've been putting all my queries in tuples.......
70ccc67
to
210f82a
Compare
also, #1525 is changing the location of those structs, let's see what gets merged first 😄 |
now defined here |
56efbd7
to
4b317e6
Compare
Updated :) |
…with system ordering
4b317e6
to
6488158
Compare
…ormance enhancement
bors r+ |
This documents both the non-obvious interaction with non-explicit system ordering and adds examples for Changed and Added. This likely closes #1551
Pull request successfully merged into main. Build succeeded: |
This documents both the non-obvious interaction with non-explicit system ordering
and adds examples for Changed and Added. This likely closes #1551