Doctest improvments (#1937)
This commit is contained in:
parent
4c86b99d2f
commit
20673dbe0e
@ -11,11 +11,14 @@ use bevy_utils::Duration;
|
||||
/// use std::time::Duration;
|
||||
/// let mut stopwatch = Stopwatch::new();
|
||||
/// assert_eq!(stopwatch.elapsed_secs(), 0.0);
|
||||
///
|
||||
/// stopwatch.tick(Duration::from_secs_f32(1.0)); // tick one second
|
||||
/// assert_eq!(stopwatch.elapsed_secs(), 1.0);
|
||||
///
|
||||
/// stopwatch.pause();
|
||||
/// stopwatch.tick(Duration::from_secs_f32(1.0)); // paused stopwatches don't tick
|
||||
/// assert_eq!(stopwatch.elapsed_secs(), 1.0);
|
||||
///
|
||||
/// stopwatch.reset(); // reset the stopwatch
|
||||
/// assert!(stopwatch.paused());
|
||||
/// assert_eq!(stopwatch.elapsed_secs(), 0.0);
|
||||
|
||||
@ -34,7 +34,7 @@ use std::{any::TypeId, collections::HashMap};
|
||||
/// #[bundle]
|
||||
/// a: A,
|
||||
/// z: String,
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// # Safety
|
||||
|
||||
@ -610,18 +610,21 @@ impl_tick_filter!(
|
||||
///
|
||||
/// Example:
|
||||
/// ```
|
||||
/// # use bevy_ecs::system::IntoSystem;
|
||||
/// # use bevy_ecs::system::Query;
|
||||
/// # use bevy_ecs::query::Added;
|
||||
/// #
|
||||
/// # #[derive(Debug)]
|
||||
/// # struct Name {};
|
||||
/// # struct Transform {};
|
||||
/// #
|
||||
///
|
||||
/// fn print_add_name_component(query: Query<&Name, Added<Name>>) {
|
||||
/// for name in query.iter() {
|
||||
/// println!("Named entity created: {:?}", name)
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// # print_add_name_component.system();
|
||||
/// ```
|
||||
Added,
|
||||
AddedState,
|
||||
@ -642,18 +645,21 @@ impl_tick_filter!(
|
||||
///
|
||||
/// Example:
|
||||
/// ```
|
||||
/// # use bevy_ecs::system::IntoSystem;
|
||||
/// # use bevy_ecs::system::Query;
|
||||
/// # use bevy_ecs::query::Changed;
|
||||
/// #
|
||||
/// # #[derive(Debug)]
|
||||
/// # struct Name {};
|
||||
/// # struct Transform {};
|
||||
/// #
|
||||
///
|
||||
/// fn print_moving_objects_system(query: Query<&Name, Changed<Transform>>) {
|
||||
/// for name in query.iter() {
|
||||
/// println!("Entity Moved: {:?}", name);
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// # print_moving_objects_system.system();
|
||||
/// ```
|
||||
Changed,
|
||||
ChangedState,
|
||||
|
||||
@ -32,6 +32,8 @@ use std::{
|
||||
/// fn my_system(param: MyParam) {
|
||||
/// // Access the resource through `param.foo`
|
||||
/// }
|
||||
///
|
||||
/// # my_system.system();
|
||||
/// ```
|
||||
pub trait SystemParam: Sized {
|
||||
type Fetch: for<'a> SystemParamFetch<'a>;
|
||||
@ -573,10 +575,17 @@ impl<'a, T: Component + FromWorld> SystemParamFetch<'a> for LocalState<T> {
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```
|
||||
/// # use bevy_ecs::system::IntoSystem;
|
||||
/// # use bevy_ecs::system::RemovedComponents;
|
||||
/// #
|
||||
/// # struct 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> {
|
||||
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 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:
|
||||
/// ```
|
||||
/// ```bash
|
||||
/// cargo run --example spawner --release
|
||||
/// ```
|
||||
/// NOTE: Bevy still has a number of optimizations to do in this area. Expect the
|
||||
|
||||
Loading…
Reference in New Issue
Block a user