Skip to content

[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

Closed
wants to merge 2 commits into from

Conversation

sdfgeoff
Copy link
Contributor

@sdfgeoff sdfgeoff commented Mar 4, 2021

This documents both the non-obvious interaction with non-explicit system ordering
and adds examples for Changed and Added. This likely closes #1551

@sdfgeoff sdfgeoff force-pushed the changed_documentation branch from ae4144b to 70ccc67 Compare March 4, 2021 20:02
@alice-i-cecile alice-i-cecile added C-Docs An addition or correction to our documentation A-ECS Entities, components, systems, and events labels Mar 4, 2021
@sdfgeoff
Copy link
Contributor Author

sdfgeoff commented Mar 4, 2021

Hmm, I'm not familiar enough with rustdoc to figure out how to make those examples pass CI. Can someone give me some pointers?

@Ratysz
Copy link
Contributor

Ratysz commented Mar 4, 2021

cargo test --doc in bevy_ecs directory.

Oh, I see what the issue is. I'm fairly sure you can't use bevy there because bevy_ecs does not depend on bevy; you should be able to import stuff from bevy_ecs and hide it from the doc with a #, like # use bevy_ecs::prelude::*;.

///
/// Example:
/// ```
/// use bevy::prelude::*;
Copy link
Member

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

Copy link
Contributor Author

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.

/// ```
/// use bevy::prelude::*;
///
/// fn print_moving_objects_system(query: Query<(Name,), (Mutated<Transform>,)>) {
Copy link
Member

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)
    }
}

Copy link
Contributor Author

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.......

@sdfgeoff sdfgeoff force-pushed the changed_documentation branch from 70ccc67 to 210f82a Compare March 4, 2021 20:42
@mockersf
Copy link
Member

mockersf commented Mar 4, 2021

also, #1525 is changing the location of those structs, let's see what gets merged first 😄

@mockersf
Copy link
Member

mockersf commented Mar 5, 2021

now defined here

@sdfgeoff sdfgeoff force-pushed the changed_documentation branch from 56efbd7 to 4b317e6 Compare March 5, 2021 21:40
@sdfgeoff
Copy link
Contributor Author

sdfgeoff commented Mar 5, 2021

Updated :)

@sdfgeoff sdfgeoff force-pushed the changed_documentation branch from 4b317e6 to 6488158 Compare March 5, 2021 21:43
@cart
Copy link
Member

cart commented Mar 6, 2021

bors r+

bors bot pushed a commit that referenced this pull request Mar 6, 2021
This documents both the non-obvious interaction with non-explicit system ordering
and adds examples for Changed and Added. This likely closes #1551
@bors
Copy link
Contributor

bors bot commented Mar 6, 2021

@bors bors bot changed the title Added documentation on the query filters [Merged by Bors] - Added documentation on the query filters Mar 6, 2021
@bors bors bot closed this Mar 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Docs An addition or correction to our documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ambiguous system order and Changed<Component>
5 participants