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 17 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
11 changes: 8 additions & 3 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use bevy_utils::tracing::info_span;
#[allow(clippy::needless_doctest_main)]
/// Containers of app logic and data
///
/// App store the ECS World, Resources, Schedule, and Executor. They also store the "run" function
/// of the App, which by default executes the App schedule once. Apps are constructed using the
/// builder pattern.
/// Bundles together the necessary elements, like [`World`] and [`Schedule`], to create
/// an ECS based application. It also stores a pointer to a
Nilirad marked this conversation as resolved.
Show resolved Hide resolved
/// [runner function](AppBuilder::set_runner), which by default executes the App schedule
/// once. Apps are constructed with the builder pattern, using the [`AppBuilder`] struct.
///
/// ## Example
/// Here is a simple "Hello World" Bevy app:
Expand Down Expand Up @@ -50,10 +51,13 @@ fn run_once(mut app: App) {
}

impl App {
/// Returns an [`AppBuilder`] with a basic structure that can be configured further
/// to create an `App`.
pub fn build() -> AppBuilder {
AppBuilder::default()
}

/// Advances the execution of the [`Schedule`] by one cycle.
pub fn update(&mut self) {
#[cfg(feature = "trace")]
let bevy_frame_update_span = info_span!("frame");
Expand All @@ -62,6 +66,7 @@ impl App {
self.schedule.run(&mut self.world);
}

/// Calls the runner function of the `App`.
Nilirad marked this conversation as resolved.
Show resolved Hide resolved
pub fn run(mut self) {
#[cfg(feature = "trace")]
let bevy_app_run_span = info_span!("bevy_app");
Expand Down
116 changes: 83 additions & 33 deletions crates/bevy_app/src/app_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ use bevy_ecs::{
use bevy_utils::tracing::debug;
use std::{fmt::Debug, hash::Hash};

/// Configure [App]s using the builder pattern
/// Configure [`App`]s using the builder pattern.
pub struct AppBuilder {
/// The app being configured.
pub app: App,
}

Expand All @@ -43,18 +44,17 @@ impl Default for AppBuilder {
}

impl AppBuilder {
/// Returns an `AppBuilder` without any configuration.
///
/// For an `AppBuilder` with [default stages](AppBuilder::add_default_stages) included,
/// use `AppBuilder::default`.
pub fn empty() -> AppBuilder {
AppBuilder {
app: App::default(),
}
}

/// Start the application (through main runner)
///
/// Runs the application main loop.
///
/// Usually the main loop is handled by Bevy integrated plugins (`winit`), but
/// but one can also set the runner function through [`AppBuilder::set_runner`].
/// Starts the application by calling the app's [runner function](Self::set_runner).
///
/// ## Example
/// ```
Expand All @@ -70,24 +70,31 @@ impl AppBuilder {
app.run();
}

/// Returns a shared reference to the ECS [`World`] stored in the app.
pub fn world(&mut self) -> &World {
&self.app.world
}

/// Returns a unique, mutable reference to the ECS [`World`] stored in the app.
pub fn world_mut(&mut self) -> &mut World {
&mut self.app.world
}

/// Stores the given [`World`] as the app's world.
pub fn set_world(&mut self, world: World) -> &mut Self {
self.app.world = world;
self
}

/// Adds a [`Stage`] with the given `label` to the last position of the app's
/// [`Schedule`].
pub fn add_stage<S: Stage>(&mut self, label: impl StageLabel, stage: S) -> &mut Self {
self.app.schedule.add_stage(label, stage);
self
}

/// Adds a [`Stage`] with the given `label` to the app's [`Schedule`], located
/// immediately after the stage labeled by `target`.
pub fn add_stage_after<S: Stage>(
&mut self,
target: impl StageLabel,
Expand All @@ -98,6 +105,8 @@ impl AppBuilder {
self
}

/// Adds a [`Stage`] with the given `label` to the app's [`Schedule`], located
/// immediately before the stage labeled by `target`.
pub fn add_stage_before<S: Stage>(
&mut self,
target: impl StageLabel,
Expand All @@ -108,6 +117,8 @@ impl AppBuilder {
self
}

/// Adds a [`Stage`] with the given `label` to the last position of the
/// [startup schedule](Self::add_default_stages).
pub fn add_startup_stage<S: Stage>(&mut self, label: impl StageLabel, stage: S) -> &mut Self {
self.app
.schedule
Expand All @@ -117,6 +128,10 @@ impl AppBuilder {
self
}

/// Adds a [startup stage](Self::add_default_stages) with the given `label`, immediately
/// after the stage labeled by `target`.
///
/// The `target` label must refer to a stage inside the startup schedule.
pub fn add_startup_stage_after<S: Stage>(
&mut self,
target: impl StageLabel,
Expand All @@ -131,6 +146,10 @@ impl AppBuilder {
self
}

/// Adds a [startup stage](Self::add_default_stages) with the given `label`, immediately
/// before the stage labeled by `target`.
///
/// The `target` label must refer to a stage inside the startup schedule.
pub fn add_startup_stage_before<S: Stage>(
&mut self,
target: impl StageLabel,
Expand All @@ -145,6 +164,10 @@ impl AppBuilder {
self
}

/// Fetches the [`Stage`] of type `T` marked with `label` from the [`Schedule`], then
/// executes `func` using the stage as parameter.
Nilirad marked this conversation as resolved.
Show resolved Hide resolved
///
/// See [`Schedule::stage`] for more details.
pub fn stage<T: Stage, F: FnOnce(&mut T) -> &mut T>(
&mut self,
label: impl StageLabel,
Expand All @@ -154,17 +177,7 @@ impl AppBuilder {
self
}

/// Adds a system that runs every time `app.update()` is called by the runner
///
/// Systems are the main building block in the Bevy ECS app model. You can define
/// normal rust functions, and call `.system()` to make them be Bevy systems.
///
/// System functions can have parameters, through which one can query and
/// mutate Bevy ECS states.
/// See [The Bevy Book](https://bevyengine.org/learn/book/introduction/) for more information.
///
/// Systems are run in parallel, and the execution order is not deterministic.
/// If you want more fine-grained control for order, see [`AppBuilder::add_system_to_stage`].
/// Adds a system to the [update stage](Self::add_default_stages) of the app's [`Schedule`].
///
/// For adding a system that runs only at app startup, see [`AppBuilder::add_startup_system`].
///
Expand All @@ -184,10 +197,12 @@ impl AppBuilder {
self.add_system_to_stage(CoreStage::Update, system)
}

/// Adds a [`SystemSet`] to the [update stage](Self::add_default_stages).
pub fn add_system_set(&mut self, system_set: SystemSet) -> &mut Self {
self.add_system_set_to_stage(CoreStage::Update, system_set)
}

/// Adds a system to the [`Stage`] identified by `stage_label`.
pub fn add_system_to_stage(
&mut self,
stage_label: impl StageLabel,
Expand All @@ -197,6 +212,7 @@ impl AppBuilder {
self
}

/// Adds a [`SystemSet`] to the [`Stage`] identified by `stage_label`.
pub fn add_system_set_to_stage(
&mut self,
stage_label: impl StageLabel,
Expand All @@ -208,10 +224,7 @@ impl AppBuilder {
self
}

/// Adds a system that is run once at application startup
///
/// Startup systems run exactly once BEFORE all other systems. These are generally used for
/// app initialization code (ex: adding entities and resources).
/// Adds a system to the [startup stage](Self::add_default_stages) of the app's [`Schedule`].
///
/// * For adding a system that runs for every frame, see [`AppBuilder::add_system`].
/// * For adding a system to specific stage, see [`AppBuilder::add_system_to_stage`].
Expand All @@ -232,10 +245,15 @@ impl AppBuilder {
self.add_startup_system_to_stage(StartupStage::Startup, system)
}

/// Adds a [`SystemSet`] to the [startup stage](Self::add_default_stages)
pub fn add_startup_system_set(&mut self, system_set: SystemSet) -> &mut Self {
self.add_startup_system_set_to_stage(StartupStage::Startup, system_set)
}

/// Adds a system to the [startup schedule](Self::add_default_stages), in the stage
/// identified by `stage_label`.
///
/// `stage_label` must refer to a stage inside the startup schedule.
pub fn add_startup_system_to_stage(
&mut self,
stage_label: impl StageLabel,
Expand All @@ -249,6 +267,10 @@ impl AppBuilder {
self
}

/// Adds a [`SystemSet`] to the [startup schedule](Self::add_default_stages), in the stage
/// identified by `stage_label`.
///
/// `stage_label` must refer to a stage inside the startup schedule.
pub fn add_startup_system_set_to_stage(
&mut self,
stage_label: impl StageLabel,
Expand Down Expand Up @@ -287,6 +309,26 @@ impl AppBuilder {
.add_system_set_to_stage(stage, State::<T>::get_driver())
}

/// Adds utility stages to the [`Schedule`], giving it a standardized structure.
///
/// Adding those stages is necessary to make work some core engine features, like
Nilirad marked this conversation as resolved.
Show resolved Hide resolved
/// adding systems without specifying a stage, or registering events. This is however
/// done by default by calling `AppBuilder::default`, which is in turn called by
/// [`App::build`].
///
/// # The stages
///
/// All the added stages, with the exception of the startup stage, run every time the
/// schedule is invoked. The most relevant stages are the following, in order of execution:
Nilirad marked this conversation as resolved.
Show resolved Hide resolved
Nilirad marked this conversation as resolved.
Show resolved Hide resolved
/// - **First:** Runs at the very start of the schedule execution cycle, even before the
/// startup stage.
/// - **Startup:** It is actually a schedule containing sub-stages. Runs only once
Nilirad marked this conversation as resolved.
Show resolved Hide resolved
/// when the app starts.
/// - **Update:** Stage intended for user defined logic.
/// - **Last:** Runs right before the end of the schedule execution cycle.
///
/// The labels for those stages are defined in the [`CoreStage`] and [`StartupStage`]
/// `enum`s.
pub fn add_default_stages(&mut self) -> &mut Self {
self.add_stage(CoreStage::First, SystemStage::parallel())
.add_stage(
Expand Down Expand Up @@ -320,7 +362,7 @@ impl AppBuilder {
/// A resource in Bevy represents globally unique data. Resources must be added to Bevy Apps
/// before using them. This happens with [`AppBuilder::insert_resource`].
///
/// See also `init_resource` for resources that implement `Default` or [`FromResources`].
/// See also `init_resource` for resources that implement `Default` or `FromResources`.
///
/// ## Example
/// ```
Expand Down Expand Up @@ -365,9 +407,9 @@ impl AppBuilder {
self
}

/// Initialize a resource in the current [App], if it does not exist yet
/// Initialize a resource in the current [`App`], if it does not exist yet
///
/// Adds a resource that implements `Default` or [`FromResources`] trait.
/// Adds a resource that implements `Default` or `FromResources` trait.
/// If the resource already exists, `init_resource` does nothing.
Nilirad marked this conversation as resolved.
Show resolved Hide resolved
Nilirad marked this conversation as resolved.
Show resolved Hide resolved
///
/// ## Example
Expand Down Expand Up @@ -403,6 +445,10 @@ impl AppBuilder {
self
}

/// Initialize a non-send resource in the current [`App`], if it does not exist yet.
///
/// Adds a resource that implements `Default` or `FromResources` trait.
/// If the resource already exists, it does nothing.
Nilirad marked this conversation as resolved.
Show resolved Hide resolved
pub fn init_non_send_resource<R>(&mut self) -> &mut Self
where
R: FromWorld + 'static,
Expand All @@ -415,12 +461,14 @@ impl AppBuilder {
self
}

/// Sets the main runner loop function for this Bevy App
/// Sets the function that will be called when the app is run.
///
/// Usually the main loop is handled by Bevy integrated plugins ([`WinitPlugin`]), but
/// in some cases one might wish to implement their own main loop.
/// The runner function (`run_fn`) is called only once by [`AppBuilder::run`]. If the
/// presence of a main loop in the app is desired, it is responsibility of the runner
/// function to provide it.
///
/// This method sets the main loop function, overwriting a previous runner if any.
/// The runner function is usually not set manually, but by Bevy integrated plugins
/// (e.g. winit plugin).
///
/// ## Example
/// ```
Expand Down Expand Up @@ -531,17 +579,19 @@ impl AppBuilder {
self
}

/// Registers a new component using the given [ComponentDescriptor]. Components do not need to
/// be manually registered. This just provides a way to override default configuration.
/// Attempting to register a component with a type that has already been used by [World]
/// will result in an error.
/// Registers a new component using the given [ComponentDescriptor].
///
/// Components do not need to be manually registered. This just provides a way to
/// override default configuration. Attempting to register a component with a type
/// that has already been used by [World] will result in an error.
///
/// See [World::register_component]
pub fn register_component(&mut self, descriptor: ComponentDescriptor) -> &mut Self {
self.world_mut().register_component(descriptor).unwrap();
self
}

/// Adds the type `T` to the type registry resource.
Copy link
Member

Choose a reason for hiding this comment

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

An explanation of why you might want to do so would be appreciated.

IIRC it's used to enable reflection?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From a quick "find references" and git blame it looks like it's primarily, if not solely, used for reflection. I don't feel extremely confident about what to add since I never used reflection directly.

#[cfg(feature = "bevy_reflect")]
pub fn register_type<T: bevy_reflect::GetTypeRegistration>(&mut self) -> &mut Self {
{
Expand Down
7 changes: 6 additions & 1 deletion crates/bevy_app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,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 in more sub-stages defined in [`StartupStage`]. Systems added here are
Nilirad marked this conversation as resolved.
Show resolved Hide resolved
/// referred to as "startup systems".
Startup,
/// Name of app stage that runs before all other app stages
First,
Expand Down
24 changes: 24 additions & 0 deletions crates/bevy_ecs/src/entity/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
//! The handle to an object stored in a [`World`](crate::world::World).
//!
//! 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. As the
//! [book](#) explains, this is a fundamental design choice that has been made to increase
//! performance and usability.
//!
//! # Usage
//!
//! In the following list there are links to the methods used to perform common operations
Nilirad marked this conversation as resolved.
Show resolved Hide resolved
//! 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).
//! - **Adding multiple components to an entity:** use
//! [`EntityCommands::insert_bundle`](crate::system::EntityCommands::insert_bundle).
//! - **Despawning an entity:** use
//! [`EntityCommands::despawn`](crate::system::EntityCommands::despawn).
//! - **Inserting a component to an entity:** use
//! [`EntityCommands::insert`](crate::system::EntityCommands::insert).
//! - **Removing a component to an entity:** use
//! [`EntityCommands::remove`](crate::system::EntityCommands::remove).
mod map_entities;
mod serde;

Expand Down
Loading