mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Add missing closing ticks for inline examples and some cleanup (#3573)
# Objective - clean up documentation and inline examples ## Solution - add missing closing "```" - remove stray "```" - remove whitespace in inline examples - unify inline examples (remove some `rust` labels)
This commit is contained in:
parent
015da72250
commit
fbab01a40d
9 changed files with 17 additions and 15 deletions
|
@ -36,7 +36,7 @@
|
||||||
//! Manually enabling dynamic linking is achieved by adding `bevy_dylib` as a dependency and
|
//! Manually enabling dynamic linking is achieved by adding `bevy_dylib` as a dependency and
|
||||||
//! adding the following code to the `main.rs` file:
|
//! adding the following code to the `main.rs` file:
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```
|
||||||
//! #[allow(unused_imports)]
|
//! #[allow(unused_imports)]
|
||||||
//! use bevy_dylib;
|
//! use bevy_dylib;
|
||||||
//! ```
|
//! ```
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
//! It is recommended to disable the `bevy_dylib` dependency in release mode by adding the
|
//! It is recommended to disable the `bevy_dylib` dependency in release mode by adding the
|
||||||
//! following code to the `use` statement to avoid having to ship additional files with your game:
|
//! following code to the `use` statement to avoid having to ship additional files with your game:
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```
|
||||||
//! #[allow(unused_imports)]
|
//! #[allow(unused_imports)]
|
||||||
//! #[cfg(debug_assertions)] // new
|
//! #[cfg(debug_assertions)] // new
|
||||||
//! use bevy_dylib;
|
//! use bevy_dylib;
|
||||||
|
|
|
@ -161,6 +161,7 @@ impl Schedule {
|
||||||
/// # schedule.add_stage("target_stage", SystemStage::parallel());
|
/// # schedule.add_stage("target_stage", SystemStage::parallel());
|
||||||
/// #
|
/// #
|
||||||
/// schedule.add_stage_before("target_stage", "my_stage", SystemStage::parallel());
|
/// schedule.add_stage_before("target_stage", "my_stage", SystemStage::parallel());
|
||||||
|
/// ```
|
||||||
pub fn add_stage_before<S: Stage>(
|
pub fn add_stage_before<S: Stage>(
|
||||||
&mut self,
|
&mut self,
|
||||||
target: impl StageLabel,
|
target: impl StageLabel,
|
||||||
|
@ -197,6 +198,7 @@ impl Schedule {
|
||||||
/// # schedule.add_stage("my_stage", SystemStage::parallel());
|
/// # schedule.add_stage("my_stage", SystemStage::parallel());
|
||||||
/// #
|
/// #
|
||||||
/// schedule.add_system_to_stage("my_stage", my_system);
|
/// schedule.add_system_to_stage("my_stage", my_system);
|
||||||
|
/// ```
|
||||||
pub fn add_system_to_stage<Params>(
|
pub fn add_system_to_stage<Params>(
|
||||||
&mut self,
|
&mut self,
|
||||||
stage_label: impl StageLabel,
|
stage_label: impl StageLabel,
|
||||||
|
@ -324,6 +326,7 @@ impl Schedule {
|
||||||
/// # schedule.add_stage("my_stage", SystemStage::parallel());
|
/// # schedule.add_stage("my_stage", SystemStage::parallel());
|
||||||
/// #
|
/// #
|
||||||
/// let stage = schedule.get_stage_mut::<SystemStage>(&"my_stage").unwrap();
|
/// let stage = schedule.get_stage_mut::<SystemStage>(&"my_stage").unwrap();
|
||||||
|
/// ```
|
||||||
pub fn get_stage_mut<T: Stage>(&mut self, label: &dyn StageLabel) -> Option<&mut T> {
|
pub fn get_stage_mut<T: Stage>(&mut self, label: &dyn StageLabel) -> Option<&mut T> {
|
||||||
self.stages
|
self.stages
|
||||||
.get_mut(label)
|
.get_mut(label)
|
||||||
|
|
|
@ -367,7 +367,7 @@ impl<'w, 's, 'a> EntityCommands<'w, 's, 'a> {
|
||||||
/// # use bevy_ecs::prelude::*;
|
/// # use bevy_ecs::prelude::*;
|
||||||
/// #
|
/// #
|
||||||
/// fn my_system(mut commands: Commands) {
|
/// fn my_system(mut commands: Commands) {
|
||||||
/// let entity_id = commands.spawn().id();
|
/// let entity_id = commands.spawn().id();
|
||||||
/// }
|
/// }
|
||||||
/// # my_system.system();
|
/// # my_system.system();
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -403,7 +403,7 @@ impl<'w, 's, 'a> EntityCommands<'w, 's, 'a> {
|
||||||
/// health: Health(100),
|
/// health: Health(100),
|
||||||
/// strength: Strength(40),
|
/// strength: Strength(40),
|
||||||
/// defense: Defense(20),
|
/// defense: Defense(20),
|
||||||
/// });
|
/// });
|
||||||
/// }
|
/// }
|
||||||
/// # add_combat_stats_system.system();
|
/// # add_combat_stats_system.system();
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -477,7 +477,7 @@ impl<'w, 's, 'a> EntityCommands<'w, 's, 'a> {
|
||||||
/// # struct CombatBundle { a: Dummy }; // dummy field, unit bundles are not permitted.
|
/// # struct CombatBundle { a: Dummy }; // dummy field, unit bundles are not permitted.
|
||||||
/// #
|
/// #
|
||||||
/// fn remove_combat_stats_system(mut commands: Commands, player: Res<PlayerEntity>) {
|
/// fn remove_combat_stats_system(mut commands: Commands, player: Res<PlayerEntity>) {
|
||||||
/// commands.entity(player.entity).remove_bundle::<CombatBundle>();
|
/// commands.entity(player.entity).remove_bundle::<CombatBundle>();
|
||||||
/// }
|
/// }
|
||||||
/// # remove_combat_stats_system.system();
|
/// # remove_combat_stats_system.system();
|
||||||
/// ```
|
/// ```
|
||||||
|
|
|
@ -55,7 +55,7 @@ impl SystemMeta {
|
||||||
|
|
||||||
// TODO: Actually use this in FunctionSystem. We should probably only do this once Systems are constructed using a World reference
|
// TODO: Actually use this in FunctionSystem. We should probably only do this once Systems are constructed using a World reference
|
||||||
// (to avoid the need for unwrapping to retrieve SystemMeta)
|
// (to avoid the need for unwrapping to retrieve SystemMeta)
|
||||||
/// Holds on to persistent state required to drive [`SystemParam`] for a [`System`].
|
/// Holds on to persistent state required to drive [`SystemParam`] for a [`System`].
|
||||||
pub struct SystemState<Param: SystemParam> {
|
pub struct SystemState<Param: SystemParam> {
|
||||||
meta: SystemMeta,
|
meta: SystemMeta,
|
||||||
param_state: <Param as SystemParam>::Fetch,
|
param_state: <Param as SystemParam>::Fetch,
|
||||||
|
@ -115,7 +115,7 @@ impl<Param: SystemParam> SystemState<Param> {
|
||||||
|
|
||||||
/// Applies all state queued up for [`SystemParam`] values. For example, this will apply commands queued up
|
/// Applies all state queued up for [`SystemParam`] values. For example, this will apply commands queued up
|
||||||
/// by a [`Commands`](`super::Commands`) parameter to the given [`World`].
|
/// by a [`Commands`](`super::Commands`) parameter to the given [`World`].
|
||||||
/// This function should be called manually after the values returned by [`SystemState::get`] and [`SystemState::get_mut`]
|
/// This function should be called manually after the values returned by [`SystemState::get`] and [`SystemState::get_mut`]
|
||||||
/// are finished being used.
|
/// are finished being used.
|
||||||
pub fn apply(&mut self, world: &mut World) {
|
pub fn apply(&mut self, world: &mut World) {
|
||||||
self.param_state.apply(world);
|
self.param_state.apply(world);
|
||||||
|
@ -150,7 +150,7 @@ impl<Param: SystemParam> SystemState<Param> {
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// This call might access any of the input parameters in a way that violates Rust's mutability rules. Make sure the data
|
/// This call might access any of the input parameters in a way that violates Rust's mutability rules. Make sure the data
|
||||||
/// access is safe in the context of global [`World`] access. The passed-in [`World`] _must_ be the [`World`] the [`SystemState`] was
|
/// access is safe in the context of global [`World`] access. The passed-in [`World`] _must_ be the [`World`] the [`SystemState`] was
|
||||||
/// created with.
|
/// created with.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn get_unchecked_manual<'w, 's>(
|
pub unsafe fn get_unchecked_manual<'w, 's>(
|
||||||
&'s mut self,
|
&'s mut self,
|
||||||
|
|
|
@ -187,7 +187,7 @@ use thiserror::Error;
|
||||||
/// # tuple_system.system();
|
/// # tuple_system.system();
|
||||||
///
|
///
|
||||||
/// # fn non_tuple_system(
|
/// # fn non_tuple_system(
|
||||||
/// // This is the preferred method.
|
/// // This is the preferred method.
|
||||||
/// query: Query<&MyComponent>
|
/// query: Query<&MyComponent>
|
||||||
/// # ) {}
|
/// # ) {}
|
||||||
/// # non_tuple_system.system();
|
/// # non_tuple_system.system();
|
||||||
|
|
|
@ -493,15 +493,15 @@ impl World {
|
||||||
///
|
///
|
||||||
/// let mut world = World::new();
|
/// let mut world = World::new();
|
||||||
/// let entities = world.spawn_batch(vec![
|
/// let entities = world.spawn_batch(vec![
|
||||||
/// (Position { x: 0.0, y: 0.0}, Velocity { x: 1.0, y: 0.0 }),
|
/// (Position { x: 0.0, y: 0.0}, Velocity { x: 1.0, y: 0.0 }),
|
||||||
/// (Position { x: 0.0, y: 0.0}, Velocity { x: 0.0, y: 1.0 }),
|
/// (Position { x: 0.0, y: 0.0}, Velocity { x: 0.0, y: 1.0 }),
|
||||||
/// ]).collect::<Vec<Entity>>();
|
/// ]).collect::<Vec<Entity>>();
|
||||||
///
|
///
|
||||||
/// let mut query = world.query::<(&mut Position, &Velocity)>();
|
/// let mut query = world.query::<(&mut Position, &Velocity)>();
|
||||||
/// for (mut position, velocity) in query.iter_mut(&mut world) {
|
/// for (mut position, velocity) in query.iter_mut(&mut world) {
|
||||||
/// position.x += velocity.x;
|
/// position.x += velocity.x;
|
||||||
/// position.y += velocity.y;
|
/// position.y += velocity.y;
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// assert_eq!(world.get::<Position>(entities[0]).unwrap(), &Position { x: 1.0, y: 0.0 });
|
/// assert_eq!(world.get::<Position>(entities[0]).unwrap(), &Position { x: 1.0, y: 0.0 });
|
||||||
/// assert_eq!(world.get::<Position>(entities[1]).unwrap(), &Position { x: 0.0, y: 1.0 });
|
/// assert_eq!(world.get::<Position>(entities[1]).unwrap(), &Position { x: 0.0, y: 1.0 });
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
//!
|
//!
|
||||||
//! # Examples
|
//! # Examples
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```
|
||||||
//! use bevy_render::mesh::VertexAttributeValues;
|
//! use bevy_render::mesh::VertexAttributeValues;
|
||||||
//!
|
//!
|
||||||
//! // creating std::vec::Vec
|
//! // creating std::vec::Vec
|
||||||
|
|
|
@ -46,7 +46,6 @@ pub enum PhysicsSystem {
|
||||||
/// ordering can then change between invocations.
|
/// ordering can then change between invocations.
|
||||||
///
|
///
|
||||||
/// Lastly a system with run criterion _done_ is used to exit the app.
|
/// Lastly a system with run criterion _done_ is used to exit the app.
|
||||||
/// ```
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
//! println!("hello world");
|
//! println!("hello world");
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
//!
|
||||||
//! Don't let the simplicity of the example above fool you. Bevy is a [fully featured game engine](https://bevyengine.org)
|
//! Don't let the simplicity of the example above fool you. Bevy is a [fully featured game engine](https://bevyengine.org)
|
||||||
//! and it gets more powerful every day!
|
//! and it gets more powerful every day!
|
||||||
//!
|
//!
|
||||||
|
|
Loading…
Reference in a new issue