Skip to content

Commit

Permalink
Doctest improvments (#1937)
Browse files Browse the repository at this point in the history
  • Loading branch information
MinerSebas committed Apr 16, 2021
1 parent 4c86b99 commit 20673db
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
3 changes: 3 additions & 0 deletions crates/bevy_core/src/time/stopwatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use std::{any::TypeId, collections::HashMap};
/// #[bundle]
/// a: A,
/// z: String,
/// }
/// }
/// ```
///
/// # Safety
Expand Down
10 changes: 8 additions & 2 deletions crates/bevy_ecs/src/query/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
13 changes: 11 additions & 2 deletions crates/bevy_ecs/src/system/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/3d/spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 20673db

Please sign in to comment.