Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve doc formatting. #9840

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/fxaa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct Fxaa {

/// Use lower sensitivity for a sharper, faster, result.
/// Use higher sensitivity for a slower, smoother, result.
/// [Ultra](`Sensitivity::Ultra`) and [Extreme](`Sensitivity::Extreme`)
/// [`Ultra`](`Sensitivity::Ultra`) and [`Extreme`](`Sensitivity::Extreme`)
/// settings can result in significant smearing and loss of detail.

/// The minimum amount of local contrast required to apply algorithm.
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_diagnostic/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{borrow::Cow, collections::VecDeque};

use crate::MAX_DIAGNOSTIC_NAME_WIDTH;

/// Unique identifier for a [Diagnostic]
/// Unique identifier for a [`Diagnostic`].
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, PartialOrd, Ord)]
pub struct DiagnosticId(pub Uuid);

Expand All @@ -22,7 +22,7 @@ impl Default for DiagnosticId {
}
}

/// A single measurement of a [Diagnostic]
/// A single measurement of a [`Diagnostic`].
#[derive(Debug)]
pub struct DiagnosticMeasurement {
pub time: Instant,
Expand Down Expand Up @@ -195,7 +195,7 @@ impl Diagnostic {
}
}

/// A collection of [Diagnostic]s
/// A collection of [`Diagnostic`]s.
#[derive(Debug, Default, Resource)]
pub struct DiagnosticsStore {
// This uses a [`StableHashMap`] to ensure that the iteration order is deterministic between
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_ecs/src/reflect/entity_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn insert_reflect(
pub struct InsertReflect {
/// The entity on which the component will be inserted.
pub entity: Entity,
/// The reflect [Component](crate::component::Component) that will be added to the entity.
/// The reflect [`Component`](crate::component::Component) that will be added to the entity.
pub component: Box<dyn Reflect>,
}

Expand All @@ -228,7 +228,7 @@ pub struct InsertReflectWithRegistry<T: Resource + AsRef<TypeRegistry>> {
/// The entity on which the component will be inserted.
pub entity: Entity,
pub _t: PhantomData<T>,
/// The reflect [Component](crate::component::Component) that will be added to the entity.
/// The reflect [`Component`](crate::component::Component) that will be added to the entity.
pub component: Box<dyn Reflect>,
}

Expand Down Expand Up @@ -267,7 +267,7 @@ fn remove_reflect(
pub struct RemoveReflect {
/// The entity from which the component will be removed.
pub entity: Entity,
/// The [Component](crate::component::Component) type name that will be used to remove a component
/// The [`Component`](crate::component::Component) type name that will be used to remove a component
/// of the same type from the entity.
pub component_type_name: Cow<'static, str>,
}
Expand All @@ -292,7 +292,7 @@ pub struct RemoveReflectWithRegistry<T: Resource + AsRef<TypeRegistry>> {
/// The entity from which the component will be removed.
pub entity: Entity,
pub _t: PhantomData<T>,
/// The [Component](crate::component::Component) type name that will be used to remove a component
/// The [`Component`](crate::component::Component) type name that will be used to remove a component
/// of the same type from the entity.
pub component_type_name: Cow<'static, str>,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub use resource::*;
pub use sparse_set::*;
pub use table::*;

/// The raw data stores of a [World](crate::world::World)
/// The raw data stores of a [`World`](crate::world::World)
#[derive(Default)]
pub struct Storages {
/// Backing storage for [`SparseSet`] components.
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/storage/sparse_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<I: SparseSetIndex, V> SparseArray<I, V> {
}
}

/// A sparse data structure of [Components](crate::component::Component)
/// A sparse data structure of [`Component`](crate::component::Component)s.
///
/// Designed for relatively fast insertions and deletions.
#[derive(Debug)]
Expand Down
73 changes: 37 additions & 36 deletions crates/bevy_ecs/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ use self::unsafe_world_cell::{UnsafeEntityCell, UnsafeWorldCell};
/// Stores and exposes operations on [entities](Entity), [components](Component), resources,
/// and their associated metadata.
///
/// Each [Entity] has a set of components. Each component can have up to one instance of each
/// Each [`Entity`] has a set of components. Each component can have up to one instance of each
/// component type. Entity components can be created, updated, removed, and queried using a given
/// [World].
/// [`World`].
///
/// For complex access patterns involving [`SystemParam`](crate::system::SystemParam),
/// consider using [`SystemState`](crate::system::SystemState).
Expand Down Expand Up @@ -94,7 +94,8 @@ impl Default for World {
}

impl World {
/// Creates a new empty [World]
/// Creates a new empty [`World`].
///
/// # Panics
///
/// If [`usize::MAX`] [`World`]s have been created.
Expand Down Expand Up @@ -123,13 +124,13 @@ impl World {
UnsafeWorldCell::new_readonly(self)
}

/// Retrieves this world's [Entities] collection
/// Retrieves this world's [`Entities`] collection.
#[inline]
pub fn entities(&self) -> &Entities {
&self.entities
}

/// Retrieves this world's [Entities] collection mutably
/// Retrieves this world's [`Entities`] collection mutably.
///
/// # Safety
/// Mutable reference must not be used to put the [`Entities`] data
Expand All @@ -139,25 +140,25 @@ impl World {
&mut self.entities
}

/// Retrieves this world's [Archetypes] collection
/// Retrieves this world's [`Archetypes`] collection.
#[inline]
pub fn archetypes(&self) -> &Archetypes {
&self.archetypes
}

/// Retrieves this world's [Components] collection
/// Retrieves this world's [`Components`] collection.
#[inline]
pub fn components(&self) -> &Components {
&self.components
}

/// Retrieves this world's [Storages] collection
/// Retrieves this world's [`Storages`] collection.
#[inline]
pub fn storages(&self) -> &Storages {
&self.storages
}

/// Retrieves this world's [Bundles] collection
/// Retrieves this world's [`Bundles`] collection.
#[inline]
pub fn bundles(&self) -> &Bundles {
&self.bundles
Expand Down Expand Up @@ -767,10 +768,10 @@ impl World {
EntityWorldMut::new(self, entity, location)
}

/// Spawns a batch of entities with the same component [Bundle] type. Takes a given [Bundle]
/// iterator and returns a corresponding [Entity] iterator.
/// Spawns a batch of entities with the same component [`Bundle`] type. Takes a given
/// [`Bundle`] iterator and returns a corresponding [`Entity`] iterator.
/// This is more efficient than spawning entities and adding components to them individually,
/// but it is limited to spawning entities with the same [Bundle] type, whereas spawning
/// but it is limited to spawning entities with the same [`Bundle`] type, whereas spawning
/// individually is more flexible.
///
/// ```
Expand All @@ -797,8 +798,8 @@ impl World {
SpawnBatchIter::new(self, iter.into_iter())
}

/// Retrieves a reference to the given `entity`'s [Component] of the given type.
/// Returns [None] if the `entity` does not have a [Component] of the given type.
/// Retrieves a reference to the given `entity`'s [`Component`] of the given type.
/// Returns `None` if the `entity` does not have a [`Component`] of the given type.
/// ```
/// use bevy_ecs::{component::Component, world::World};
///
Expand All @@ -818,8 +819,8 @@ impl World {
self.get_entity(entity)?.get()
}

/// Retrieves a mutable reference to the given `entity`'s [Component] of the given type.
/// Returns [None] if the `entity` does not have a [Component] of the given type.
/// Retrieves a mutable reference to the given `entity`'s [`Component`] of the given type.
/// Returns `None` if the `entity` does not have a [`Component`] of the given type.
/// ```
/// use bevy_ecs::{component::Component, world::World};
///
Expand All @@ -844,7 +845,7 @@ impl World {
}

/// Despawns the given `entity`, if it exists. This will also remove all of the entity's
/// [Component]s. Returns `true` if the `entity` is successfully despawned and `false` if
/// [`Component`]s. Returns `true` if the `entity` is successfully despawned and `false` if
/// the `entity` does not exist.
/// ```
/// use bevy_ecs::{component::Component, world::World};
Expand Down Expand Up @@ -952,7 +953,7 @@ impl World {
/// To iterate over entities in a deterministic order,
/// sort the results of the query using the desired component as a key.
/// Note that this requires fetching the whole result set from the query
/// and allocation of a [Vec] to store it.
/// and allocation of a [`Vec`] to store it.
///
/// ```
/// use bevy_ecs::{component::Component, entity::Entity, world::World};
Expand Down Expand Up @@ -1122,7 +1123,7 @@ impl World {
});
}

/// Removes the resource of a given type and returns it, if it exists. Otherwise returns [None].
/// Removes the resource of a given type and returns it, if it exists. Otherwise returns `None`.
#[inline]
pub fn remove_resource<R: Resource>(&mut self) -> Option<R> {
let component_id = self.components.get_resource_id(TypeId::of::<R>())?;
Expand Down Expand Up @@ -1345,7 +1346,7 @@ impl World {
}

/// Gets a reference to the non-send resource of the given type, if it exists.
/// Otherwise returns [None].
/// Otherwise returns `None`.
///
/// # Panics
/// This function will panic if it isn't called from the same thread that the resource was inserted from.
Expand All @@ -1358,7 +1359,7 @@ impl World {
}

/// Gets a mutable reference to the non-send resource of the given type, if it exists.
/// Otherwise returns [None]
/// Otherwise returns `None`.
///
/// # Panics
/// This function will panic if it isn't called from the same thread that the resource was inserted from.
Expand Down Expand Up @@ -1390,12 +1391,12 @@ impl World {
Some(resource.id())
}

/// For a given batch of ([Entity], [Bundle]) pairs, either spawns each [Entity] with the given
/// bundle (if the entity does not exist), or inserts the [Bundle] (if the entity already exists).
/// For a given batch of ([`Entity`], [`Bundle`]) pairs, either spawns each [`Entity`] with the given
/// bundle (if the entity does not exist), or inserts the [`Bundle`] (if the entity already exists).
/// This is faster than doing equivalent operations one-by-one.
/// Returns [Ok] if all entities were successfully inserted into or spawned. Otherwise it returns an [Err]
/// Returns `Ok` if all entities were successfully inserted into or spawned. Otherwise it returns an `Err`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Returns `Ok` if all entities were successfully inserted into or spawned. Otherwise it returns an `Err`
/// Returns `Ok()` if all entities were successfully inserted into or spawned. Otherwise it returns an `Err`

/// with a list of entities that could not be spawned or inserted into. A "spawn or insert" operation can
/// only fail if an [Entity] is passed in with an "invalid generation" that conflicts with an existing [Entity].
/// only fail if an [`Entity`] is passed in with an "invalid generation" that conflicts with an existing [`Entity`].
///
/// # Note
/// Spawning a specific `entity` value is rarely the right choice. Most apps should use [`World::spawn_batch`].
Expand Down Expand Up @@ -1702,9 +1703,9 @@ impl World {
component_id
}

/// Empties queued entities and adds them to the empty [Archetype](crate::archetype::Archetype).
/// Empties queued entities and adds them to the empty [`Archetype`](crate::archetype::Archetype).
/// This should be called before doing operations that might operate on queued entities,
/// such as inserting a [Component].
/// such as inserting a [`Component`].
pub(crate) fn flush(&mut self) {
let empty_archetype = self.archetypes.empty_mut();
let table = &mut self.storages.tables[empty_archetype.table_id()];
Expand Down Expand Up @@ -1807,7 +1808,7 @@ impl World {

/// Clears all resources in this [`World`].
///
/// **Note:** Any resource fetch to this [World] will fail unless they are re-initialized,
/// **Note:** Any resource fetch to this [`World`] will fail unless they are re-initialized,
/// including engine-internal resources that are only initialized on app/world construction.
///
/// This can easily cause systems expecting certain resources to immediately start panicking.
Expand Down Expand Up @@ -1893,7 +1894,7 @@ impl World {
}
}

/// Removes the resource of a given type, if it exists. Otherwise returns [None].
/// Removes the resource of a given type, if it exists. Otherwise returns `None`.
///
/// **You should prefer to use the typed API [`World::remove_resource`] where possible and only
/// use this in cases where the actual types are not known at compile time.**
Expand All @@ -1905,7 +1906,7 @@ impl World {
Some(())
}

/// Removes the resource of a given type, if it exists. Otherwise returns [None].
/// Removes the resource of a given type, if it exists. Otherwise returns `None`.
///
/// **You should prefer to use the typed API [`World::remove_resource`] where possible and only
/// use this in cases where the actual types are not known at compile time.**
Expand All @@ -1920,8 +1921,8 @@ impl World {
Some(())
}

/// Retrieves an immutable untyped reference to the given `entity`'s [Component] of the given [`ComponentId`].
/// Returns [None] if the `entity` does not have a [Component] of the given type.
/// Retrieves an immutable untyped reference to the given `entity`'s [`Component`] of the given [`ComponentId`].
/// Returns `None` if the `entity` does not have a [`Component`] of the given type.
///
/// **You should prefer to use the typed API [`World::get_mut`] where possible and only
/// use this in cases where the actual types are not known at compile time.**
Expand All @@ -1940,8 +1941,8 @@ impl World {
}
}

/// Retrieves a mutable untyped reference to the given `entity`'s [Component] of the given [`ComponentId`].
/// Returns [None] if the `entity` does not have a [Component] of the given type.
/// Retrieves a mutable untyped reference to the given `entity`'s [`Component`] of the given [`ComponentId`].
/// Returns `None` if the `entity` does not have a [`Component`] of the given type.
///
/// **You should prefer to use the typed API [`World::get_mut`] where possible and only
/// use this in cases where the actual types are not known at compile time.**
Expand Down Expand Up @@ -2103,11 +2104,11 @@ unsafe impl Send for World {}
unsafe impl Sync for World {}

/// Creates an instance of the type this trait is implemented for
/// using data from the supplied [World].
/// using data from the supplied [`World`].
///
/// This can be helpful for complex initialization or context-aware defaults.
pub trait FromWorld {
/// Creates `Self` using data from the given [World]
/// Creates `Self` using data from the given [`World`].
fn from_world(world: &mut World) -> Self;
}

Expand Down
12 changes: 6 additions & 6 deletions crates/bevy_ecs/src/world/unsafe_world_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,31 +200,31 @@ impl<'w> UnsafeWorldCell<'w> {
unsafe { self.world_metadata() }.id()
}

/// Retrieves this world's [Entities] collection
/// Retrieves this world's [`Entities`] collection.
#[inline]
pub fn entities(self) -> &'w Entities {
// SAFETY:
// - we only access world metadata
&unsafe { self.world_metadata() }.entities
}

/// Retrieves this world's [Archetypes] collection
/// Retrieves this world's [`Archetypes`] collection.
#[inline]
pub fn archetypes(self) -> &'w Archetypes {
// SAFETY:
// - we only access world metadata
&unsafe { self.world_metadata() }.archetypes
}

/// Retrieves this world's [Components] collection
/// Retrieves this world's [`Components`] collection.
#[inline]
pub fn components(self) -> &'w Components {
// SAFETY:
// - we only access world metadata
&unsafe { self.world_metadata() }.components
}

/// Retrieves this world's [Bundles] collection
/// Retrieves this world's [`Bundles`] collection.
#[inline]
pub fn bundles(self) -> &'w Bundles {
// SAFETY:
Expand Down Expand Up @@ -838,8 +838,8 @@ impl<'w> UnsafeEntityCell<'w> {
}
}

/// Retrieves a mutable untyped reference to the given `entity`'s [Component] of the given [`ComponentId`].
/// Returns [None] if the `entity` does not have a [Component] of the given type.
/// Retrieves a mutable untyped reference to the given `entity`'s [`Component`] of the given [`ComponentId`].
/// Returns `None` if the `entity` does not have a [`Component`] of the given type.
///
/// **You should prefer to use the typed API [`UnsafeEntityCell::get_mut`] where possible and only
/// use this in cases where the actual types are not known at compile time.**
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_input/src/axis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ where
///
/// If the `input_device`:
/// - was present before, the position data is updated, and the old value is returned.
/// - wasn't present before, [None] is returned.
/// - wasn't present before, `None` is returned.
pub fn set(&mut self, input_device: T, position_data: f32) -> Option<f32> {
self.axis_data.insert(input_device, position_data)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/wireframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub struct Wireframe;
#[derive(Resource, Debug, Clone, Default, ExtractResource, Reflect)]
#[reflect(Resource)]
pub struct WireframeConfig {
/// Whether to show wireframes for all meshes. If `false`, only meshes with a [Wireframe] component will be rendered.
/// Whether to show wireframes for all meshes. If `false`, only meshes with a [`Wireframe`] component will be rendered.
pub global: bool,
}

Expand Down
Loading