Skip to content

Commit 025d459

Browse files
committed
fix docs
1 parent be9e573 commit 025d459

File tree

8 files changed

+29
-16
lines changed

8 files changed

+29
-16
lines changed

examples/basic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//!
1+
//! A simple increasing timer, without using the entity builder, showcasing the least invasive way
2+
//! to start using jonmo signals in existing Bevy apps.
23
34
mod utils;
45
use utils::*;
@@ -54,4 +55,3 @@ fn incr_value(mut ticker: ResMut<ValueTicker>, time: Res<Time>, mut values: Quer
5455
fn camera(mut commands: Commands) {
5556
commands.spawn(Camera2d);
5657
}
57-

examples/basic_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//!
1+
//! A simple increasing timer, using the entity builder, showcasing the recommended, idiomatic way to use jonmo signals.
22
mod utils;
33
use utils::*;
44

examples/basic_builder_inject.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//!
1+
//! A simple increasing timer, injecting the entity builder into an existing entity, showcasing a
2+
//! less invasive way to start using jonmo signals in existing Bevy apps.
23
mod utils;
34
use utils::*;
45

examples/filters.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ fn text_node(text: &'static str) -> JonmoBuilder {
207207
))
208208
}
209209

210-
fn toggle<T: Eq + std::hash::Hash>(set: &mut HashSet<T>, value: T) {
210+
fn toggle<T: Eq + core::hash::Hash>(set: &mut HashSet<T>, value: T) {
211211
if !set.remove(&value) {
212212
set.insert(value);
213213
}

examples/letters.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
//!
1+
//! Diverse filtering options for a list of items, showcasing the power of vector signals.
22
mod utils;
33
use utils::*;
44

5-
use std::collections::BTreeMap;
5+
extern crate alloc;
6+
use alloc::collections::BTreeMap;
67

78
use bevy_platform::collections::HashMap;
89

examples/test.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
//!
2-
1+
#![allow(missing_docs)]
2+
#![allow(unused_variables)]
33
mod utils;
4-
54
use utils::*;
65

76
use bevy::prelude::*;

src/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ impl JonmoBuilder {
219219
} */
220220

221221
/// Run a function that takes a [`Signal`] which outputs this builder's [`Entity`]'s
222-
/// `generations`-nth generation ancestor and returns a [`Signal`]. Passing `0` to `generations`
223-
/// will return this builder's [`Entity`] itself.
222+
/// `generations`-th generation ancestor and returns a [`Signal`]. Passing `0` to `generations`
223+
/// will output this builder's [`Entity`] itself.
224224
///
225225
/// The resulting [`Signal`] will be automatically cleaned up when the [`Entity`] is despawned.
226226
pub fn signal_from_ancestor<S, F>(self, generations: usize, f: F) -> Self

src/signal.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,18 +615,26 @@ impl SignalBuilder {
615615
Self::from_system(move |_: In<()>| entity.get())
616616
}
617617

618+
/// Creates a [`Source`] signal from an [`Entity`]'s `generations`-th generation ancestor's
619+
/// [`Entity`]. Passing `0` to `generation` will output the [`Entity`] itself.
618620
pub fn from_ancestor(entity: Entity, generations: usize) -> Map<Source<Entity>, Entity> {
619621
Self::from_entity(entity).map(ancestor_map(generations))
620622
}
621623

624+
/// Creates a [`Source`] signal from a [`LazyEntity`]'s `generations`-th generation ancestor's
625+
/// [`Entity`]. Passing `0` to `generation` will output the [`LazyEntity`]'s [`Entity`] itself.
622626
pub fn from_ancestor_lazy(entity: LazyEntity, generations: usize) -> Map<Source<Entity>, Entity> {
623627
Self::from_lazy_entity(entity).map(ancestor_map(generations))
624628
}
625629

630+
/// Creates a [`Source`] signal from an [`Entity`]'s parent's [`Entity`]. Passing `0` to
631+
/// `generation` will output the [`Entity`] itself.
626632
pub fn from_parent(entity: Entity) -> Map<Source<Entity>, Entity> {
627633
Self::from_ancestor(entity, 1)
628634
}
629635

636+
/// Creates a [`Source`] signal from a [`LazyEntity`]'s parent's [`Entity`]. Passing `0` to
637+
/// `generation` will output the [`LazyEntity`]'s [`Entity`] itself.
630638
pub fn from_parent_lazy(entity: LazyEntity) -> Map<Source<Entity>, Entity> {
631639
Self::from_ancestor_lazy(entity, 1)
632640
}
@@ -1848,19 +1856,23 @@ impl<T: ?Sized> SignalExt for T where T: Signal {}
18481856

18491857
#[cfg(test)]
18501858
mod tests {
1851-
use super::*;
18521859
use crate::{
18531860
JonmoPlugin,
1854-
prelude::{MutableVec, SignalVecExt},
1861+
graph::{LazySignalHolder, SignalRegistrationCount},
1862+
prelude::{MutableVec, SignalVecExt, clone},
1863+
signal::{SignalBuilder, SignalExt, Upstream},
1864+
signal_vec::VecDiff,
1865+
utils::SSs,
18551866
};
1867+
use core::{convert::identity, fmt};
18561868

18571869
// Import Bevy prelude for MinimalPlugins and other common items
18581870
use bevy::prelude::*;
18591871
use bevy_platform::sync::*;
18601872
use bevy_time::TimeUpdateStrategy;
18611873

18621874
// Add Duration
1863-
use core::{convert::identity, time::Duration};
1875+
use core::time::Duration;
18641876

18651877
// Helper component and resource for testing Add Default
18661878
#[derive(Component, Clone, Debug, PartialEq, Reflect, Default)]
@@ -2624,7 +2636,7 @@ mod tests {
26242636
// --- Test Some case ---
26252637
let source_some = SignalBuilder::from_system(|_: In<()>| Some(42));
26262638
let signal_some = source_some
2627-
.map_some(|In(val): In<i32>| format!("Got {}", val))
2639+
.map_some(|In(val): In<i32>| format!("Got {val}"))
26282640
.map(capture_output)
26292641
.register(app.world_mut());
26302642
app.update();

0 commit comments

Comments
 (0)