Skip to content

Commit 1ba7429

Browse files
committed
Doc/module style doc blocks for examples (bevyengine#4438)
# Objective Provide a starting point for bevyengine#3951, or a partial solution. Providing a few comment blocks to discuss, and hopefully find better one in the process. ## Solution Since I am pretty new to pretty much anything in this context, I figured I'd just start with a draft for some file level doc blocks. For some of them I found more relevant details (or at least things I considered interessting), for some others there is less. ## Changelog - Moved some existing comments from main() functions in the 2d examples to the file header level - Wrote some more comment blocks for most other 2d examples TODO: - [x] 2d/sprite_sheet, wasnt able to come up with something good yet - [x] all other example groups... Also: Please let me know if the commit style is okay, or to verbose. I could certainly squash these things, or add more details if needed. I also hope its okay to raise this PR this early, with just a few files changed. Took me long enough and I dont wanted to let it go to waste because I lost motivation to do the whole thing. Additionally I am somewhat uncertain over the style and contents of the commets. So let me know what you thing please.
1 parent 7462f21 commit 1ba7429

File tree

120 files changed

+425
-177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+425
-177
lines changed

examples/2d/mesh2d.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Shows how to render a polygonal [`Mesh`], generated from a [`Quad`] primitive, in a 2D scene.
2+
13
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
24

35
fn main() {

examples/2d/mesh2d_manual.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
//! This example shows how to manually render 2d items using "mid level render apis" with a custom
2+
//! pipeline for 2d meshes.
3+
//! It doesn't use the [`Material2d`] abstraction, but changes the vertex buffer to include vertex color.
4+
//! Check out the "mesh2d" example for simpler / higher level 2d meshes.
5+
16
use bevy::{
27
core_pipeline::Transparent2d,
38
prelude::*,
@@ -23,9 +28,6 @@ use bevy::{
2328
utils::FloatOrd,
2429
};
2530

26-
/// This example shows how to manually render 2d items using "mid level render apis" with a custom pipeline for 2d meshes
27-
/// It doesn't use the [`Material2d`] abstraction, but changes the vertex buffer to include vertex color
28-
/// Check out the "mesh2d" example for simpler / higher level 2d meshes
2931
fn main() {
3032
App::new()
3133
.add_plugins(DefaultPlugins)

examples/2d/move_sprite.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Renders a 2D scene containing a single, moving sprite.
2+
13
use bevy::prelude::*;
24

35
fn main() {
@@ -25,6 +27,8 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
2527
.insert(Direction::Up);
2628
}
2729

30+
/// The sprite is animated by changing its translation depending on the time that has passed since
31+
/// the last frame.
2832
fn sprite_movement(time: Res<Time>, mut sprite_position: Query<(&mut Direction, &mut Transform)>) {
2933
for (mut logo, mut transform) in sprite_position.iter_mut() {
3034
match *logo {

examples/2d/rotation.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Demonstrates rotating entities in 2D using quaternions.
2+
13
use bevy::{
24
core::FixedTimestep,
35
math::{const_vec2, Vec3Swizzles},

examples/2d/shapes.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Shows how to render simple primitive shapes with a single color.
2+
13
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
24

35
fn main() {

examples/2d/sprite.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Displays a single [`Sprite`], created from an image.
2+
13
use bevy::prelude::*;
24

35
fn main() {

examples/2d/sprite_flipping.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Displays a single [`Sprite`], created from an image, but flipped on one axis.
2+
13
use bevy::prelude::*;
24

35
fn main() {

examples/2d/sprite_sheet.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Renders an animated sprite by loading all animation frames from a single image (a sprite sheet)
2+
//! into a texture atlas, and changing the displayed image periodically.
3+
14
use bevy::prelude::*;
25

36
fn main() {

examples/2d/text2d.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
//! Shows text rendering with moving, rotating and scaling text.
2+
//!
3+
//! Note that this uses [`Text2dBundle`] to display text alongside your other entities in a 2D scene.
4+
//!
5+
//! For an example on how to render text as part of a user interface, independent from the world
6+
//! viewport, you may want to look at `2d/contributors.rs` or `ui/text.rs`.
7+
18
use bevy::{prelude::*, text::Text2dBounds};
29

310
fn main() {

examples/2d/texture_atlas.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
//! In this example we generate a new texture atlas (sprite sheet) from a folder containing
2+
//! individual sprites.
3+
14
use bevy::{asset::LoadState, prelude::*};
25

3-
/// In this example we generate a new texture atlas (sprite sheet) from a folder containing
4-
/// individual sprites
56
fn main() {
67
App::new()
78
.init_resource::<RpgSpriteHandles>()

0 commit comments

Comments
 (0)