Skip to content

Commit bc8ba43

Browse files
committed
Fix doc tests
1 parent 493590e commit bc8ba43

File tree

5 files changed

+114
-28
lines changed

5 files changed

+114
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ If you want *all* entities with a `Transform` to be interpolated by default, you
9898

9999
```rust
100100
fn main() {
101-
App::build()
101+
App::new()
102102
.add_plugins(TransformInterpolationPlugin::interpolate_all())
103103
// ...
104104
.run();

src/extrapolation.rs

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ use bevy::prelude::*;
3939
/// use bevy::{ecs::query::QueryData, prelude::*};
4040
/// use bevy_transform_interpolation::VelocitySource;
4141
///
42-
/// #[derive(Component)]
42+
/// #[derive(Component, Default)]
4343
/// struct LinearVelocity(Vec3);
4444
///
45-
/// #[derive(Component)]
45+
/// #[derive(Component, Default)]
4646
/// struct AngularVelocity(Vec3);
4747
///
4848
/// #[derive(QueryData)]
@@ -83,11 +83,49 @@ use bevy::prelude::*;
8383
/// Then, add the [`TransformExtrapolationPlugin`] to the app with the velocity sources:
8484
///
8585
/// ```
86-
/// use bevy::prelude::*;
87-
/// use bevy_transform_interpolation::prelude::*;
86+
/// use bevy::{ecs::query::QueryData, prelude::*};
87+
/// use bevy_transform_interpolation::{prelude::*, VelocitySource};
88+
/// #
89+
/// # #[derive(Component, Default)]
90+
/// # struct LinearVelocity(Vec3);
91+
/// #
92+
/// # #[derive(Component, Default)]
93+
/// # struct AngularVelocity(Vec3);
94+
/// #
95+
/// # #[derive(QueryData)]
96+
/// # struct LinVelSource;
97+
/// #
98+
/// # impl VelocitySource for LinVelSource {
99+
/// # type Previous = LinearVelocity;
100+
/// # type Current = LinearVelocity;
101+
/// #
102+
/// # fn previous(start: &Self::Previous) -> Vec3 {
103+
/// # start.0
104+
/// # }
105+
/// #
106+
/// # fn current(end: &Self::Current) -> Vec3 {
107+
/// # end.0
108+
/// # }
109+
/// # }
110+
/// #
111+
/// # #[derive(QueryData)]
112+
/// # struct AngVelSource;
113+
/// #
114+
/// # impl VelocitySource for AngVelSource {
115+
/// # type Previous = AngularVelocity;
116+
/// # type Current = AngularVelocity;
117+
/// #
118+
/// # fn previous(start: &Self::Previous) -> Vec3 {
119+
/// # start.0
120+
/// # }
121+
/// #
122+
/// # fn current(end: &Self::Current) -> Vec3 {
123+
/// # end.0
124+
/// # }
125+
/// # }
88126
///
89127
/// fn main() {
90-
/// let mut app = App::build();
128+
/// let mut app = App::new();
91129
///
92130
/// app.add_plugins((
93131
/// TransformInterpolationPlugin::default(),
@@ -147,7 +185,7 @@ use bevy::prelude::*;
147185
/// # use bevy_transform_interpolation::prelude::*;
148186
/// #
149187
/// fn main() {
150-
/// App::build()
188+
/// App::new()
151189
/// .add_plugins(TransformExtrapolationPlugin::<LinVelSource, AngVelSource> {
152190
/// // Extrapolate translation by default, but not rotation.
153191
/// extrapolate_translation_all: true,

