Skip to content
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

Improve query API docs #4989

Closed
wants to merge 23 commits into from
Closed

Improve query API docs #4989

wants to merge 23 commits into from

Conversation

Nilirad
Copy link
Contributor

@Nilirad Nilirad commented Jun 11, 2022

Objective

Solution

Documentation has been changed for the following items:

  • Query (item level and methods)
  • QueryCombinationIter
  • WorldQuery trait
  • WorldQuery macro

Query

  • Introduction has been redone.
  • “Renamed” type parameters to reflect their purpose.
  • Examples for declaration idioms have been simplified and reordered.
  • “Query result” terminology has been changed to “query item”, which is more in line with the underlying types and with general terminology.
  • Query methods: structure has been made consistent, old notes about query being able to access certain methods based on mutability have been updated and centralized to the item level.
  • A tables has been added to navigate the safe methods.
  • A performance section has been added, notably with a table with big O computational complexity.

QueryCombinationIter

  • Moved stuff about QueryCombinationIter from Query methods to the item itself.

WorldQuery trait

  • Introduction has been tidied up
  • Macro usage moved to macro item, with a link in the original place.

WorldQuery macro

  • Removed foobar terminology in favor of more recognizable identifiers (ComponentA, my_system). Examples with concrete identifiers are used where appropriate.
  • Removed “Ignored fields” section on WorldQuery macro.
  • Examples split by use case.

Additional notes

  • I had to add bevy_ecs as a dev-dependency of bevy_ecs_macros to make doctests compile. Discussion on this is appreciated. I'm putting S-Controversial for now until a collective decision can be made. Solved.
  • Query and WorldQuery macro idioms should be in the book, but in the meantime they can stay here.
  • I don't know what the computational complexity for many_iter and many_for_each_mut is, so I added a placeholder for now. Solved.
  • Consider removing the #[world_query(ignore)] feature, as it is no longer needed.
  • Please review by checking the rendered docs (cargo doc -p bevy_ecs --no-deps --open).
  • Suggestions on improving examples by making them simpler or more concrete (where applicable) are appreciated.

Todo list:

  • Resolve the dev-dependency dilemma
  • Write the computational complexity for many_iter and many_for_each_mut

@Nilirad Nilirad added C-Docs An addition or correction to our documentation A-ECS Entities, components, systems, and events X-Controversial There is active debate or serious implications around merging this PR labels Jun 11, 2022
@alice-i-cecile alice-i-cecile self-requested a review June 11, 2022 16:29
@tim-blackbird
Copy link
Contributor

tim-blackbird commented Jun 11, 2022

