Skip to content

Commit 437e48c

Browse files
committed
Fix ci doctests for bevy_render_2d
1 parent 9d8449d commit 437e48c

File tree

7 files changed

+31
-14
lines changed

7 files changed

+31
-14
lines changed

crates/bevy_gizmos/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const LINE_JOINT_SHADER_HANDLE: Handle<Shader> =
148148

149149
/// A [`Plugin`] that provides an immediate mode drawing api for visual debugging.
150150
///
151-
/// Requires to be loaded after [`PbrPlugin`](bevy_pbr::PbrPlugin) or [`SpritePlugin`](bevy_render_2d::SpritePlugin).
151+
/// Requires to be loaded after [`PbrPlugin`](bevy_pbr::PbrPlugin) or [`Mesh2dRenderPlugin`](bevy_render_2d::mesh_pipeline::Mesh2dRenderPlugin).
152152
#[derive(Default)]
153153
pub struct GizmoPlugin;
154154

crates/bevy_render_2d/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ derive_more = { version = "1", default-features = false, features = ["from"] }
2828
nonmax = "0.5"
2929
tracing = { version = "0.1", default-features = false, features = ["std"] }
3030

31+
[dev-dependencies]
32+
# used on doc tests
33+
bevy_color = { path = "../bevy_color", version = "0.16.0-dev" }
34+
3135
[lints]
3236
workspace = true
3337

crates/bevy_render_2d/src/material/alpha_mode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use bevy_reflect::{prelude::ReflectDefault, Reflect};
22

33
/// Sets how a 2d material's base color alpha channel is used for transparency.
4-
/// Currently, this only works with [`Mesh2d`]. Sprites are always transparent.
4+
/// Currently, this only works with [`Mesh2d`](bevy_render::mesh::Mesh2d). Sprites are always transparent.
55
///
66
/// This is very similar to [`AlphaMode`](bevy_render::alpha::AlphaMode) but this only applies to 2d meshes.
77
/// We use a separate type because 2d doesn't support all the transparency modes that 3d does.

crates/bevy_render_2d/src/material/components.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,32 @@ use derive_more::derive::From;
66

77
use super::Material2d;
88

9-
/// A [material](Material2d) used for rendering a [`Mesh2d`].
9+
/// A [material](Material2d) used for rendering a [`Mesh2d`](bevy_render::mesh::Mesh2d).
1010
///
1111
/// See [`Material2d`] for general information about 2D materials and how to implement your own materials.
1212
///
1313
/// # Example
1414
///
1515
/// ```
16-
/// # use bevy_sprite::{ColorMaterial, MeshMaterial2d};
1716
/// # use bevy_ecs::prelude::*;
18-
/// # use bevy_render::mesh::{Mesh, Mesh2d};
19-
/// # use bevy_color::palettes::basic::RED;
20-
/// # use bevy_asset::Assets;
17+
/// # use bevy_render::{mesh::{Mesh, Mesh2d}, render_resource::AsBindGroup};
18+
/// # use bevy_render_2d::material::{MeshMaterial2d, Material2d, AlphaMode2d};
19+
/// # use bevy_color::{Color, palettes::basic::RED};
20+
/// # use bevy_asset::{Asset, Assets};
2121
/// # use bevy_math::primitives::Circle;
22+
/// # use bevy_reflect::Reflect;
2223
/// #
24+
/// # // Defining locally so that there is no need to depend on `bevy_sprite`
25+
/// # #[derive(Asset, AsBindGroup, Reflect, Debug, Clone)]
26+
/// # struct ColorMaterial {}
27+
/// # impl ColorMaterial {
28+
/// # pub fn from_color(_color: impl Into<Color>) -> Self { Self {} }
29+
/// # }
30+
/// # impl Material2d for ColorMaterial {
31+
/// # fn alpha_mode(&self) -> AlphaMode2d {
32+
/// # AlphaMode2d::Opaque
33+
/// # }
34+
/// # }
2335
/// // Spawn an entity with a mesh using `ColorMaterial`.
2436
/// fn setup(
2537
/// mut commands: Commands,

