Skip to content

Commit 20673db

Browse files
committed
Doctest improvments (#1937)
1 parent 4c86b99 commit 20673db

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

crates/bevy_core/src/time/stopwatch.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ use bevy_utils::Duration;
1111
/// use std::time::Duration;
1212
/// let mut stopwatch = Stopwatch::new();
1313
/// assert_eq!(stopwatch.elapsed_secs(), 0.0);
14+
///
1415
/// stopwatch.tick(Duration::from_secs_f32(1.0)); // tick one second
1516
/// assert_eq!(stopwatch.elapsed_secs(), 1.0);
17+
///
1618
/// stopwatch.pause();
1719
/// stopwatch.tick(Duration::from_secs_f32(1.0)); // paused stopwatches don't tick
1820
/// assert_eq!(stopwatch.elapsed_secs(), 1.0);
21+
///
1922
/// stopwatch.reset(); // reset the stopwatch
2023
/// assert!(stopwatch.paused());
2124
/// assert_eq!(stopwatch.elapsed_secs(), 0.0);

crates/bevy_ecs/src/bundle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use std::{any::TypeId, collections::HashMap};
3434
/// #[bundle]
3535
/// a: A,
3636
/// z: String,
37-
/// }
37+
/// }
3838
/// ```
3939
///
4040
/// # Safety

crates/bevy_ecs/src/query/filter.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,18 +610,21 @@ impl_tick_filter!(
610610
///
611611
/// Example:
612612
/// ```
613+
/// # use bevy_ecs::system::IntoSystem;
613614
/// # use bevy_ecs::system::Query;
614615
/// # use bevy_ecs::query::Added;
615616
/// #
616617
/// # #[derive(Debug)]
617618
/// # struct Name {};
618619
/// # struct Transform {};
619-
/// #
620+
///
620621
/// fn print_add_name_component(query: Query<&Name, Added<Name>>) {
621622
/// for name in query.iter() {
622623
/// println!("Named entity created: {:?}", name)
623624
/// }
624625
/// }
626+
///
627+
/// # print_add_name_component.system();
625628
/// ```
626629
Added,
627630
AddedState,
@@ -642,18 +645,21 @@ impl_tick_filter!(
642645
///
643646
/// Example:
644647
/// ```
648+
/// # use bevy_ecs::system::IntoSystem;
645649
/// # use bevy_ecs::system::Query;
646650
/// # use bevy_ecs::query::Changed;
647651
/// #
648652
/// # #[derive(Debug)]
649653
/// # struct Name {};
650654
/// # struct Transform {};
651-
/// #
655+
///
652656
/// fn print_moving_objects_system(query: Query<&Name, Changed<Transform>>) {
653657
/// for name in query.iter() {
654658
/// println!("Entity Moved: {:?}", name);
655659
/// }
656660
/// }
661+
///
662+
/// # print_moving_objects_system.system();
657663
/// ```
658664
Changed,
659665
ChangedState,

crates/bevy_ecs/src/system/system_param.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ use std::{
3232
/// fn my_system(param: MyParam) {
3333
/// // Access the resource through `param.foo`
3434
/// }
35+
///
36+
/// # my_system.system();
3537
/// ```
3638
pub trait SystemParam: Sized {
3739
type Fetch: for<'a> SystemParamFetch<'a>;
@@ -573,10 +575,17 @@ impl<'a, T: Component + FromWorld> SystemParamFetch<'a> for LocalState<T> {
573575
///
574576
/// Basic usage:
575577
///
576-
/// ```ignore
578+
/// ```
579+
/// # use bevy_ecs::system::IntoSystem;
580+
/// # use bevy_ecs::system::RemovedComponents;
581+
/// #
582+
/// # struct MyComponent;
583+
///
577584
/// fn react_on_removal(removed: RemovedComponents<MyComponent>) {
578-
/// removed.iter().for_each(|removed_entity| println!("{}", removed_entity));
585+
/// removed.iter().for_each(|removed_entity| println!("{:?}", removed_entity));
579586
/// }
587+
///
588+
/// # react_on_removal.system();
580589
/// ```
581590
pub struct RemovedComponents<'a, T> {
582591
world: &'a World,

examples/3d/spawner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rand::{rngs::StdRng, Rng, SeedableRng};
77
/// This example spawns a large number of cubes, each with its own changing position and material
88
/// This is intended to be a stress test of bevy's ability to render many objects with different
99
/// properties For the best results, run it in release mode:
10-
/// ```
10+
/// ```bash
1111
/// cargo run --example spawner --release
1212
/// ```
1313
/// NOTE: Bevy still has a number of optimizations to do in this area. Expect the

0 commit comments

Comments
 (0)