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

[Merged by Bors] - Improve bevy_ecs and bevy_app API docs where referenced by the new Bevy Book #2365

Closed
wants to merge 151 commits into from
Closed
Show file tree
Hide file tree
Changes from 143 commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
4d1040a
Improve App docs
Nilirad Jun 20, 2021
54954bc
Move App doc example to AppBuilder
Nilirad Jun 20, 2021
6db1fce
Document App methods
Nilirad Jun 20, 2021
b7436de
Restore App example to original position
Nilirad Jun 20, 2021
71f4541
Clarify App::update method doc comment
Nilirad Jun 20, 2021
62258d4
Document AppBuilder fns and some relative items
Nilirad Jun 22, 2021
3d34f02
Add StartupStage enum link to add_default_stages
Nilirad Jun 23, 2021
ba27b4f
Correct enum keyword monospace text
Nilirad Jun 23, 2021
862ccb3
Add docs for mod system
Nilirad Jun 23, 2021
cfe0755
Point stage links to add_default_stages
Nilirad Jun 23, 2021
043b31a
Merge branch 'main' into api-docs-ch1
Nilirad Jun 23, 2021
c1fc50b
Update crates/bevy_ecs/src/system/mod.rs
Nilirad Jun 24, 2021
f29e769
Correct add_startup_system_to_stage docs
Nilirad Jun 24, 2021
7c66d20
Document new AppBuilder methods
Nilirad Jun 24, 2021
3f9d879
Remove incorrect references to StartupStage
Nilirad Jun 24, 2021
483f312
Add module-level documentation for entity
Nilirad Jun 25, 2021
dad4c5e
Improve sentence wording
Nilirad Jun 25, 2021
c693223
Query module-level documentation
Nilirad Jun 26, 2021
ac52aa3
Remove duplicate info on resource init methods
Nilirad Jun 26, 2021
2cc360c
Refactor Query docs in a more structured way
Nilirad Jun 26, 2021
16f9a87
Add `Added` and `Changed` filters
Nilirad Jun 26, 2021
307ea91
Add link to Query in mod query docs
Nilirad Jun 26, 2021
348985f
Add query iteration docs
Nilirad Jun 26, 2021
5676e45
FIx doctests
Nilirad Jun 26, 2021
7e11aa1
Fix link to Query
Nilirad Jun 26, 2021
2f8f7f9
Add list of system parameters
Nilirad Jun 27, 2021
94fee6c
Improve add_default_stages wording
Nilirad Jun 28, 2021
78ce084
Improve add_default_stages wording
Nilirad Jun 28, 2021
8f34675
Add Optional (Non)Send SystemParams
Nilirad Jun 28, 2021
7945a66
Merge branch 'main' into api-docs-ch1
Nilirad Jun 28, 2021
eaa4e72
Add SystemParam requirement
Nilirad Jul 2, 2021
f13dcb5
Add Schedule struct and module documentation
Nilirad Jul 2, 2021
d517f57
Link to Stage
Nilirad Jul 2, 2021
083adf0
Add brief description of Stage trait
Nilirad Jul 2, 2021
7610e8b
Add crate general info and module summaries
Nilirad Jul 4, 2021
bafbda6
Improve resource documentation
Nilirad Jul 4, 2021
a72840b
Merge branch 'bevyengine:main' into api-docs-ch1
Nilirad Jul 4, 2021
ba506b9
Yeet .system() from resource doctest
Nilirad Jul 5, 2021
132043e
Remove unnecessary comma
Nilirad Jul 5, 2021
54aa4ef
Improve Bundle docs
Nilirad Jul 5, 2021
c7cdfd0
Add dash in ECS-based
Nilirad Jul 6, 2021
79ce84d
Fix grammar
Nilirad Jul 6, 2021
8b16e36
Improve WithBundle docs
Nilirad Jul 6, 2021
70373f7
Improve sentence conciseness
Nilirad Jul 6, 2021
58e1d30
Improve entity use-case list order
Nilirad Jul 6, 2021
2a9369a
Improve grammar
Nilirad Jul 6, 2021
681e2e9
Improve grammar
Nilirad Jul 6, 2021
5b8c8e9
Improve query filter list header
Nilirad Jul 6, 2021
0e1328d
Improve App::run docs
Nilirad Jul 6, 2021
5600265
Describe default behavior of init_resource
Nilirad Jul 6, 2021
db34dd4
Specify that Schedule stages run in linear order
Nilirad Jul 6, 2021
0aa09d7
uwu
Nilirad Jul 6, 2021
647c322
Invert sentence for query single component access
Nilirad Jul 7, 2021
5363519
Add multiple query filters example
Nilirad Jul 7, 2021
cc92352
Change Schedule to Stage in schedule mod docs
Nilirad Jul 7, 2021
5fa6f0a
Separate resource from Component
Nilirad Jul 7, 2021
4856db0
Merge branch 'bevyengine:main' into api-docs-ch1
Nilirad Jul 7, 2021
171b0a2
Add usefulness of nested Schedules
Nilirad Jul 8, 2021
26794d9
Merge branch 'api-docs-ch1' of github.com:Nilirad/bevy into api-docs-ch1
Nilirad Jul 8, 2021
84e78f2
Change "update" to "my_stage" in example
Nilirad Jul 8, 2021
549db69
Enumerate default stages
Nilirad Jul 8, 2021
565a69a
Correct concurrent mutable component access
Nilirad Jul 8, 2021
a9bc51e
Fix typo
Nilirad Jul 11, 2021
2eb507a
Correct query concurrent mutable access
Nilirad Jul 11, 2021
0026994
Clarify use of `func` parameter
Nilirad Jul 11, 2021
bf94f67
Update query mutable component access descriptions
Nilirad Jul 11, 2021
9059588
Update mod system docs
Nilirad Jul 15, 2021
9d334e8
Add examples to AppBuilder methods
Nilirad Jul 15, 2021
ef830b6
Merge branch 'bevyengine:main' into api-docs-ch1
Nilirad Jul 16, 2021
696bbb4
Fix scheduler typo
Nilirad Jul 16, 2021
76ab530
Improve query result usage
Nilirad Jul 16, 2021
a705bfe
Remove code block for type parameters of Query
Nilirad Jul 16, 2021
9bb6e1c
Use a more specific Query summary description
Nilirad Jul 16, 2021
9482315
Define "query result"
Nilirad Jul 16, 2021
86dd7f7
Avoid using "contemporarily"
Nilirad Jul 16, 2021
eea7f53
Query system parameter usage intro
Nilirad Jul 16, 2021
20581b7
Merge branch 'api-docs-ch1' of github.com:Nilirad/bevy into api-docs-ch1
Nilirad Jul 16, 2021
fc52b1b
Add examples to Query iter and iter_mut methods
Nilirad Jul 16, 2021
6254589
Remove Res<Time> from Query::iter_mut example
Nilirad Jul 17, 2021
293702d
Fix mod system doctest
Nilirad Jul 17, 2021
7b2a818
General Query docs improvements
Nilirad Jul 17, 2021
5d15897
Add Query methods docs
Nilirad Jul 17, 2021
4ac95eb
Improve wording
Nilirad Jul 17, 2021
8972641
Add example to Query::get
Nilirad Jul 17, 2021
865d722
Rename Target to Winner
Nilirad Jul 18, 2021
9319ced
Rename Target to Winner, part 2
Nilirad Jul 18, 2021
4594d13
Add third person "s" verb suffix
Nilirad Jul 18, 2021
933cc9f
Add Query::get_component example
Nilirad Jul 18, 2021
0bdc8ab
Use a more concise example for Query::get
Nilirad Jul 18, 2021
57333e0
Add example to Query::get_component_mut
Nilirad Jul 18, 2021
6c82809
Add example for Query::get_mut
Nilirad Jul 18, 2021
14155ce
Add .system() to check examples' SystemParams
Nilirad Jul 18, 2021
33c8a1c
Add example to Query::is_empty
Nilirad Jul 18, 2021
c68dd21
Update examples for Query::{single, single_mut}
Nilirad Jul 18, 2021
d88b46a
Query: use "Returns" instead of "Gets"
Nilirad Jul 18, 2021
c0eddb6
Add error case info for Query methods
Nilirad Jul 18, 2021
b7ae0c7
Link to `SystemParam`
Nilirad Jul 21, 2021
96a63aa
Add metadata notes to some `SystemParam`s in list
Nilirad Jul 21, 2021
8c66a92
Improve `WithBundle` summary
Nilirad Jul 21, 2021
f3cedeb
Listify safety notes for `Bundle`
Nilirad Jul 21, 2021
eda2f90
Reference example on top for `AppBuilder::run`
Nilirad Jul 21, 2021
788a817
Improve wording
Nilirad Jul 21, 2021
358f825
Remove "most relevant"
Nilirad Jul 21, 2021
7d3d8ce
Expand mutable query guidelines
Nilirad Jul 21, 2021
8a4c679
Remove empty code block
Nilirad Jul 23, 2021
5bd7d6a
Merge branch 'api-docs-ch1' of github.com:Nilirad/bevy into api-docs-ch1
Nilirad Jul 23, 2021
26aaade
Add `Commands` method examples
Nilirad Jul 24, 2021
3372b7b
Add `EntityCommands` method examples
Nilirad Jul 25, 2021
fad5a32
hi
Nilirad Jul 25, 2021
208377e
Merge branch 'main' of https://github.com/bevyengine/bevy into bevyen…
Nilirad Jul 25, 2021
b9b33b5
Merge branch 'bevyengine-main' into api-docs-ch1
Nilirad Jul 25, 2021
e2bea20
Apply suggestions
Nilirad Jul 26, 2021
6395011
Misc improvements
Nilirad Jul 26, 2021
230eff1
Merge branch 'bevyengine:main' into api-docs-ch1
Nilirad Jul 27, 2021
34b68b3
Update `WithBundle` description
Nilirad Jul 27, 2021
50fb8c9
Resolve conflicts caused by app_builder.rs removal
Nilirad Jul 28, 2021
0501747
Merge branch 'bevyengine-main' into api-docs-ch1
Nilirad Jul 28, 2021
ad87266
Fix doctests and remove refs to `AppBuilder`
Nilirad Jul 28, 2021
85caa4b
Resolve merge conflicts
Nilirad Aug 1, 2021
3d9a857
Merge branch 'bevyengine-main' into api-docs-ch1
Nilirad Aug 1, 2021
090e923
Add examples to `Schedule` methods
Nilirad Aug 1, 2021
779e983
Include `REAME.md` as `bevy_ecs` crate level docs
Nilirad Aug 1, 2021
32c20be
Remove newline
Nilirad Aug 1, 2021
de82c53
return -> yield
Nilirad Aug 1, 2021
acaefb4
Style
Nilirad Aug 1, 2021
61395f7
Entity: handle -> ID
Nilirad Aug 1, 2021
bdfe0c2
Entity ID
Nilirad Aug 1, 2021
cd2b9ba
Add context to some `Query` method examples
Nilirad Aug 1, 2021
6d30e1d
wow
Nilirad Aug 1, 2021
4d39725
Unit `Bundle` is not a thing
Nilirad Aug 1, 2021
e9b22fa
Correct mod `archetype` summary
Nilirad Aug 1, 2021
8ebf116
Remove indent for code surrounded by hidden code
Nilirad Aug 1, 2021
5e1bac1
README docs breaks doctest suite
Nilirad Aug 1, 2021
b490df7
Apply suggestion
Nilirad Aug 1, 2021
bc6ef67
Unit `Bundle` is actually a thing
Nilirad Aug 1, 2021
ebbc6d2
Add newline after //! blocks on top of files
Nilirad Aug 1, 2021
96ff662
Remove ECS crate level docs as done by #2575
Nilirad Aug 7, 2021
50578d7
Add brief crate summary doc comment for `bevy_app`
Nilirad Aug 7, 2021
637beb0
Merge branch 'main' of https://github.com/bevyengine/bevy into bevyen…
Nilirad Aug 18, 2021
109c08f
Remove references to removed `WithBundle` filter
Nilirad Aug 18, 2021
762be6c
Merge branch 'bevyengine-main' into api-docs-ch1
Nilirad Aug 18, 2021
0136659
Merge branch 'main' into api-docs-ch1
Nilirad Aug 27, 2021
b5bb71a
Merge branch 'bevyengine:main' into api-docs-ch1
Nilirad Sep 5, 2021
1e6a53e
Resolve merge conflicts
Nilirad Sep 13, 2021
0997fe4
Merge branch 'bevyengine-main' into api-docs-ch1
Nilirad Sep 13, 2021
d740a96
fix
Nilirad Sep 13, 2021
757aa22
Fix doc warnings
Nilirad Sep 14, 2021
37b5b40
Resolve merge conflicts
Nilirad Sep 15, 2021
49f8e3d
Merge branch 'bevyengine-main' into api-docs-ch1
Nilirad Sep 15, 2021
f0ef44c
Apply review suggestions, part 1
Nilirad Sep 17, 2021
4c88e01
Move `.spawn().insert_bundle` alternative to `spawn`
Nilirad Sep 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
372 changes: 315 additions & 57 deletions crates/bevy_app/src/app.rs

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion crates/bevy_app/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! This crate is about everything concerning the highest-level, application layer of a Bevy
//! app.