many_iter and many_for_each_mut essentially amount to a bunch of Query::get's with slightly reduced overhead.
Since Query::get is O(1) the complexity should be O(n) where n is the number of entities provided.

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the consistency this adds, and the language changes are good. There's a few things to clean up. Not sure if / how we can resolve the dev-dependency problem; I'd probably just revert that and merge it without links for now :(

@Nilirad Nilirad removed the X-Controversial There is active debate or serious implications around merging this PR label Jun 12, 2022
@Nilirad
Copy link
Contributor Author

Nilirad commented Jun 12, 2022

I moved back the macro docs to the WorldQuery trait and restored changes to bevy_ecs_macros from the main branch.

I also removed the S-Controversial label.

crates/bevy_ecs/src/query/fetch.rs Outdated Show resolved Hide resolved
crates/bevy_ecs/src/query/fetch.rs Outdated Show resolved Hide resolved
crates/bevy_ecs/src/query/iter.rs Outdated Show resolved Hide resolved
crates/bevy_ecs/src/system/query.rs Outdated Show resolved Hide resolved
@Nilirad
Copy link
Contributor Author

Nilirad commented Jun 16, 2022

Squashed because rebasing in multiple steps is a headache.

I preserved co-authors in the commit message.

crates/bevy_ecs/src/query/fetch.rs Outdated Show resolved Hide resolved
crates/bevy_ecs/src/system/query.rs Outdated Show resolved Hide resolved
crates/bevy_ecs/src/system/query.rs Outdated Show resolved Hide resolved
crates/bevy_ecs/src/system/query.rs Show resolved Hide resolved
crates/bevy_ecs/src/system/query.rs Show resolved Hide resolved
crates/bevy_ecs/src/system/query.rs Outdated Show resolved Hide resolved
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jul 2, 2022
@james7132 james7132 removed the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jul 3, 2022
@Nilirad
Copy link
Contributor Author

Nilirad commented Jul 31, 2022

Rebased. I also pushed new commits. The first of the new commits is 5b064a2.

Copy link
Contributor

@rparrett rparrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't have time to look this over this morning, but I did a quick pass with the spell-checker.

crates/bevy_ecs/src/system/query.rs Outdated Show resolved Hide resolved
crates/bevy_ecs/src/system/query.rs Outdated Show resolved Hide resolved
@alice-i-cecile alice-i-cecile self-requested a review July 31, 2022 20:40
@nicopap nicopap added this to the Bevy 0.8.1 milestone Aug 1, 2022
@rparrett
Copy link
Contributor

rparrett commented Aug 4, 2022

Curious about the motivation behind

Moved stuff about QueryCombinationIter from Query methods to the item itself.

The general pattern in rust docs seems to be for the Iteratorish type to point to docs in the methods that create them. QueryIter and QueryManyIter seem to follow that pattern as well.

@alice-i-cecile
Copy link
Member

Ping @BoxyUwU for docs review following your WorldQuery changes.

@BoxyUwU
Copy link
Member

BoxyUwU commented Aug 8, 2022

Generally what happend in that PR is that all of the traits were merged into WorldQuery. So anything talking about Fetch::foo or FetchState::foo now should talk about WorldQuery::foo

crates/bevy_ecs/src/query/fetch.rs Outdated Show resolved Hide resolved
crates/bevy_ecs/src/query/fetch.rs Outdated Show resolved Hide resolved
crates/bevy_ecs/src/query/fetch.rs Outdated Show resolved Hide resolved
@Nilirad
Copy link
Contributor Author

Nilirad commented Aug 8, 2022

Thanks!!

@Nilirad
Copy link
Contributor Author

Nilirad commented Aug 19, 2022

@Nilirad Nilirad closed this Aug 19, 2022
bors bot pushed a commit that referenced this pull request Aug 30, 2022
# Objective

- Document `QueryCombinationIter`

## Solution

- Describe the item, add usage and examples
- Copy notes about the number of query items generated from the corresponding query methods (they will be removed in #5742 ([motivation]))

## Additional notes

- Derived from #4989 

[motivation]: #4989 (comment)
bors bot pushed a commit that referenced this pull request Sep 2, 2022
# Objective

- Update docs to `WorldQuery`

## Solution

- See #4989. This PR is derived from it, and limited to the `WorldQuery` item docs.
bors bot pushed a commit that referenced this pull request Sep 2, 2022
# Objective

- Update `Query` docs with better terminology
- add some performance remarks (Fixes #4742)

## Solution

- See #4989. This PR is derived from it. It just includes changes to the `Query` struct docs.
bors bot pushed a commit that referenced this pull request Sep 2, 2022
# Objective

- Increase consistency across documentation of `Query` methods.
- Fixes #5506

## Solution

- See #4989. This PR is derived from it. It just includes changes to the `Query` methods' docs.
bors bot pushed a commit that referenced this pull request Sep 2, 2022
# Objective

- Increase consistency across documentation of `Query` methods.
- Fixes #5506

## Solution

- See #4989. This PR is derived from it. It just includes changes to the `Query` methods' docs.
james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 28, 2022
# Objective

- Document `QueryCombinationIter`

## Solution

- Describe the item, add usage and examples
- Copy notes about the number of query items generated from the corresponding query methods (they will be removed in bevyengine#5742 ([motivation]))

## Additional notes

- Derived from bevyengine#4989 

[motivation]: bevyengine#4989 (comment)
james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 28, 2022
# Objective

- Update docs to `WorldQuery`

## Solution

- See bevyengine#4989. This PR is derived from it, and limited to the `WorldQuery` item docs.
james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 28, 2022
# Objective

- Update `Query` docs with better terminology
- add some performance remarks (Fixes bevyengine#4742)

## Solution

- See bevyengine#4989. This PR is derived from it. It just includes changes to the `Query` struct docs.
james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 28, 2022
# Objective

- Increase consistency across documentation of `Query` methods.
- Fixes bevyengine#5506

## Solution

- See bevyengine#4989. This PR is derived from it. It just includes changes to the `Query` methods' docs.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

- Document `QueryCombinationIter`

## Solution

- Describe the item, add usage and examples
- Copy notes about the number of query items generated from the corresponding query methods (they will be removed in bevyengine#5742 ([motivation]))

## Additional notes

- Derived from bevyengine#4989 

[motivation]: bevyengine#4989 (comment)
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

- Update docs to `WorldQuery`

## Solution

- See bevyengine#4989. This PR is derived from it, and limited to the `WorldQuery` item docs.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

- Update `Query` docs with better terminology
- add some performance remarks (Fixes bevyengine#4742)

## Solution

- See bevyengine#4989. This PR is derived from it. It just includes changes to the `Query` struct docs.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

- Increase consistency across documentation of `Query` methods.
- Fixes bevyengine#5506

## Solution

- See bevyengine#4989. This PR is derived from it. It just includes changes to the `Query` methods' docs.
@Nilirad Nilirad deleted the query_docs branch December 5, 2023 18:05
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
10 participants