Skip to content

Commit

Permalink
Fix doc errors after bevyengine#10193, bevyengine#13152 and bevyengin…
Browse files Browse the repository at this point in the history
  • Loading branch information
SkiFire13 committed Jul 11, 2024
1 parent 0558bf8 commit b16330d
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 19 deletions.
21 changes: 12 additions & 9 deletions crates/bevy_ecs/src/event/event_cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ pub type ManualEventReader<E> = EventCursor<E>;
///
/// # bevy_ecs::system::assert_is_system(send_and_receive_events);
/// ```
///
/// [`EventReader`]: super::EventReader
/// [`EventMutator`]: super::EventMutator
#[derive(Debug)]
pub struct EventCursor<E: Event> {
pub(super) last_event_count: usize,
Expand All @@ -84,42 +87,42 @@ impl<E: Event> Clone for EventCursor<E> {

#[allow(clippy::len_without_is_empty)] // Check fails since the is_empty implementation has a signature other than `(&self) -> bool`
impl<E: Event> EventCursor<E> {
/// See [`EventReader::read`]
/// See [`EventReader::read`](super::EventReader::read)
pub fn read<'a>(&'a mut self, events: &'a Events<E>) -> EventIterator<'a, E> {
self.read_with_id(events).without_id()
}

/// See [`EventMutator::read`]
/// See [`EventMutator::read`](super::EventMutator::read)
pub fn read_mut<'a>(&'a mut self, events: &'a mut Events<E>) -> EventMutIterator<'a, E> {
self.read_mut_with_id(events).without_id()
}

/// See [`EventReader::read_with_id`]
/// See [`EventReader::read_with_id`](super::EventReader::read_with_id)
pub fn read_with_id<'a>(&'a mut self, events: &'a Events<E>) -> EventIteratorWithId<'a, E> {
EventIteratorWithId::new(self, events)
}

/// See [`EventMutator::read_with_id`]
/// See [`EventMutator::read_with_id`](super::EventMutator::read_with_id)
pub fn read_mut_with_id<'a>(
&'a mut self,
events: &'a mut Events<E>,
) -> EventMutIteratorWithId<'a, E> {
EventMutIteratorWithId::new(self, events)
}

/// See [`EventReader::par_read`]
/// See [`EventReader::par_read`](super::EventReader::par_read)
#[cfg(feature = "multi_threaded")]
pub fn par_read<'a>(&'a mut self, events: &'a Events<E>) -> EventParIter<'a, E> {
EventParIter::new(self, events)
}

/// See [`EventMutator::par_read`]
/// See [`EventMutator::par_read`](super::EventMutator::par_read)
#[cfg(feature = "multi_threaded")]
pub fn par_read_mut<'a>(&'a mut self, events: &'a mut Events<E>) -> EventMutParIter<'a, E> {
EventMutParIter::new(self, events)
}

/// See [`EventReader::len`]
/// See [`EventReader::len`](super::EventReader::len)
pub fn len(&self, events: &Events<E>) -> usize {
// The number of events in this reader is the difference between the most recent event
// and the last event seen by it. This will be at most the number of events contained
Expand All @@ -138,12 +141,12 @@ impl<E: Event> EventCursor<E> {
.saturating_sub(self.last_event_count)
}

/// See [`EventReader::is_empty()`]
/// See [`EventReader::is_empty()`](super::EventReader::is_empty)
pub fn is_empty(&self, events: &Events<E>) -> bool {
self.len(events) == 0
}

/// See [`EventReader::clear()`]
/// See [`EventReader::clear()`](super::EventReader::clear)
pub fn clear(&mut self, events: &Events<E>) {
self.last_event_count = events.event_count;
}
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_ecs/src/event/mut_iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use bevy_utils::detailed_trace;
use std::{iter::Chain, slice::IterMut};

/// An iterator that yields any unread events from an [`EventMutator`] or [`EventCursor`].
///
/// [`EventMutator`]: super::EventMutator
#[derive(Debug)]
pub struct EventMutIterator<'a, E: Event> {
iter: EventMutIteratorWithId<'a, E>,
Expand Down Expand Up @@ -44,6 +46,8 @@ impl<'a, E: Event> ExactSizeIterator for EventMutIterator<'a, E> {
}

/// An iterator that yields any unread events (and their IDs) from an [`EventMutator`] or [`EventCursor`].
///
/// [`EventMutator`]: super::EventMutator
#[derive(Debug)]
pub struct EventMutIteratorWithId<'a, E: Event> {
mutator: &'a mut EventCursor<E>,
Expand Down
6 changes: 4 additions & 2 deletions crates/bevy_ecs/src/event/mutator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ use bevy_ecs::{
/// Most of the time systems will want to use [`EventMutator::read()`]. This function creates an iterator over
/// all events that haven't been read yet by this system, marking the event as read in the process.
///
/// [`EventReader`]: super::EventReader
/// [`EventWriter`]: super::EventWriter
#[derive(SystemParam, Debug)]
pub struct EventMutator<'w, 's, E: Event> {
pub(super) reader: Local<'s, EventCursor<E>>,
Expand All @@ -54,13 +56,13 @@ impl<'w, 's, E: Event> EventMutator<'w, 's, E> {
self.reader.read_mut(&mut self.events)
}

/// Like [`read`](Self::read), except also returning the [`EventId`] of the events.
/// Like [`read`](Self::read), except also returning the [`EventId`](super::EventId) of the events.
pub fn read_with_id(&mut self) -> EventMutIteratorWithId<'_, E> {
self.reader.read_mut_with_id(&mut self.events)
}

/// Returns a parallel iterator over the events this [`EventMutator`] has not seen yet.
/// See also [`for_each`](EventParIter::for_each).
/// See also [`for_each`](super::EventParIter::for_each).
///
/// # Example
/// ```
Expand Down
5 changes: 3 additions & 2 deletions crates/bevy_reflect/src/func/args/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::TypePath;

/// Type information for an [`Arg`] used in a [`DynamicFunction`].
///
/// [`Arg`]: crate::func::args::Arg
/// [`DynamicFunction`]: super::function::DynamicFunction
/// [`Arg`]: crate::func::Arg
/// [`DynamicFunction`]: crate::func::DynamicFunction
#[derive(Debug, Clone)]
pub struct ArgInfo {
/// The index of the argument within its function.
Expand Down Expand Up @@ -57,6 +57,7 @@ impl ArgInfo {
/// For [`DynamicFunctions`] created using [`IntoFunction`], the name will always be `None`.
///
/// [`DynamicFunctions`]: crate::func::DynamicFunction
/// [`IntoFunction`]: crate::func::IntoFunction
pub fn name(&self) -> Option<&str> {
self.name.as_deref()
}
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_reflect/src/func/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ impl FunctionInfo {
/// the name will always be the full path to the function as returned by [`std::any::type_name`].
///
/// [`DynamicFunctions`]: crate::func::DynamicFunction
/// [`IntoFunction`]: crate::func::IntoFunction
pub fn name(&self) -> Option<&str> {
self.name.as_deref()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_text/src/font_atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::{GlyphAtlasLocation, TextError};
/// providing a trade-off between visual quality and performance.
///
/// A [`CacheKey`](cosmic_text::CacheKey) encodes all of the information of a subpixel-offset glyph and is used to
/// find that glyphs raster in a [`TextureAtlas`] through its corresponding [`GlyphAtlasLocation`].
/// find that glyphs raster in a [`TextureAtlas`](bevy_sprite::TextureAtlas) through its corresponding [`GlyphAtlasLocation`].
pub struct FontAtlas {
/// Used to update the [`TextureAtlasLayout`].
pub dynamic_texture_atlas_builder: DynamicTextureAtlasBuilder,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_text/src/font_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bevy_asset::{io::Reader, AssetLoader, LoadContext};
use thiserror::Error;

#[derive(Default)]
/// An [`AssetLoader`] for [`Font`]s, for use by the [`AssetServer`]
/// An [`AssetLoader`] for [`Font`]s, for use by the [`AssetServer`](bevy_asset::AssetServer)
pub struct FontLoader;

/// Possible errors that can be produced by [`FontLoader`]
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_text/src/glyph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ impl PositionedGlyph {
pub struct GlyphAtlasInfo {
/// A handle to the [`Image`] data for the texture atlas this glyph was placed in.
///
/// A (weak) clone of the handle held by the [`FontAtlas`].
/// A (weak) clone of the handle held by the [`FontAtlas`](crate::FontAtlas).
pub texture: Handle<Image>,
/// A handle to the [`TextureAtlasLayout`] map for the texture atlas this glyph was placed in.
///
/// A (weak) clone of the handle held by the [`FontAtlas`].
/// A (weak) clone of the handle held by the [`FontAtlas`](crate::FontAtlas).
pub texture_atlas: Handle<TextureAtlasLayout>,
/// Location and offset of a glyph within the texture atlas.
pub location: GlyphAtlasLocation,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_text/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//! Note that text measurement is only relevant in a UI context.
//!
//! With the actual text bounds defined, the `bevy_ui::widget::text::text_system` system (in a UI context)
//! or [`bevy_text::text2d::update_text2d_layout`] system (in a 2d world space context)
//! or [`text2d::update_text2d_layout`] system (in a 2d world space context)
//! passes it into [`TextPipeline::queue_text`], which:
//!
//! 1. creates a [`Buffer`](cosmic_text::Buffer) from the [`TextSection`]s, generating new [`FontAtlasSet`]s if necessary.
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_text/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ fn load_font_to_fontdb(
});
}

/// Translates [`TextSection`] to [`Attrs`](cosmic_text::attrs::Attrs),
/// Translates [`TextSection`] to [`Attrs`],
/// loading fonts into the [`Database`](cosmic_text::fontdb::Database) if required.
fn get_attrs<'a>(
section: &TextSection,
Expand Down

0 comments on commit b16330d

Please sign in to comment.