src/hermite.rs

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ use crate::{
4242
/// use bevy::{ecs::query::QueryData, prelude::*};
4343
/// use bevy_transform_interpolation::VelocitySource;
4444
///
45-
/// #[derive(Component)]
45+
/// #[derive(Component, Default)]
4646
/// struct PreviousLinearVelocity(Vec3);
4747
///
48-
/// #[derive(Component)]
48+
/// #[derive(Component, Default)]
4949
/// struct PreviousAngularVelocity(Vec3);
5050
///
51-
/// #[derive(Component)]
51+
/// #[derive(Component, Default)]
5252
/// struct LinearVelocity(Vec3);
5353
///
54-
/// #[derive(Component)]
54+
/// #[derive(Component, Default)]
5555
/// struct AngularVelocity(Vec3);
5656
///
5757
/// #[derive(QueryData)]
@@ -92,11 +92,56 @@ use crate::{
9292
/// along with the [`TransformInterpolationPlugin`] and/or [`TransformExtrapolationPlugin`]:
9393
///
9494
/// ```
95-
/// use bevy::prelude::*;
96-
/// use bevy_transform_interpolation::prelude::*;
95+
/// use bevy::{ecs::query::QueryData, prelude::*};
96+
/// use bevy_transform_interpolation::{prelude::*, VelocitySource};
97+
/// #
98+
/// # #[derive(Component, Default)]
99+
/// # struct PreviousLinearVelocity(Vec3);
100+
/// #
101+
/// # #[derive(Component, Default)]
102+
/// # struct PreviousAngularVelocity(Vec3);
103+
/// #
104+
/// # #[derive(Component, Default)]
105+
/// # struct LinearVelocity(Vec3);
106+
/// #
107+
/// # #[derive(Component, Default)]
108+
/// # struct AngularVelocity(Vec3);
109+
/// #
110+
/// # #[derive(QueryData)]
111+
/// # struct LinVelSource;
112+
/// #
113+
/// # impl VelocitySource for LinVelSource {
114+
/// # // Components storing the previous and current velocities.
115+
/// # type Previous = PreviousLinearVelocity;
116+
/// # type Current = LinearVelocity;
117+
/// #
118+
/// # fn previous(start: &Self::Previous) -> Vec3 {
119+
/// # start.0
120+
/// # }
121+
/// #
122+
/// # fn current(end: &Self::Current) -> Vec3 {
123+
/// # end.0
124+
/// # }
125+
/// # }
126+
/// #
127+
/// # #[derive(QueryData)]
128+
/// # struct AngVelSource;
129+
/// #
130+
/// # impl VelocitySource for AngVelSource {
131+
/// # type Previous = PreviousAngularVelocity;
132+
/// # type Current = AngularVelocity;
133+
/// #
134+
/// # fn previous(start: &Self::Previous) -> Vec3 {
135+
/// # start.0
136+
/// # }
137+
/// #
138+
/// # fn current(end: &Self::Current) -> Vec3 {
139+
/// # end.0
140+
/// # }
141+
/// # }
97142
///
98143
/// fn main() {
99-
/// let mut app = App::build();
144+
/// let mut app = App::new();
100145
///
101146
/// app.add_plugins((
102147
/// TransformInterpolationPlugin::default(),

src/interpolation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ use bevy::prelude::*;
7474
/// # use bevy_transform_interpolation::prelude::*;
7575
/// #
7676
/// fn main() {
77-
/// App::build()
77+
/// App::new()
7878
/// .add_plugins(TransformInterpolationPlugin {
7979
/// // Interpolate translation and rotation by default, but not scale.
8080
/// interpolate_translation_all: true,

src/lib.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
//! # use bevy_transform_interpolation::prelude::*;
6262
//! #
6363
//! fn main() {
64-
//! App::build()
64+
//! App::new()
6565
//! .add_plugins(TransformInterpolationPlugin::interpolate_all())
6666
//! // ...
6767
//! .run();
@@ -302,6 +302,9 @@ pub struct NonlinearRotationEasing;
302302
/// # Example
303303
///
304304
/// ```
305+
/// use bevy::{ecs::query::QueryData, prelude::*};
306+
/// use bevy_transform_interpolation::VelocitySource;
307+
///
305308
/// // Velocity components
306309
///
307310
/// #[derive(Component)]
@@ -321,15 +324,15 @@ pub struct NonlinearRotationEasing;
321324
/// struct LinVelSource;
322325
///
323326
/// impl VelocitySource for LinVelSource {
324-
/// type Start = PreviousLinearVelocity;
325-
/// type End = LinearVelocity;
327+
/// type Previous = PreviousLinearVelocity;
328+
/// type Current = LinearVelocity;
326329
///
327-
/// fn start(start: &Self::Start) -> Vec3 {
328-
/// start.0
330+
/// fn previous(previous: &Self::Previous) -> Vec3 {
331+
/// previous.0
329332
/// }
330333
///
331-
/// fn end(end: &Self::End) -> Vec3 {
332-
/// end.0
334+
/// fn current(current: &Self::Current) -> Vec3 {
335+
/// current.0
333336
/// }
334337
/// }
335338
///
@@ -338,15 +341,15 @@ pub struct NonlinearRotationEasing;
338341
/// struct AngVelSource;
339342
///
340343
/// impl VelocitySource for AngVelSource {
341-
/// type Start = PreviousAngularVelocity;
342-
/// type End = AngularVelocity;
344+
/// type Previous = PreviousAngularVelocity;
345+
/// type Current = AngularVelocity;
343346
///
344-
/// fn start(start: &Self::Start) -> Vec3 {
345-
/// start.0
347+
/// fn previous(previous: &Self::Previous) -> Vec3 {
348+
/// previous.0
346349
/// }
347350
///
348-
/// fn end(end: &Self::End) -> Vec3 {
349-
/// end.0
351+
/// fn current(current: &Self::Current) -> Vec3 {
352+
/// current.0
350353
/// }
351354
/// }
352355
/// ```

0 commit comments

Comments
 (0)