Doctest improvments (#1937)
This commit is contained in:
parent
4c86b99d2f
commit
20673dbe0e
@ -11,11 +11,14 @@ use bevy_utils::Duration;
|
|||||||
/// use std::time::Duration;
|
/// use std::time::Duration;
|
||||||
/// let mut stopwatch = Stopwatch::new();
|
/// let mut stopwatch = Stopwatch::new();
|
||||||
/// assert_eq!(stopwatch.elapsed_secs(), 0.0);
|
/// assert_eq!(stopwatch.elapsed_secs(), 0.0);
|
||||||
|
///
|
||||||
/// stopwatch.tick(Duration::from_secs_f32(1.0)); // tick one second
|
/// stopwatch.tick(Duration::from_secs_f32(1.0)); // tick one second
|
||||||
/// assert_eq!(stopwatch.elapsed_secs(), 1.0);
|
/// assert_eq!(stopwatch.elapsed_secs(), 1.0);
|
||||||
|
///
|
||||||
/// stopwatch.pause();
|
/// stopwatch.pause();
|
||||||
/// stopwatch.tick(Duration::from_secs_f32(1.0)); // paused stopwatches don't tick
|
/// stopwatch.tick(Duration::from_secs_f32(1.0)); // paused stopwatches don't tick
|
||||||
/// assert_eq!(stopwatch.elapsed_secs(), 1.0);
|
/// assert_eq!(stopwatch.elapsed_secs(), 1.0);
|
||||||
|
///
|
||||||
/// stopwatch.reset(); // reset the stopwatch
|
/// stopwatch.reset(); // reset the stopwatch
|
||||||
/// assert!(stopwatch.paused());
|
/// assert!(stopwatch.paused());
|
||||||
/// assert_eq!(stopwatch.elapsed_secs(), 0.0);
|
/// assert_eq!(stopwatch.elapsed_secs(), 0.0);
|
||||||
|
|||||||
@ -34,7 +34,7 @@ use std::{any::TypeId, collections::HashMap};
|
|||||||
/// #[bundle]
|
/// #[bundle]
|
||||||
/// a: A,
|
/// a: A,
|
||||||
/// z: String,
|
/// z: String,
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
|
|||||||
@ -610,18 +610,21 @@ impl_tick_filter!(
|
|||||||
///
|
///
|
||||||
/// Example:
|
/// Example:
|
||||||
/// ```
|
/// ```
|
||||||
|
/// # use bevy_ecs::system::IntoSystem;
|
||||||
/// # use bevy_ecs::system::Query;
|
/// # use bevy_ecs::system::Query;
|
||||||
/// # use bevy_ecs::query::Added;
|
/// # use bevy_ecs::query::Added;
|
||||||
/// #
|
/// #
|
||||||
/// # #[derive(Debug)]
|
/// # #[derive(Debug)]
|
||||||
/// # struct Name {};
|
/// # struct Name {};
|
||||||
/// # struct Transform {};
|
/// # struct Transform {};
|
||||||
/// #
|
///
|
||||||
/// fn print_add_name_component(query: Query<&Name, Added<Name>>) {
|
/// fn print_add_name_component(query: Query<&Name, Added<Name>>) {
|
||||||
/// for name in query.iter() {
|
/// for name in query.iter() {
|
||||||
/// println!("Named entity created: {:?}", name)
|
/// println!("Named entity created: {:?}", name)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
|
///
|
||||||
|
/// # print_add_name_component.system();
|
||||||
/// ```
|
/// ```
|
||||||
Added,
|
Added,
|
||||||
AddedState,
|
AddedState,
|
||||||
@ -642,18 +645,21 @@ impl_tick_filter!(
|
|||||||
///
|
///
|
||||||
/// Example:
|
/// Example:
|
||||||
/// ```
|
/// ```
|
||||||
|
/// # use bevy_ecs::system::IntoSystem;
|
||||||
/// # use bevy_ecs::system::Query;
|
/// # use bevy_ecs::system::Query;
|
||||||
/// # use bevy_ecs::query::Changed;
|
/// # use bevy_ecs::query::Changed;
|
||||||
/// #
|
/// #
|
||||||
/// # #[derive(Debug)]
|
/// # #[derive(Debug)]
|
||||||
/// # struct Name {};
|
/// # struct Name {};
|
||||||
/// # struct Transform {};
|
/// # struct Transform {};
|
||||||
/// #
|
///
|
||||||
/// fn print_moving_objects_system(query: Query<&Name, Changed<Transform>>) {
|
/// fn print_moving_objects_system(query: Query<&Name, Changed<Transform>>) {
|
||||||
/// for name in query.iter() {
|
/// for name in query.iter() {
|
||||||
/// println!("Entity Moved: {:?}", name);
|
/// println!("Entity Moved: {:?}", name);
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
|
///
|
||||||
|
/// # print_moving_objects_system.system();
|
||||||
/// ```
|
/// ```
|
||||||
Changed,
|
Changed,
|
||||||
ChangedState,
|
ChangedState,
|
||||||
|
|||||||
@ -32,6 +32,8 @@ use std::{
|
|||||||
/// fn my_system(param: MyParam) {
|
/// fn my_system(param: MyParam) {
|
||||||
/// // Access the resource through `param.foo`
|
/// // Access the resource through `param.foo`
|
||||||
/// }
|
/// }
|
||||||
|
///
|
||||||
|
/// # my_system.system();
|
||||||
/// ```
|
/// ```
|
||||||
pub trait SystemParam: Sized {
|
pub trait SystemParam: Sized {
|
||||||
type Fetch: for<'a> SystemParamFetch<'a>;
|
type Fetch: for<'a> SystemParamFetch<'a>;
|
||||||
@ -573,10 +575,17 @@ impl<'a, T: Component + FromWorld> SystemParamFetch<'a> for LocalState<T> {
|
|||||||
///
|
///
|
||||||
/// Basic usage:
|
/// Basic usage:
|
||||||
///
|
///
|
||||||
/// ```ignore
|
/// ```
|
||||||
|
/// # use bevy_ecs::system::IntoSystem;
|
||||||
|
/// # use bevy_ecs::system::RemovedComponents;
|
||||||
|
/// #
|
||||||
|
/// # struct MyComponent;
|
||||||
|
///
|
||||||
/// fn react_on_removal(removed: RemovedComponents<MyComponent>) {
|
/// fn react_on_removal(removed: RemovedComponents<MyComponent>) {
|
||||||
/// removed.iter().for_each(|removed_entity| println!("{}", removed_entity));
|
/// removed.iter().for_each(|removed_entity| println!("{:?}", removed_entity));
|
||||||
/// }
|
/// }
|
||||||
|
///
|
||||||
|
/// # react_on_removal.system();
|
||||||
/// ```
|
/// ```
|
||||||
pub struct RemovedComponents<'a, T> {
|
pub struct RemovedComponents<'a, T> {
|
||||||
world: &'a World,
|
world: &'a World,
|
||||||
|
|||||||
@ -7,7 +7,7 @@ use rand::{rngs::StdRng, Rng, SeedableRng};
|
|||||||
/// This example spawns a large number of cubes, each with its own changing position and material
|
/// This example spawns a large number of cubes, each with its own changing position and material
|
||||||
/// This is intended to be a stress test of bevy's ability to render many objects with different
|
/// This is intended to be a stress test of bevy's ability to render many objects with different
|
||||||
/// properties For the best results, run it in release mode:
|
/// properties For the best results, run it in release mode:
|
||||||
/// ```
|
/// ```bash
|
||||||
/// cargo run --example spawner --release
|
/// cargo run --example spawner --release
|
||||||
/// ```
|
/// ```
|
||||||
/// NOTE: Bevy still has a number of optimizations to do in this area. Expect the
|
/// NOTE: Bevy still has a number of optimizations to do in this area. Expect the
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user