crates/bevy_render_2d/src/material/pipeline/prepared_asset.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use super::{properties::Material2dProperties, DrawMaterial2d, Material2dPipeline
1717

1818
/// Data prepared for a [`Material2d`] instance.
1919
pub struct PreparedMaterial2d<T: Material2d> {
20+
#[expect(dead_code, reason = "`dead_code` under investigation")]
2021
pub bindings: BindingResources,
2122
pub bind_group: BindGroup,
2223
pub key: T::Data,

crates/bevy_render_2d/src/material/pipeline/properties.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use bevy_render::render_phase::DrawFunctionId;
22

33
use crate::{material::AlphaMode2d, mesh_pipeline::pipeline::Mesh2dPipelineKey};
44

5-
/// Common [`Material2d`] properties, calculated for a specific material instance.
5+
/// Common [`Material2d`](super::Material2d) properties, calculated for a specific material instance.
66
pub struct Material2dProperties {
77
/// The [`AlphaMode2d`] of this material.
88
pub alpha_mode: AlphaMode2d,
@@ -13,7 +13,7 @@ pub struct Material2dProperties {
1313
/// The bits in the [`Mesh2dPipelineKey`] for this material.
1414
///
1515
/// These are precalculated so that we can just "or" them together in
16-
/// [`queue_material2d_meshes`].
16+
/// [`queue_material2d_meshes`](crate::material::queue_material2d_meshes).
1717
pub mesh_pipeline_key_bits: Mesh2dPipelineKey,
1818
pub draw_function_id: DrawFunctionId,
1919
}

crates/bevy_render_2d/src/material/traits.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ use bevy_render::{
88

99
use super::{AlphaMode2d, Material2dKey};
1010

11-
/// Materials are used alongside [`Material2dPlugin`], [`Mesh2d`], and [`MeshMaterial2d`]
11+
/// Materials are used alongside [`Material2dPlugin`](super::Material2dPlugin),
12+
/// [`Mesh2d`](bevy_render::mesh::Mesh2d), and [`MeshMaterial2d`](super::MeshMaterial2d)
1213
/// to spawn entities that are rendered with a specific [`Material2d`] type. They serve as an easy to use high level
13-
/// way to render [`Mesh2d`] entities with custom shader logic.
14+
/// way to render [`Mesh2d`](bevy_render::mesh::Mesh2d) entities with custom shader logic.
1415
///
1516
/// Materials must implement [`AsBindGroup`] to define how data will be transferred to the GPU and bound in shaders.
1617
/// [`AsBindGroup`] can be derived, which makes generating bindings straightforward. See the [`AsBindGroup`] docs for details.
@@ -21,13 +22,12 @@ use super::{AlphaMode2d, Material2dKey};
2122
/// check out the [`AsBindGroup`] documentation.
2223
///
2324
/// ```
24-
/// # use bevy_sprite::{Material2d, MeshMaterial2d};
25+
/// # use bevy_render_2d::material::{Material2d, MeshMaterial2d};
2526
/// # use bevy_ecs::prelude::*;
2627
/// # use bevy_image::Image;
2728
/// # use bevy_reflect::TypePath;
2829
/// # use bevy_render::{mesh::{Mesh, Mesh2d}, render_resource::{AsBindGroup, ShaderRef}};
29-
/// # use bevy_color::LinearRgba;
30-
/// # use bevy_color::palettes::basic::RED;
30+
/// # use bevy_color::{LinearRgba, palettes::basic::RED};
3131
/// # use bevy_asset::{Handle, AssetServer, Assets, Asset};
3232
/// # use bevy_math::primitives::Circle;
3333
/// #

0 commit comments

Comments
 (0)