Skip to content

Commit d043dcc

Browse files
committed
1 parent c5717b5 commit d043dcc

File tree

11 files changed

+44
-0
lines changed

11 files changed

+44
-0
lines changed

crates/bevy_ecs/src/component.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ impl<T: Send + Sync + 'static> Component for T {}
3535
/// let mut world = World::default();
3636
/// world.register_component(ComponentDescriptor::new::<A>(StorageType::SparseSet));
3737
/// ```
38+
///
39+
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/bevy_ecs/examples/component_storage.rs)
3840
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
3941
pub enum StorageType {
4042
/// Provides fast and cache-friendly iteration, but slower addition and removal of components.

crates/bevy_ecs/src/event.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ enum State {
118118
/// but can be done by adding your event as a resource instead of using [`App::add_event`].
119119
///
120120
/// [`App::add_event`]: https://docs.rs/bevy/*/bevy/app/struct.App.html#method.add_event
121+
///
122+
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/bevy_ecs/examples/events.rs)
121123
#[derive(Debug)]
122124
pub struct Events<T> {
123125
events_a: Vec<EventInstance<T>>,
@@ -150,13 +152,21 @@ fn map_instance_event<T>(event_instance: &EventInstance<T>) -> &T {
150152
}
151153

152154
/// Reads events of type `T` in order and tracks which events have already been read.
155+
///
156+
/// [Simple example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/ecs/event.rs)
157+
///
158+
/// [Detailed example usage.](https://github.com/bevyengine/bevy/blob/latest/bevy_ecs/examples/events.rs)
153159
#[derive(SystemParam)]
154160
pub struct EventReader<'w, 's, T: Component> {
155161
last_event_count: Local<'s, (usize, PhantomData<T>)>,
156162
events: Res<'w, Events<T>>,
157163
}
158164

159165
/// Sends events of type `T`.
166+
///
167+
/// [Simple example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/ecs/event.rs)
168+
///
169+
/// [Detailed example usage.](https://github.com/bevyengine/bevy/blob/latest/bevy_ecs/examples/events.rs)
160170
#[derive(SystemParam)]
161171
pub struct EventWriter<'w, 's, T: Component> {
162172
events: ResMut<'w, Events<T>>,

crates/bevy_ecs/src/query/filter.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ impl_tick_filter!(
612612
///
613613
/// # print_add_name_component.system();
614614
/// ```
615+
///
616+
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/bevy_ecs/examples/change_detection.rs)
615617
Added,
616618
/// The [`FetchState`] of [`Added`].
617619
AddedState,
@@ -653,6 +655,10 @@ impl_tick_filter!(
653655
///
654656
/// # print_moving_objects_system.system();
655657
/// ```
658+
///
659+
/// [Simple example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/ecs/component_change_detection.rs)
660+
///
661+
/// [Detailed example usage.](https://github.com/bevyengine/bevy/blob/latest/bevy_ecs/examples/change_detection.rs)
656662
Changed,
657663
/// The [`FetchState`] of [`Changed`].
658664
ChangedState,

crates/bevy_input/src/keyboard.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use bevy_app::EventReader;
33
use bevy_ecs::system::ResMut;
44

55
/// A key input event from a keyboard device
6+
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/input/keyboard_input_event.rs)
67
#[derive(Debug, Clone)]
78
pub struct KeyboardInput {
89
pub scan_code: u32,

crates/bevy_math/src/geometry.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use glam::Vec2;
33
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
44

55
/// A two dimensional "size" as defined by a width and height
6+
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/ui/ui.rs)
67
#[derive(Copy, Clone, PartialEq, Debug, Reflect)]
78
#[reflect(PartialEq)]
89
pub struct Size<T: Reflect + PartialEq = f32> {
@@ -26,6 +27,7 @@ impl<T: Default + Reflect + PartialEq> Default for Size<T> {
2627
}
2728

2829
/// A rect, as defined by its "side" locations
30+
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/ui/ui.rs)
2931
#[derive(Copy, Clone, PartialEq, Debug, Reflect)]
3032
#[reflect(PartialEq)]
3133
pub struct Rect<T: Reflect + PartialEq> {

crates/bevy_pbr/src/entity.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use bevy_render::{
1111
use bevy_transform::prelude::{GlobalTransform, Transform};
1212

1313
/// A component bundle for "pbr mesh" entities
14+
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/3d/pbr.rs)
1415
#[derive(Bundle)]
1516
pub struct PbrBundle {
1617
pub mesh: Handle<Mesh>,
@@ -41,6 +42,7 @@ impl Default for PbrBundle {
4142
}
4243

4344
/// A component bundle for "light" entities
45+
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/3d/pbr.rs)
4446
#[derive(Debug, Bundle, Default)]
4547
pub struct PointLightBundle {
4648
pub point_light: PointLight,

crates/bevy_pbr/src/light.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ impl DirectionalLightUniform {
153153
}
154154

155155
// Ambient light color.
156+
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/3d/load_gltf.rs)
156157
#[derive(Debug)]
157158
pub struct AmbientLight {
158159
pub color: Color,

crates/bevy_pbr/src/material.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use bevy_render::{color::Color, renderer::RenderResources, shader::ShaderDefs, t
44

55
/// A material with "standard" properties used in PBR lighting
66
/// Standard property values with pictures here https://google.github.io/filament/Material%20Properties.pdf
7+
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/3d/texture.rs)
78
#[derive(Debug, RenderResources, ShaderDefs, TypeUuid)]
89
#[uuid = "dace545e-4bc6-4595-a79d-c224fc694975"]
910
pub struct StandardMaterial {

crates/bevy_render/src/entity.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use bevy_ecs::bundle::Bundle;
1414
use bevy_transform::components::{GlobalTransform, Transform};
1515

1616
/// A component bundle for "mesh" entities
17+
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/shader/array_texture.rs)
1718
#[derive(Bundle, Default)]
1819
pub struct MeshBundle {
1920
pub mesh: Handle<Mesh>,
@@ -28,6 +29,7 @@ pub struct MeshBundle {
2829
/// Component bundle for camera entities with perspective projection
2930
///
3031
/// Use this for 3D rendering.
32+
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/3d/3d_scene.rs)
3133
#[derive(Bundle)]
3234
pub struct PerspectiveCameraBundle {
3335
pub camera: Camera,
@@ -74,6 +76,8 @@ impl Default for PerspectiveCameraBundle {
7476
/// Component bundle for camera entities with orthographic projection
7577
///
7678
/// Use this for 2D games, isometric games, CAD-like 3D views.
79+
/// [Example usage in 2D.](https://github.com/bevyengine/bevy/blob/latest/examples/3d/orthographic.rs)
80+
/// [Example usage in 3D.](https://github.com/bevyengine/bevy/blob/latest/examples/3d/orthographic.rs)
7781
#[derive(Bundle)]
7882
pub struct OrthographicCameraBundle {
7983
pub camera: Camera,
@@ -84,6 +88,7 @@ pub struct OrthographicCameraBundle {
8488
}
8589

8690
impl OrthographicCameraBundle {
91+
/// [Example usage](https://github.com/bevyengine/bevy/blob/latest/examples/2d/sprite.rs)
8792
pub fn new_2d() -> Self {
8893
// we want 0 to be "closest" and +far to be "farthest" in 2d, so we offset
8994
// the camera's translation by far and use a right handed coordinate system
@@ -104,6 +109,7 @@ impl OrthographicCameraBundle {
104109
}
105110
}
106111

112+
/// [Example usage](https://github.com/bevyengine/bevy/blob/latest/examples/3d/orthographic.rs)
107113
pub fn new_3d() -> Self {
108114
OrthographicCameraBundle {
109115
camera: Camera {

crates/bevy_render/src/render_graph/base.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ use bevy_reflect::Reflect;
1515
use bevy_window::WindowId;
1616

1717
/// A component that indicates that an entity should be drawn in the "main pass"
18+
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/window/multiple_windows.rs)
1819
#[derive(Clone, Debug, Default, Reflect)]
1920
#[reflect(Component)]
2021
pub struct MainPass;
2122

23+
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/3d/msaa.rs)
2224
#[derive(Debug)]
2325
pub struct Msaa {
2426
pub samples: u32,
@@ -31,6 +33,7 @@ impl Default for Msaa {
3133
}
3234

3335
impl Msaa {
36+
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/window/multiple_windows.rs)
3437
pub fn color_attachment(
3538
&self,
3639
attachment: TextureAttachment,

examples/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ git checkout v0.4.0
4545
- [Audio](#audio)
4646
- [Diagnostics](#diagnostics)
4747
- [ECS (Entity Component System)](#ecs-entity-component-system)
48+
- [Examples inside bevy_ecs sub-crate](#examples-inside-bevy_ecs-sub-crate)
4849
- [Games](#games)
4950
- [Input](#input)
5051
- [Reflection](#reflection)
@@ -170,6 +171,15 @@ Example | File | Description
170171
`system_sets` | [`ecs/system_sets.rs`](./ecs/system_sets.rs) | Shows `SystemSet` use along with run criterion
171172
`timers` | [`ecs/timers.rs`](./ecs/timers.rs) | Illustrates ticking `Timer` resources inside systems and handling their state
172173

174+
## Examples inside bevy_ecs sub-crate
175+
176+
Example | File | Description
177+
--- | --- | ---
178+
`change_detection` | [`crates/bevy_ecs/examples/change_detecion.rs`](../crates/bevy_ecs/examples/change_detecion.rs) | Detailed example of change detection
179+
`component_storage` | [`crates/bevy_ecs/examples/component_storage.rs`](../crates/bevy_ecs/examples/component_storage.rs) | Detailed example of different storage mechanisms
180+
`events` | [`crates/bevy_ecs/examples/events.rs`](../crates/bevy_ecs/examples/events.rs) | Illustrates event creation, activation, and reception
181+
`resources` | [`crates/bevy_ecs/examples/resources.rs`](../crates/bevy_ecs/examples/resources.rs) | Detailed example of resource creation and usage
182+
173183
## Games
174184

175185
Example | File | Description

0 commit comments

Comments
 (0)