mod app;
mod plugin;
mod plugin_group;
Expand All @@ -21,9 +24,14 @@ pub mod prelude {
use bevy_ecs::schedule::StageLabel;

/// The names of the default App stages
///
/// The relative stages are added by [`AppBuilder::add_default_stages`].
#[derive(Debug, Hash, PartialEq, Eq, Clone, StageLabel)]
pub enum CoreStage {
/// Runs once at the beginning of the app.
/// Runs only once at the beginning of the app.
///
/// Consists of the sub-stages defined in [`StartupStage`]. Systems added here are
/// referred to as "startup systems".
Startup,
/// Name of app stage that runs before all other app stages
First,
Expand Down
3 changes: 3 additions & 0 deletions crates/bevy_ecs/src/archetype.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! Types for defining [`Archetype`]s, collections of entities that have the same set of
//! components.

use crate::{
bundle::BundleId,
component::{ComponentId, StorageType},
Expand Down
46 changes: 35 additions & 11 deletions crates/bevy_ecs/src/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! Types for handling [`Bundle`]s.
//!
//! This module contains the `Bundle` trait and some other helper types.

pub use bevy_ecs_macros::Bundle;

use crate::{
Expand All @@ -9,15 +13,35 @@ use crate::{
use bevy_ecs_macros::all_tuples;
use std::{any::TypeId, collections::HashMap};

/// An ordered collection of components, commonly used for spawning entities, and adding and
/// removing components in bulk.
/// An ordered collection of components.
///
/// Commonly used for spawning entities and adding and removing components in bulk. This
/// trait is automatically implemented for tuples of components: `(ComponentA, ComponentB)`
/// is a very convenient shorthand when working with one-off collections of components. Note
/// that both the unit type `()` and `(ComponentA, )` are valid bundles. The unit bundle is
/// particularly useful for spawning multiple empty entities by using
/// [`Commands::spawn_batch`](bevy_ecs::system::Commands::spawn_batch).
///
/// # Examples
///
/// Typically, you will simply use `#[derive(Bundle)]` when creating your own `Bundle`. Each
/// struct field is a component:
///
/// Typically, you will simply use `#[derive(Bundle)]` when creating your own `Bundle`.
/// The `Bundle` trait is automatically implemented for tuples of components:
/// `(ComponentA, ComponentB)` is a very convenient shorthand when working with one-off collections
/// of components. Note that both `()` and `(ComponentA, )` are valid tuples.
/// ```
/// # use bevy_ecs::prelude::*;
/// # struct ComponentA;
/// # struct ComponentB;
/// # struct ComponentC;
/// #
/// #[derive(Bundle)]
/// struct MyBundle {
/// a: ComponentA,
/// b: ComponentB,
/// c: ComponentC,
/// }
/// ```
///
/// You can nest bundles like so:
/// You can nest bundles using the `#[bundle]` attribute:
/// ```
/// # use bevy_ecs::bundle::Bundle;
///
Expand All @@ -36,10 +60,10 @@ use std::{any::TypeId, collections::HashMap};
/// ```
///
/// # Safety
/// [Bundle::component_id] must return the ComponentId for each component type in the bundle, in the
/// _exact_ order that [Bundle::get_components] is called.
/// [Bundle::from_components] must call `func` exactly once for each [ComponentId] returned by
/// [Bundle::component_id]
/// - [Bundle::component_id] must return the ComponentId for each component type in the bundle, in the
/// _exact_ order that [Bundle::get_components] is called.
/// - [Bundle::from_components] must call `func` exactly once for each [ComponentId] returned by
/// [Bundle::component_id]
pub unsafe trait Bundle: Send + Sync + 'static {
/// Gets this [Bundle]'s component ids, in the order of this bundle's Components
fn component_ids(components: &mut Components) -> Vec<ComponentId>;
Expand Down
6 changes: 6 additions & 0 deletions crates/bevy_ecs/src/change_detection.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Types that detect when their internal data mutate.

use crate::component::{Component, ComponentTicks};
use bevy_reflect::Reflect;
use std::ops::{Deref, DerefMut};
Expand Down Expand Up @@ -136,6 +138,10 @@ pub(crate) struct Ticks<'a> {

/// Unique mutable borrow of a resource.
///
/// See the [`World`](crate::world::World) documentation to see the usage of a resource.
///
/// If you need a shared borrow, use [`Res`](crate::system::Res) instead.
///
/// # Panics
///
/// Panics when used as a [`SystemParameter`](crate::system::SystemParam) if the resource does not exist.
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_ecs/src/component.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Types for declaring and storing [`Component`]s.

use crate::storage::SparseSetIndex;
use std::{
alloc::Layout,
Expand Down
23 changes: 23 additions & 0 deletions crates/bevy_ecs/src/entity/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
//! Entity handling types.
//!
//! In Bevy ECS, there is no monolithic data structure for an entity. Instead, the [`Entity`]
//! `struct` is just an identification number that [`Component`s](crate::component::Component)
Nilirad marked this conversation as resolved.
Show resolved Hide resolved
//! can refer to in order to attach meaningful data to it. This is a fundamental design choice
//! that has been taken to enhance performance and usability.
//!
//! # Usage
//!
//! Here are links to the methods used to perform common operations
//! involving entities:
//!
//! - **Spawning an empty entity:** use [`Commands::spawn`](crate::system::Commands::spawn).
Nilirad marked this conversation as resolved.
Show resolved Hide resolved
//! - **Spawning an entity with components:** use
//! [`Commands::spawn_bundle`](crate::system::Commands::spawn_bundle).
//! - **Despawning an entity:** use
//! [`EntityCommands::despawn`](crate::system::EntityCommands::despawn).
//! - **Inserting a component to an entity:** use
//! [`EntityCommands::insert`](crate::system::EntityCommands::insert).
//! - **Adding multiple components to an entity:** use
//! [`EntityCommands::insert_bundle`](crate::system::EntityCommands::insert_bundle).
//! - **Removing a component to an entity:** use
//! [`EntityCommands::remove`](crate::system::EntityCommands::remove).
mod map_entities;
mod serde;

Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_ecs/src/event.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Event handling types.

use crate as bevy_ecs;
use crate::{
component::Component,
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_ecs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub mod storage;
pub mod system;
pub mod world;

/// Most commonly used re-exported types.
pub mod prelude {
#[doc(hidden)]
#[cfg(feature = "bevy_reflect")]
Expand Down
11 changes: 11 additions & 0 deletions crates/bevy_ecs/src/query/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
//! Helper types for [`Query`](crate::system::Query).
Nilirad marked this conversation as resolved.
Show resolved Hide resolved
//!
//! # Query filters
//! Query filters restrict query results by filtering out entities that do not meet the criteria. The following is a full list of filters:
//!
//! - [`Added`]
//! - [`Changed`]
//! - [`With`]
//! - [`Without`]
//! - [`Or`]

mod access;
mod fetch;
mod filter;
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_ecs/src/reflect.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Types that enable reflection support.

pub use crate::change_detection::ReflectMut;
use crate::{
component::Component,
Expand Down
Loading