Skip to content

Commit 4a1db6b

Browse files
authored
Fix some documentation after new stable doc lints
1 parent 1f2aee7 commit 4a1db6b

File tree

4 files changed

+60
-66
lines changed

4 files changed

+60
-66
lines changed

crates/bevy_time/src/fixed.rs

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ use crate::{time::Time, virt::Virtual, FixedUpdate};
1212
/// It is automatically inserted as a resource by
1313
/// [`TimePlugin`](crate::TimePlugin) and updated based on
1414
/// [`Time<Virtual>`](Virtual). The fixed clock is automatically set as the
15-
/// generic [`Time`] resource during [`FixedUpdate`](bevy_app::FixedUpdate)
16-
/// schedule processing.
15+
/// generic [`Time`] resource during [`FixedUpdate`] schedule processing.
1716
///
1817
/// The fixed timestep clock advances in fixed-size increments, which is
1918
/// extremely useful for writing logic (like physics) that should have
@@ -27,13 +26,12 @@ use crate::{time::Time, virt::Virtual, FixedUpdate};
2726
/// frame). Additionally, the value is a power of two which losslessly converts
2827
/// into [`f32`] and [`f64`].
2928
///
30-
/// To run a system on a fixed timestep, add it to the
31-
/// [`FixedUpdate`](bevy_app::FixedUpdate) schedule. This schedule is run a
32-
/// number of times between [`PreUpdate`](bevy_app::PreUpdate) and
33-
/// [`Update`](bevy_app::Update) according to the accumulated
34-
/// [`overstep()`](Time::overstep) time divided by the
35-
/// [`timestep()`](Time::timestep). This means the schedule may run 0, 1 or more
36-
/// times during a single update (which typically corresponds to a rendered
29+
/// To run a system on a fixed timestep, add it to the [`FixedUpdate`] schedule.
30+
/// This schedule is run a number of times between
31+
/// [`PreUpdate`](bevy_app::PreUpdate) and [`Update`](bevy_app::Update)
32+
/// according to the accumulated [`overstep()`](Time::overstep) time divided by
33+
/// the [`timestep()`](Time::timestep). This means the schedule may run 0, 1 or
34+
/// more times during a single update (which typically corresponds to a rendered
3735
/// frame).
3836
///
3937
/// `Time<Fixed>` and the generic [`Time`] resource will report a
@@ -45,21 +43,20 @@ use crate::{time::Time, virt::Virtual, FixedUpdate};
4543
/// means it is affected by [`pause()`](Time::pause),
4644
/// [`set_relative_speed()`](Time::set_relative_speed) and
4745
/// [`set_max_delta()`](Time::set_max_delta) from virtual time. If the virtual
48-
/// clock is paused, the [`FixedUpdate`](bevy_app::FixedUpdate) schedule will
49-
/// not run. It is guaranteed that the [`elapsed()`](Time::elapsed) time in
50-
/// `Time<Fixed>` is always between the previous `elapsed()` and the current
51-
/// `elapsed()` value in `Time<Virtual>`, so the values are compatible.
46+
/// clock is paused, the [`FixedUpdate`] schedule will not run. It is guaranteed
47+
/// that the [`elapsed()`](Time::elapsed) time in `Time<Fixed>` is always
48+
/// between the previous `elapsed()` and the current `elapsed()` value in
49+
/// `Time<Virtual>`, so the values are compatible.
5250
///
5351
/// Changing the timestep size while the game is running should not normally be
5452
/// done, as having a regular interval is the point of this schedule, but it may
5553
/// be necessary for effects like "bullet-time" if the normal granularity of the
5654
/// fixed timestep is too big for the slowed down time. In this case,
5755
/// [`set_timestep()`](Time::set_timestep) and be called to set a new value. The
58-
/// new value will be used immediately for the next run of the
59-
/// [`FixedUpdate`](bevy_app::FixedUpdate) schedule, meaning that it will affect
60-
/// the [`delta()`](Time::delta) value for the very next
61-
/// [`FixedUpdate`](bevy_app::FixedUpdate), even if it is still during the same
62-
/// frame. Any [`overstep()`](Time::overstep) present in the accumulator will be
56+
/// new value will be used immediately for the next run of the [`FixedUpdate`]
57+
/// schedule, meaning that it will affect the [`delta()`](Time::delta) value for
58+
/// the very next [`FixedUpdate`], even if it is still during the same frame.
59+
/// Any [`overstep()`](Time::overstep) present in the accumulator will be
6360
/// processed according to the new [`timestep()`](Time::timestep) value.
6461
#[derive(Debug, Copy, Clone, Reflect)]
6562
pub struct Fixed {
@@ -71,8 +68,7 @@ impl Time<Fixed> {
7168
/// Corresponds to 64 Hz.
7269
const DEFAULT_TIMESTEP: Duration = Duration::from_micros(15625);
7370

74-
/// Return new fixed time clock with given timestep as
75-
/// [`Duration`](std::time::Duration)
71+
/// Return new fixed time clock with given timestep as [`Duration`]
7672
///
7773
/// # Panics
7874
///
@@ -113,7 +109,7 @@ impl Time<Fixed> {
113109
}
114110

115111
/// Sets the amount of virtual time that must pass before the fixed timestep
116-
/// schedule is run again, as [`Duration`](std::time::Duration).
112+
/// schedule is run again, as [`Duration`].
117113
///
118114
/// Takes effect immediately on the next run of the schedule, respecting
119115
/// what is currently in [`Self::overstep`].
@@ -134,9 +130,8 @@ impl Time<Fixed> {
134130
/// Sets the amount of virtual time that must pass before the fixed timestep
135131
/// schedule is run again, as seconds.
136132
///
137-
/// Timestep is stored as a [`Duration`](std::time::Duration), which has
138-
/// fixed nanosecond resolution and will be converted from the floating
139-
/// point number.
133+
/// Timestep is stored as a [`Duration`], which has fixed nanosecond
134+
/// resolution and will be converted from the floating point number.
140135
///
141136
/// Takes effect immediately on the next run of the schedule, respecting
142137
/// what is currently in [`Self::overstep`].
@@ -157,8 +152,8 @@ impl Time<Fixed> {
157152
/// Sets the amount of virtual time that must pass before the fixed timestep
158153
/// schedule is run again, as frequency.
159154
///
160-
/// The timestep value is set to `1 / hz`, converted to a
161-
/// [`Duration`](std::time::Duration) which has fixed nanosecond resolution.
155+
/// The timestep value is set to `1 / hz`, converted to a [`Duration`] which
156+
/// has fixed nanosecond resolution.
162157
///
163158
/// Takes effect immediately on the next run of the schedule, respecting
164159
/// what is currently in [`Self::overstep`].
@@ -174,7 +169,7 @@ impl Time<Fixed> {
174169
}
175170

176171
/// Returns the amount of overstep time accumulated toward new steps, as
177-
/// [`Duration`](std::time::Duration).
172+
/// [`Duration`].
178173
#[inline]
179174
pub fn overstep(&self) -> Duration {
180175
self.context().overstep
@@ -221,8 +216,8 @@ impl Default for Fixed {
221216
}
222217
}
223218

224-
/// Runs [`FixedUpdate`](bevy_app::FixedUpdate) zero or more times based on
225-
/// delta of [`Time<Virtual>`](Virtual) and [`Time::overstep`]
219+
/// Runs [`FixedUpdate`] zero or more times based on delta of
220+
/// [`Time<Virtual>`](Virtual) and [`Time::overstep`]
226221
pub fn run_fixed_update_schedule(world: &mut World) {
227222
let delta = world.resource::<Time<Virtual>>().delta();
228223
world.resource_mut::<Time<Fixed>>().accumulate(delta);

crates/bevy_time/src/real.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl Time<Real> {
6565
self.update_with_instant(instant);
6666
}
6767

68-
/// Updates time with a specified [`Duration`](std::time::Duration).
68+
/// Updates time with a specified [`Duration`].
6969
///
7070
/// This method is provided for use in tests.
7171
///

crates/bevy_time/src/time.rs

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,28 @@ use bevy_ecs::{reflect::ReflectResource, system::Resource};
22
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
33
use bevy_utils::Duration;
44

5-
/// A generic clock resource that tracks how much it has advanced since its previous
6-
/// update and since its creation.
5+
/// A generic clock resource that tracks how much it has advanced since its
6+
/// previous update and since its creation.
77
///
88
/// Multiple instances of this resource are inserted automatically by
99
/// [`TimePlugin`](crate::TimePlugin):
1010
///
1111
/// - [`Time<Real>`](crate::real::Real) tracks real wall-clock time elapsed.
12-
/// - [`Time<Virtual>`](crate::virt::Virtual) tracks virtual game time that may be paused or scaled.
13-
/// - [`Time<Fixed>`](crate::fixed::Fixed) tracks fixed timesteps based on virtual time.
14-
/// - [`Time`] is a generic clock that corresponds to "current" or "default" time for systems. It
15-
/// contains [`Time<Virtual>`](crate::virt::Virtual) except inside the
16-
/// [`FixedUpdate`](bevy_app::FixedUpdate) schedule when it contains
17-
/// [`Time<Fixed>`](crate::fixed::Fixed).
12+
/// - [`Time<Virtual>`](crate::virt::Virtual) tracks virtual game time that may
13+
/// be paused or scaled.
14+
/// - [`Time<Fixed>`](crate::fixed::Fixed) tracks fixed timesteps based on
15+
/// virtual time.
16+
/// - [`Time`] is a generic clock that corresponds to "current" or "default"
17+
/// time for systems. It contains [`Time<Virtual>`](crate::virt::Virtual)
18+
/// except inside the [`FixedUpdate`](bevy_app::FixedUpdate) schedule when it
19+
/// contains [`Time<Fixed>`](crate::fixed::Fixed).
1820
///
19-
/// The time elapsed since the previous time this clock was advanced is saved
20-
/// as [`delta()`](Time::delta) and the total amount of time the clock has
21-
/// advanced is saved as [`elapsed()`](Time::elapsed). Both are represented
22-
/// as exact [`Duration`](std::time::Duration) values with fixed nanosecond
23-
/// precision. The clock does not support time moving backwards, but it can be
24-
/// updated with [`Duration::ZERO`](std::time::Duration::ZERO) which will set
25-
/// [`delta()`](Time::delta) to zero.
21+
/// The time elapsed since the previous time this clock was advanced is saved as
22+
/// [`delta()`](Time::delta) and the total amount of time the clock has advanced
23+
/// is saved as [`elapsed()`](Time::elapsed). Both are represented as exact
24+
/// [`Duration`] values with fixed nanosecond precision. The clock does not
25+
/// support time moving backwards, but it can be updated with [`Duration::ZERO`]
26+
/// which will set [`delta()`](Time::delta) to zero.
2627
///
2728
/// These values are also available in seconds as `f32` via
2829
/// [`delta_seconds()`](Time::delta_seconds) and
@@ -34,19 +35,19 @@ use bevy_utils::Duration;
3435
/// is `f32`, it will exhibit gradual precision loss. For applications that
3536
/// require an `f32` value but suffer from gradual precision loss there is
3637
/// [`elapsed_seconds_wrapped()`](Time::elapsed_seconds_wrapped) available. The
37-
/// same wrapped value is also available as [`Duration`](std::time::Duration)
38-
/// and `f64` for consistency. The wrap period is by default 1 hour, and can be
39-
/// set by [`set_wrap_period()`](Time::set_wrap_period).
38+
/// same wrapped value is also available as [`Duration`] and `f64` for
39+
/// consistency. The wrap period is by default 1 hour, and can be set by
40+
/// [`set_wrap_period()`](Time::set_wrap_period).
4041
///
4142
/// # Accessing clocks
4243
///
4344
/// By default, any systems requiring current [`delta()`](Time::delta) or
4445
/// [`elapsed()`](Time::elapsed) should use `Res<Time>` to access the default
4546
/// time configured for the program. By default, this refers to
46-
/// [`Time<Virtual>`](crate::virt::Virtual) except during
47-
/// the [`FixedUpdate`](bevy_app::FixedUpdate) schedule when it refers to
48-
/// [`Time<Fixed>`](crate::fixed::Fixed). This ensures your system can
49-
/// be used either in [`Update`](bevy_app::Update) or
47+
/// [`Time<Virtual>`](crate::virt::Virtual) except during the
48+
/// [`FixedUpdate`](bevy_app::FixedUpdate) schedule when it refers to
49+
/// [`Time<Fixed>`](crate::fixed::Fixed). This ensures your system can be used
50+
/// either in [`Update`](bevy_app::Update) or
5051
/// [`FixedUpdate`](bevy_app::FixedUpdate) schedule depending on what is needed.
5152
///
5253
/// ```
@@ -140,10 +141,9 @@ use bevy_utils::Duration;
140141
/// both your context and the generic time part, it's probably simplest to add a
141142
/// custom trait for them and implement it for `Time<Custom>`.
142143
///
143-
/// Your context struct will need to implement the
144-
/// [`Default`](std::default::Default) trait because [`Time`] structures support
145-
/// reflection. It also makes initialization trivial by being able to call
146-
/// `app.init_resource::<Time<Custom>>()`.
144+
/// Your context struct will need to implement the [`Default`] trait because
145+
/// [`Time`] structures support reflection. It also makes initialization trivial
146+
/// by being able to call `app.init_resource::<Time<Custom>>()`.
147147
///
148148
/// You can also replace the "generic" `Time` clock resource if the "default"
149149
/// time for your game should not be the default virtual time provided. You can
@@ -215,8 +215,7 @@ impl<T: Default> Time<T> {
215215
///
216216
/// The added duration will be returned by [`Self::delta`] and
217217
/// [`Self::elapsed`] will be increased by the duration. Adding
218-
/// [`Duration::ZERO`](std::time::Duration::ZERO) is allowed and will set
219-
/// [`Self::delta`] to zero.
218+
/// [`Duration::ZERO`] is allowed and will set [`Self::delta`] to zero.
220219
pub fn advance_by(&mut self, delta: Duration) {
221220
self.delta = delta;
222221
self.delta_seconds = self.delta.as_secs_f32();

crates/bevy_time/src/virt.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ impl Time<Virtual> {
8282
/// Equal to 250 milliseconds.
8383
const DEFAULT_MAX_DELTA: Duration = Duration::from_millis(250);
8484

85-
/// Create new virtual clock with given maximum delta step
86-
/// [`Duration`](std::time::Duration)
85+
/// Create new virtual clock with given maximum delta step [`Duration`]
8786
///
8887
/// # Panics
8988
///
@@ -95,7 +94,7 @@ impl Time<Virtual> {
9594
}
9695

9796
/// Returns the maximum amount of time that can be added to this clock by a
98-
/// single update, as [`Duration`](std::time::Duration).
97+
/// single update, as [`Duration`].
9998
///
10099
/// This is the maximum value [`Self::delta()`] will return and also to
101100
/// maximum time [`Self::elapsed()`] will be increased by in a single
@@ -112,7 +111,7 @@ impl Time<Virtual> {
112111
}
113112

114113
/// Sets the maximum amount of time that can be added to this clock by a
115-
/// single update, as [`Duration`](std::time::Duration).
114+
/// single update, as [`Duration`].
116115
///
117116
/// This is the maximum value [`Self::delta()`] will return and also to
118117
/// maximum time [`Self::elapsed()`] will be increased by in a single
@@ -124,11 +123,12 @@ impl Time<Virtual> {
124123
/// gameplay bugs or having to suddenly simulate all the intervening time.
125124
///
126125
/// If no updates happen for an extended amount of time, this limit prevents
127-
/// having a sudden, huge advance all at once. This also indirectly limits the
128-
/// maximum number of fixed update steps that can run in a single update.
126+
/// having a sudden, huge advance all at once. This also indirectly limits
127+
/// the maximum number of fixed update steps that can run in a single
128+
/// update.
129129
///
130-
/// The default value is 250 milliseconds. If you want to disable this feature,
131-
/// set the value to [`Duration::MAX`](std::time::Duration).
130+
/// The default value is 250 milliseconds. If you want to disable this
131+
/// feature, set the value to [`Duration::MAX`].
132132
///
133133
/// # Panics
134134
///

0 commit comments

Comments
 (0)