Replace or document ignored doctests (#11040)
# Objective There are a lot of doctests that are `ignore`d for no documented reason. And that should be fixed. ## Solution I searched the bevy repo with the regex ` ```[a-z,]*ignore ` in order to find all `ignore`d doctests. For each one of the `ignore`d doctests, I did the following steps: 1. Attempt to remove the `ignored` attribute while still passing the test. I did this by adding hidden dummy structs and imports. 2. If step 1 doesn't work, attempt to replace the `ignored` attribute with the `no_run` attribute while still passing the test. 3. If step 2 doesn't work, keep the `ignored` attribute but add documentation for why the `ignored` attribute was added. --------- Co-authored-by: François <mockersf@gmail.com>
This commit is contained in:
parent
ffded5b78e
commit
189ceaf0d3
@ -99,7 +99,7 @@ impl Debug for App {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_app::{App, AppLabel, SubApp, Main};
|
||||
/// # use bevy_ecs::prelude::*;
|
||||
/// # use bevy_ecs::schedule::ScheduleLabel;
|
||||
@ -678,7 +678,7 @@ impl App {
|
||||
/// This vector will be length zero if no plugins of that type have been added.
|
||||
/// If multiple copies of the same plugin are added to the [`App`], they will be listed in insertion order in this vector.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_app::prelude::*;
|
||||
/// # #[derive(Default)]
|
||||
/// # struct ImagePlugin {
|
||||
@ -755,8 +755,8 @@ impl App {
|
||||
|
||||
/// Registers the type `T` in the [`TypeRegistry`](bevy_reflect::TypeRegistry) resource,
|
||||
/// adding reflect data as specified in the [`Reflect`](bevy_reflect::Reflect) derive:
|
||||
/// ```rust,ignore
|
||||
/// #[derive(Reflect)]
|
||||
/// ```ignore (No serde "derive" feature)
|
||||
/// #[derive(Component, Serialize, Deserialize, Reflect)]
|
||||
/// #[reflect(Component, Serialize, Deserialize)] // will register ReflectComponent, ReflectSerialize, ReflectDeserialize
|
||||
/// ```
|
||||
///
|
||||
@ -776,7 +776,7 @@ impl App {
|
||||
/// this method can be used to insert additional type data.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use bevy_app::App;
|
||||
/// use bevy_reflect::{ReflectSerialize, ReflectDeserialize};
|
||||
///
|
||||
@ -930,7 +930,7 @@ impl App {
|
||||
///
|
||||
/// ## Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_app::prelude::*;
|
||||
/// # use bevy_ecs::prelude::*;
|
||||
/// # use bevy_ecs::schedule::{LogLevel, ScheduleBuildSettings};
|
||||
@ -968,7 +968,7 @@ impl App {
|
||||
///
|
||||
/// ## Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_app::prelude::*;
|
||||
/// # use bevy_ecs::prelude::*;
|
||||
/// # use bevy_ecs::schedule::{LogLevel, ScheduleBuildSettings};
|
||||
|
@ -194,7 +194,7 @@ impl PluginGroupBuilder {
|
||||
}
|
||||
|
||||
/// A plugin group which doesn't do anything. Useful for examples:
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_app::prelude::*;
|
||||
/// use bevy_app::NoopPluginGroup as MinimalPlugins;
|
||||
///
|
||||
|
@ -302,7 +302,7 @@ impl<'a> AssetPath<'a> {
|
||||
/// Resolves a relative asset path via concatenation. The result will be an `AssetPath` which
|
||||
/// is resolved relative to this "base" path.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_asset::AssetPath;
|
||||
/// assert_eq!(AssetPath::parse("a/b").resolve("c"), Ok(AssetPath::parse("a/b/c")));
|
||||
/// assert_eq!(AssetPath::parse("a/b").resolve("./c"), Ok(AssetPath::parse("a/b/c")));
|
||||
@ -352,7 +352,7 @@ impl<'a> AssetPath<'a> {
|
||||
/// primary use case for this method is resolving relative paths embedded within asset files,
|
||||
/// which are relative to the asset in which they are contained.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_asset::AssetPath;
|
||||
/// assert_eq!(AssetPath::parse("a/b").resolve_embed("c"), Ok(AssetPath::parse("a/c")));
|
||||
/// assert_eq!(AssetPath::parse("a/b").resolve_embed("./c"), Ok(AssetPath::parse("a/c")));
|
||||
|
@ -61,7 +61,7 @@ impl ReflectAsset {
|
||||
/// Furthermore, this does *not* allow you to have look up two distinct handles,
|
||||
/// you can only have at most one alive at the same time.
|
||||
/// This means that this is *not allowed*:
|
||||
/// ```rust,no_run
|
||||
/// ```no_run
|
||||
/// # use bevy_asset::{ReflectAsset, UntypedHandle};
|
||||
/// # use bevy_ecs::prelude::World;
|
||||
/// # let reflect_asset: ReflectAsset = unimplemented!();
|
||||
@ -176,7 +176,7 @@ impl<A: Asset + FromReflect> FromType<A> for ReflectAsset {
|
||||
/// the [`ReflectAsset`] type data on the corresponding `T` asset type:
|
||||
///
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// ```no_run
|
||||
/// # use bevy_reflect::{TypeRegistry, prelude::*};
|
||||
/// # use bevy_ecs::prelude::*;
|
||||
/// use bevy_asset::{ReflectHandle, ReflectAsset};
|
||||
|
@ -88,7 +88,7 @@ impl std::fmt::Debug for Name {
|
||||
|
||||
/// Convenient query for giving a human friendly name to an entity.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_core::prelude::*;
|
||||
/// # use bevy_ecs::prelude::*;
|
||||
/// # #[derive(Component)] pub struct Score(f32);
|
||||
|
@ -296,7 +296,7 @@ impl RegisterDiagnostic for App {
|
||||
///
|
||||
/// Will initialize a [`DiagnosticsStore`] if it doesn't exist.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use bevy_app::App;
|
||||
/// use bevy_diagnostic::{Diagnostic, DiagnosticsPlugin, DiagnosticId, RegisterDiagnostic};
|
||||
///
|
||||
|
@ -358,7 +358,7 @@ macro_rules! impl_methods {
|
||||
/// You should never modify the argument passed to the closure -- if you want to modify the data
|
||||
/// without flagging a change, consider using [`DetectChangesMut::bypass_change_detection`] to make your intent explicit.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_ecs::prelude::*;
|
||||
/// # #[derive(PartialEq)] pub struct Vec2;
|
||||
/// # impl Vec2 { pub const ZERO: Self = Self; }
|
||||
|
@ -553,7 +553,7 @@ impl Components {
|
||||
/// Returns [`None`] if the `Component` type has not
|
||||
/// yet been initialized using [`Components::init_component()`].
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use bevy_ecs::prelude::*;
|
||||
///
|
||||
/// let mut world = World::new();
|
||||
@ -591,7 +591,7 @@ impl Components {
|
||||
/// Returns [`None`] if the `Resource` type has not
|
||||
/// yet been initialized using [`Components::init_resource()`].
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use bevy_ecs::prelude::*;
|
||||
///
|
||||
/// let mut world = World::new();
|
||||
@ -807,7 +807,7 @@ impl ComponentTicks {
|
||||
/// However, components and resources that make use of interior mutability might require manual updates.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust,no_run
|
||||
/// ```no_run
|
||||
/// # use bevy_ecs::{world::World, component::ComponentTicks};
|
||||
/// let world: World = unimplemented!();
|
||||
/// let component_ticks: ComponentTicks = unimplemented!();
|
||||
@ -823,7 +823,7 @@ impl ComponentTicks {
|
||||
/// A [`SystemParam`] that provides access to the [`ComponentId`] for a specific type.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_ecs::{system::Local, component::{Component, ComponentId, ComponentIdFor}};
|
||||
/// #[derive(Component)]
|
||||
/// struct Player;
|
||||
|
@ -12,7 +12,7 @@ use bevy_utils::EntityHashMap;
|
||||
///
|
||||
/// ## Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use bevy_ecs::prelude::*;
|
||||
/// use bevy_ecs::entity::{EntityMapper, MapEntities};
|
||||
///
|
||||
|
@ -306,7 +306,7 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use bevy_ecs::prelude::*;
|
||||
/// use bevy_ecs::query::QueryEntityError;
|
||||
///
|
||||
@ -376,7 +376,7 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {
|
||||
/// In case of a nonexisting entity or mismatched component, a [`QueryEntityError`] is
|
||||
/// returned instead.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use bevy_ecs::prelude::*;
|
||||
/// use bevy_ecs::query::QueryEntityError;
|
||||
///
|
||||
|
@ -13,8 +13,17 @@
|
||||
//! type, it tells the derive macro for `Reflect` to add the following single line to its
|
||||
//! [`get_type_registration`] method (see the relevant code[^1]).
|
||||
//!
|
||||
//! ```ignore
|
||||
//! ```
|
||||
//! # use bevy_reflect::{FromType, Reflect};
|
||||
//! # use bevy_ecs::prelude::{ReflectComponent, Component};
|
||||
//! # #[derive(Default, Reflect, Component)]
|
||||
//! # struct A;
|
||||
//! # impl A {
|
||||
//! # fn foo() {
|
||||
//! # let mut registration = bevy_reflect::TypeRegistration::of::<A>();
|
||||
//! registration.insert::<ReflectComponent>(FromType::<Self>::from_type());
|
||||
//! # }
|
||||
//! # }
|
||||
//! ```
|
||||
//!
|
||||
//! This line adds a `ReflectComponent` to the registration data for the type in question.
|
||||
|
@ -27,7 +27,7 @@ pub trait ReflectCommandExt {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// // Note that you need to register the component type in the AppTypeRegistry prior to using
|
||||
/// // reflection. You can use the helpers on the App with `app.register_type::<ComponentA>()`
|
||||
/// // or write to the TypeRegistry directly to register all your components
|
||||
@ -97,7 +97,7 @@ pub trait ReflectCommandExt {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// // Note that you need to register the component type in the AppTypeRegistry prior to using
|
||||
/// // reflection. You can use the helpers on the App with `app.register_type::<ComponentA>()`
|
||||
/// // or write to the TypeRegistry directly to register all your components
|
||||
|
@ -29,7 +29,7 @@ pub use bevy_ecs_macros::States;
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use bevy_ecs::prelude::States;
|
||||
///
|
||||
/// #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default, States)]
|
||||
|
@ -111,7 +111,7 @@ impl SystemMeta {
|
||||
/// # Example
|
||||
///
|
||||
/// Basic usage:
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_ecs::prelude::*;
|
||||
/// # use bevy_ecs::system::SystemState;
|
||||
/// # use bevy_ecs::event::Events;
|
||||
@ -144,7 +144,7 @@ impl SystemMeta {
|
||||
/// // You need to manually call `.apply(world)` on the `SystemState` to apply them.
|
||||
/// ```
|
||||
/// Caching:
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_ecs::prelude::*;
|
||||
/// # use bevy_ecs::system::SystemState;
|
||||
/// # use bevy_ecs::event::Events;
|
||||
@ -576,7 +576,7 @@ where
|
||||
///
|
||||
/// To create something like [`PipeSystem`], but in entirely safe code.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use std::num::ParseIntError;
|
||||
///
|
||||
/// use bevy_ecs::prelude::*;
|
||||
|
@ -903,7 +903,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
|
||||
/// This method panics if there is a query mismatch or a non-existing entity.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```rust, no_run
|
||||
/// ``` no_run
|
||||
/// use bevy_ecs::prelude::*;
|
||||
///
|
||||
/// #[derive(Component)]
|
||||
@ -1011,7 +1011,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust, no_run
|
||||
/// ``` no_run
|
||||
/// use bevy_ecs::prelude::*;
|
||||
///
|
||||
/// #[derive(Component)]
|
||||
|
@ -151,7 +151,7 @@ impl World {
|
||||
///
|
||||
/// ## Running a system
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_ecs::prelude::*;
|
||||
/// #[derive(Resource, Default)]
|
||||
/// struct Counter(u8);
|
||||
@ -171,7 +171,7 @@ impl World {
|
||||
///
|
||||
/// ## Change detection
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_ecs::prelude::*;
|
||||
/// #[derive(Resource, Default)]
|
||||
/// struct ChangeDetector;
|
||||
@ -195,7 +195,7 @@ impl World {
|
||||
///
|
||||
/// ## Getting system output
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_ecs::prelude::*;
|
||||
///
|
||||
/// #[derive(Resource)]
|
||||
@ -243,7 +243,7 @@ impl World {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_ecs::prelude::*;
|
||||
/// #[derive(Resource, Default)]
|
||||
/// struct Counter(u8);
|
||||
|
@ -207,7 +207,7 @@ impl World {
|
||||
/// Returns [`None`] if the `Component` type has not yet been initialized within
|
||||
/// the `World` using [`World::init_component`].
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use bevy_ecs::prelude::*;
|
||||
///
|
||||
/// let mut world = World::new();
|
||||
|
@ -4,7 +4,7 @@ use std::hash::Hash;
|
||||
|
||||
/// Stateful run condition that can be toggled via a input press using [`ButtonInput::just_pressed`].
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// ```no_run
|
||||
/// use bevy::prelude::*;
|
||||
/// use bevy::input::common_conditions::input_toggle_active;
|
||||
///
|
||||
@ -22,7 +22,7 @@ use std::hash::Hash;
|
||||
///
|
||||
/// If you want other systems to be able to access whether the toggled state is active,
|
||||
/// you should use a custom resource or a state for that:
|
||||
/// ```rust,no_run
|
||||
/// ```no_run
|
||||
/// use bevy::prelude::*;
|
||||
/// use bevy::input::common_conditions::input_just_pressed;
|
||||
///
|
||||
@ -71,7 +71,7 @@ where
|
||||
|
||||
/// Run condition that is active if [`ButtonInput::just_pressed`] is true for the given input.
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// ```no_run
|
||||
/// use bevy::prelude::*;
|
||||
/// use bevy::input::common_conditions::input_just_pressed;
|
||||
/// fn main() {
|
||||
|
@ -7,30 +7,33 @@
|
||||
//!
|
||||
//! # Example
|
||||
//! Instead of writing this:
|
||||
//! ```ignore
|
||||
//! ```
|
||||
//! # use quote::quote;
|
||||
//! quote!(
|
||||
//! fn get_id() -> Option<i32> {
|
||||
//! Some(0)
|
||||
//! }
|
||||
//! )
|
||||
//! );
|
||||
//! ```
|
||||
//! Or this:
|
||||
//! ```ignore
|
||||
//! ```
|
||||
//! # use quote::quote;
|
||||
//! quote!(
|
||||
//! fn get_id() -> ::core::option::Option<i32> {
|
||||
//! ::core::option::Option::Some(0)
|
||||
//! }
|
||||
//! )
|
||||
//! );
|
||||
//! ```
|
||||
//! We should write this:
|
||||
//! ```ignore
|
||||
//! use crate::fq_std::FQOption;
|
||||
//! ```
|
||||
//! use bevy_macro_utils::fq_std::FQOption;
|
||||
//! # use quote::quote;
|
||||
//!
|
||||
//! quote!(
|
||||
//! fn get_id() -> #FQOption<i32> {
|
||||
//! #FQOption::Some(0)
|
||||
//! }
|
||||
//! )
|
||||
//! );
|
||||
//! ```
|
||||
|
||||
use proc_macro2::TokenStream;
|
||||
|
@ -26,7 +26,7 @@ impl IRect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::IRect;
|
||||
/// let r = IRect::new(0, 4, 10, 6); // w=10 h=2
|
||||
/// let r = IRect::new(2, 3, 5, -1); // w=3 h=4
|
||||
@ -43,7 +43,7 @@ impl IRect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{IRect, IVec2};
|
||||
/// // Unit rect from [0,0] to [1,1]
|
||||
/// let r = IRect::from_corners(IVec2::ZERO, IVec2::ONE); // w=1 h=1
|
||||
@ -70,7 +70,7 @@ impl IRect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{IRect, IVec2};
|
||||
/// let r = IRect::from_center_size(IVec2::ZERO, IVec2::new(3, 2)); // w=2 h=2
|
||||
/// assert_eq!(r.min, IVec2::splat(-1));
|
||||
@ -91,7 +91,7 @@ impl IRect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{IRect, IVec2};
|
||||
/// let r = IRect::from_center_half_size(IVec2::ZERO, IVec2::ONE); // w=2 h=2
|
||||
/// assert_eq!(r.min, IVec2::splat(-1));
|
||||
@ -113,7 +113,7 @@ impl IRect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{IRect, IVec2};
|
||||
/// let r = IRect::from_corners(IVec2::ZERO, IVec2::new(0, 1)); // w=0 h=1
|
||||
/// assert!(r.is_empty());
|
||||
@ -127,7 +127,7 @@ impl IRect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::IRect;
|
||||
/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1
|
||||
/// assert_eq!(r.width(), 5);
|
||||
@ -141,7 +141,7 @@ impl IRect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::IRect;
|
||||
/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1
|
||||
/// assert_eq!(r.height(), 1);
|
||||
@ -155,7 +155,7 @@ impl IRect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{IRect, IVec2};
|
||||
/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1
|
||||
/// assert_eq!(r.size(), IVec2::new(5, 1));
|
||||
@ -173,7 +173,7 @@ impl IRect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{IRect, IVec2};
|
||||
/// let r = IRect::new(0, 0, 4, 3); // w=4 h=3
|
||||
/// assert_eq!(r.half_size(), IVec2::new(2, 1));
|
||||
@ -191,7 +191,7 @@ impl IRect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{IRect, IVec2};
|
||||
/// let r = IRect::new(0, 0, 5, 2); // w=5 h=2
|
||||
/// assert_eq!(r.center(), IVec2::new(2, 1));
|
||||
@ -205,7 +205,7 @@ impl IRect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::IRect;
|
||||
/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1
|
||||
/// assert!(r.contains(r.center()));
|
||||
@ -223,7 +223,7 @@ impl IRect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{IRect, IVec2};
|
||||
/// let r1 = IRect::new(0, 0, 5, 1); // w=5 h=1
|
||||
/// let r2 = IRect::new(1, -1, 3, 3); // w=2 h=4
|
||||
@ -246,7 +246,7 @@ impl IRect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{IRect, IVec2};
|
||||
/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1
|
||||
/// let u = r.union_point(IVec2::new(3, 6));
|
||||
@ -269,7 +269,7 @@ impl IRect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{IRect, IVec2};
|
||||
/// let r1 = IRect::new(0, 0, 5, 1); // w=5 h=1
|
||||
/// let r2 = IRect::new(1, -1, 3, 3); // w=2 h=4
|
||||
@ -297,7 +297,7 @@ impl IRect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{IRect, IVec2};
|
||||
/// let r = IRect::new(0, 0, 5, 1); // w=5 h=1
|
||||
/// let r2 = r.inset(3); // w=11 h=7
|
||||
|
@ -26,7 +26,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::Rect;
|
||||
/// let r = Rect::new(0., 4., 10., 6.); // w=10 h=2
|
||||
/// let r = Rect::new(2., 3., 5., -1.); // w=3 h=4
|
||||
@ -43,7 +43,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{Rect, Vec2};
|
||||
/// // Unit rect from [0,0] to [1,1]
|
||||
/// let r = Rect::from_corners(Vec2::ZERO, Vec2::ONE); // w=1 h=1
|
||||
@ -66,7 +66,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{Rect, Vec2};
|
||||
/// let r = Rect::from_center_size(Vec2::ZERO, Vec2::ONE); // w=1 h=1
|
||||
/// assert!(r.min.abs_diff_eq(Vec2::splat(-0.5), 1e-5));
|
||||
@ -87,7 +87,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{Rect, Vec2};
|
||||
/// let r = Rect::from_center_half_size(Vec2::ZERO, Vec2::ONE); // w=2 h=2
|
||||
/// assert!(r.min.abs_diff_eq(Vec2::splat(-1.), 1e-5));
|
||||
@ -109,7 +109,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{Rect, Vec2};
|
||||
/// let r = Rect::from_corners(Vec2::ZERO, Vec2::new(0., 1.)); // w=0 h=1
|
||||
/// assert!(r.is_empty());
|
||||
@ -123,7 +123,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::Rect;
|
||||
/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
|
||||
/// assert!((r.width() - 5.).abs() <= 1e-5);
|
||||
@ -137,7 +137,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::Rect;
|
||||
/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
|
||||
/// assert!((r.height() - 1.).abs() <= 1e-5);
|
||||
@ -151,7 +151,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{Rect, Vec2};
|
||||
/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
|
||||
/// assert!(r.size().abs_diff_eq(Vec2::new(5., 1.), 1e-5));
|
||||
@ -165,7 +165,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{Rect, Vec2};
|
||||
/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
|
||||
/// assert!(r.half_size().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5));
|
||||
@ -179,7 +179,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{Rect, Vec2};
|
||||
/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
|
||||
/// assert!(r.center().abs_diff_eq(Vec2::new(2.5, 0.5), 1e-5));
|
||||
@ -193,7 +193,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::Rect;
|
||||
/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
|
||||
/// assert!(r.contains(r.center()));
|
||||
@ -211,7 +211,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{Rect, Vec2};
|
||||
/// let r1 = Rect::new(0., 0., 5., 1.); // w=5 h=1
|
||||
/// let r2 = Rect::new(1., -1., 3., 3.); // w=2 h=4
|
||||
@ -234,7 +234,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{Rect, Vec2};
|
||||
/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
|
||||
/// let u = r.union_point(Vec2::new(3., 6.));
|
||||
@ -257,7 +257,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{Rect, Vec2};
|
||||
/// let r1 = Rect::new(0., 0., 5., 1.); // w=5 h=1
|
||||
/// let r2 = Rect::new(1., -1., 3., 3.); // w=2 h=4
|
||||
@ -285,7 +285,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{Rect, Vec2};
|
||||
/// let r = Rect::new(0., 0., 5., 1.); // w=5 h=1
|
||||
/// let r2 = r.inset(3.); // w=11 h=7
|
||||
@ -314,7 +314,7 @@ impl Rect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{Rect, Vec2};
|
||||
/// let r = Rect::new(2., 3., 4., 6.);
|
||||
/// let s = Rect::new(0., 0., 10., 10.);
|
||||
|
@ -26,7 +26,7 @@ impl URect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::URect;
|
||||
/// let r = URect::new(0, 4, 10, 6); // w=10 h=2
|
||||
/// let r = URect::new(2, 4, 5, 0); // w=3 h=4
|
||||
@ -43,7 +43,7 @@ impl URect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{URect, UVec2};
|
||||
/// // Unit rect from [0,0] to [1,1]
|
||||
/// let r = URect::from_corners(UVec2::ZERO, UVec2::ONE); // w=1 h=1
|
||||
@ -70,7 +70,7 @@ impl URect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{URect, UVec2};
|
||||
/// let r = URect::from_center_size(UVec2::ONE, UVec2::splat(2)); // w=2 h=2
|
||||
/// assert_eq!(r.min, UVec2::splat(0));
|
||||
@ -91,7 +91,7 @@ impl URect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{URect, UVec2};
|
||||
/// let r = URect::from_center_half_size(UVec2::ONE, UVec2::ONE); // w=2 h=2
|
||||
/// assert_eq!(r.min, UVec2::splat(0));
|
||||
@ -110,7 +110,7 @@ impl URect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{URect, UVec2};
|
||||
/// let r = URect::from_corners(UVec2::ZERO, UVec2::new(0, 1)); // w=0 h=1
|
||||
/// assert!(r.is_empty());
|
||||
@ -124,7 +124,7 @@ impl URect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::URect;
|
||||
/// let r = URect::new(0, 0, 5, 1); // w=5 h=1
|
||||
/// assert_eq!(r.width(), 5);
|
||||
@ -138,7 +138,7 @@ impl URect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::URect;
|
||||
/// let r = URect::new(0, 0, 5, 1); // w=5 h=1
|
||||
/// assert_eq!(r.height(), 1);
|
||||
@ -152,7 +152,7 @@ impl URect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{URect, UVec2};
|
||||
/// let r = URect::new(0, 0, 5, 1); // w=5 h=1
|
||||
/// assert_eq!(r.size(), UVec2::new(5, 1));
|
||||
@ -170,7 +170,7 @@ impl URect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{URect, UVec2};
|
||||
/// let r = URect::new(0, 0, 4, 2); // w=4 h=2
|
||||
/// assert_eq!(r.half_size(), UVec2::new(2, 1));
|
||||
@ -188,7 +188,7 @@ impl URect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{URect, UVec2};
|
||||
/// let r = URect::new(0, 0, 4, 2); // w=4 h=2
|
||||
/// assert_eq!(r.center(), UVec2::new(2, 1));
|
||||
@ -202,7 +202,7 @@ impl URect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::URect;
|
||||
/// let r = URect::new(0, 0, 5, 1); // w=5 h=1
|
||||
/// assert!(r.contains(r.center()));
|
||||
@ -220,7 +220,7 @@ impl URect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{URect, UVec2};
|
||||
/// let r1 = URect::new(0, 0, 5, 1); // w=5 h=1
|
||||
/// let r2 = URect::new(1, 0, 3, 8); // w=2 h=4
|
||||
@ -243,7 +243,7 @@ impl URect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{URect, UVec2};
|
||||
/// let r = URect::new(0, 0, 5, 1); // w=5 h=1
|
||||
/// let u = r.union_point(UVec2::new(3, 6));
|
||||
@ -266,7 +266,7 @@ impl URect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{URect, UVec2};
|
||||
/// let r1 = URect::new(0, 0, 2, 2); // w=2 h=2
|
||||
/// let r2 = URect::new(1, 1, 3, 3); // w=2 h=2
|
||||
@ -294,7 +294,7 @@ impl URect {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_math::{URect, UVec2};
|
||||
/// let r = URect::new(4, 4, 6, 6); // w=2 h=2
|
||||
/// let r2 = r.inset(1); // w=4 h=4
|
||||
|
@ -168,9 +168,9 @@ impl TypePathAttrs {
|
||||
///
|
||||
/// Registering the `Default` implementation:
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// // Import ReflectDefault so it's accessible by the derive macro
|
||||
/// use bevy_reflect::prelude::ReflectDefault.
|
||||
/// use bevy_reflect::prelude::ReflectDefault;
|
||||
///
|
||||
/// #[derive(Reflect, Default)]
|
||||
/// #[reflect(Default)]
|
||||
@ -179,7 +179,7 @@ impl TypePathAttrs {
|
||||
///
|
||||
/// Registering the `Hash` implementation:
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// // `Hash` is a "special trait" and does not need (nor have) a ReflectHash struct
|
||||
///
|
||||
/// #[derive(Reflect, Hash)]
|
||||
@ -189,7 +189,7 @@ impl TypePathAttrs {
|
||||
///
|
||||
/// Registering the `Hash` implementation using a custom function:
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// // This function acts as our `Hash` implementation and
|
||||
/// // corresponds to the `Reflect::reflect_hash` method.
|
||||
/// fn get_hash(foo: &Foo) -> Option<u64> {
|
||||
|
@ -29,7 +29,7 @@ pub(crate) enum ReflectDerive<'a> {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// #[derive(Reflect)]
|
||||
/// // traits
|
||||
/// // |----------------------------------------|
|
||||
@ -54,7 +54,7 @@ pub(crate) struct ReflectMeta<'a> {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// #[derive(Reflect)]
|
||||
/// #[reflect(PartialEq, Serialize, Deserialize, Default)]
|
||||
/// struct ThingThatImReflecting<T1, T2, T3> {
|
||||
@ -73,7 +73,7 @@ pub(crate) struct ReflectStruct<'a> {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// #[derive(Reflect)]
|
||||
/// #[reflect(PartialEq, Serialize, Deserialize, Default)]
|
||||
/// enum ThingThatImReflecting<T1, T2, T3> {
|
||||
@ -573,7 +573,7 @@ impl<'a> EnumVariant<'a> {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// # use syn::parse_quote;
|
||||
/// # use bevy_reflect_derive::ReflectTypePath;
|
||||
/// let path: syn::Path = parse_quote!(::core::marker::PhantomData)?;
|
||||
|
@ -318,7 +318,7 @@ pub fn derive_type_uuid(input: TokenStream) -> TokenStream {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// # use std::any::TypeId;
|
||||
/// # use bevy_reflect_derive::{Reflect, reflect_trait};
|
||||
/// #[reflect_trait] // Generates `ReflectMyTrait`
|
||||
@ -372,20 +372,20 @@ pub fn reflect_trait(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
///
|
||||
/// Types can be passed with or without registering type data:
|
||||
///
|
||||
/// ```ignore
|
||||
/// impl_reflect_value!(::my_crate::Foo);
|
||||
/// impl_reflect_value!(::my_crate::Bar(Debug, Default, Serialize, Deserialize));
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// impl_reflect_value!(my_crate::Foo);
|
||||
/// impl_reflect_value!(my_crate::Bar(Debug, Default, Serialize, Deserialize));
|
||||
/// ```
|
||||
///
|
||||
/// Generic types can also specify their parameters and bounds:
|
||||
///
|
||||
/// ```ignore
|
||||
/// impl_reflect_value!(::my_crate::Foo<T1, T2: Baz> where T1: Bar (Default, Serialize, Deserialize));
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// impl_reflect_value!(my_crate::Foo<T1, T2: Baz> where T1: Bar (Default, Serialize, Deserialize));
|
||||
/// ```
|
||||
///
|
||||
/// Custom type paths can be specified:
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// impl_reflect_value!((in not_my_crate as NotFoo) Foo(Debug, Default));
|
||||
/// ```
|
||||
///
|
||||
@ -440,7 +440,7 @@ pub fn impl_reflect_value(input: TokenStream) -> TokenStream {
|
||||
///
|
||||
/// # Example
|
||||
/// Implementing `Reflect` for `bevy::prelude::Vec3` as a struct type:
|
||||
/// ```ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// use bevy::prelude::Vec3;
|
||||
///
|
||||
/// impl_reflect_struct!(
|
||||
@ -515,7 +515,7 @@ pub fn impl_reflect_struct(input: TokenStream) -> TokenStream {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// impl_from_reflect_value!(foo<T1, T2: Baz> where T1: Bar);
|
||||
/// ```
|
||||
///
|
||||
@ -560,27 +560,27 @@ pub fn impl_from_reflect_value(input: TokenStream) -> TokenStream {
|
||||
/// # Examples
|
||||
///
|
||||
/// Implementing `TypePath` on a foreign type:
|
||||
/// ```rust,ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// impl_type_path!(::foreign_crate::foo::bar::Baz);
|
||||
/// ```
|
||||
///
|
||||
/// On a generic type:
|
||||
/// ```rust,ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// impl_type_path!(::foreign_crate::Foo<T>);
|
||||
/// ```
|
||||
///
|
||||
/// On a primitive (note this will not compile for a non-primitive type):
|
||||
/// ```rust,ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// impl_type_path!(bool);
|
||||
/// ```
|
||||
///
|
||||
/// With a custom type path:
|
||||
/// ```rust,ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// impl_type_path!((in other_crate::foo::bar) Baz);
|
||||
/// ```
|
||||
///
|
||||
/// With a custom type path and a custom type name:
|
||||
/// ```rust,ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// impl_type_path!((in other_crate::foo as Baz) Bar);
|
||||
/// ```
|
||||
///
|
||||
|
@ -10,7 +10,7 @@ use syn::{parenthesized, Attribute, Generics, Path};
|
||||
///
|
||||
/// This takes the form:
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (Method expecting TokenStream is better represented with raw tokens)
|
||||
/// // Standard
|
||||
/// ::my_crate::foo::Bar(TraitA, TraitB)
|
||||
///
|
||||
|
@ -18,7 +18,13 @@ pub(crate) fn get_bevy_reflect_path() -> Path {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```
|
||||
/// # use proc_macro2::Ident;
|
||||
/// # // We can't import this method because of its visibility.
|
||||
/// # fn get_reflect_ident(name: &str) -> Ident {
|
||||
/// # let reflected = format!("Reflect{name}");
|
||||
/// # Ident::new(&reflected, proc_macro2::Span::call_site())
|
||||
/// # }
|
||||
/// let reflected: Ident = get_reflect_ident("Hash");
|
||||
/// assert_eq!("ReflectHash", reflected.to_string());
|
||||
/// ```
|
||||
@ -195,7 +201,7 @@ impl WhereClauseOptions {
|
||||
/// # Example
|
||||
///
|
||||
/// The struct:
|
||||
/// ```ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// #[derive(Reflect)]
|
||||
/// struct Foo<T, U> {
|
||||
/// a: T,
|
||||
@ -206,7 +212,7 @@ impl WhereClauseOptions {
|
||||
/// will have active types: `[T]` and ignored types: `[U]`
|
||||
///
|
||||
/// The `extend_where_clause` function will yield the following `where` clause:
|
||||
/// ```ignore
|
||||
/// ```ignore (bevy_reflect is not accessible from this crate)
|
||||
/// where
|
||||
/// T: Reflect, // active_trait_bounds
|
||||
/// U: Any + Send + Sync, // ignored_trait_bounds
|
||||
|
@ -1557,7 +1557,7 @@ mod tests {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (This is only used for a unit test, no need to doc test)
|
||||
/// let some_struct = SomeStruct;
|
||||
/// ```
|
||||
#[derive(Reflect)]
|
||||
|
@ -219,7 +219,7 @@ impl Container for TupleVariantInfo {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (Can't import private struct from doctest)
|
||||
/// let expected = vec!["foo", "bar", "baz"];
|
||||
/// assert_eq!("`foo`, `bar`, `baz`", format!("{}", ExpectedValues(expected)));
|
||||
/// ```
|
||||
|
@ -36,7 +36,7 @@ use std::fmt;
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use bevy_reflect::TypePath;
|
||||
///
|
||||
/// // This type path will not change with compiler versions or recompiles,
|
||||
|
@ -101,8 +101,8 @@ impl TypeRegistry {
|
||||
}
|
||||
|
||||
/// Registers the type `T`, adding reflect data as specified in the [`Reflect`] derive:
|
||||
/// ```rust,ignore
|
||||
/// #[derive(Reflect)]
|
||||
/// ```ignore (Neither bevy_ecs nor serde "derive" are available.)
|
||||
/// #[derive(Component, serde::Serialize, serde::Deserialize, Reflect)]
|
||||
/// #[reflect(Component, Serialize, Deserialize)] // will register ReflectComponent, ReflectSerialize, ReflectDeserialize
|
||||
/// ```
|
||||
pub fn register<T>(&mut self)
|
||||
@ -143,7 +143,7 @@ impl TypeRegistry {
|
||||
/// this method can be used to insert additional type data.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use bevy_reflect::{TypeRegistry, ReflectSerialize, ReflectDeserialize};
|
||||
///
|
||||
/// let mut type_registry = TypeRegistry::default();
|
||||
@ -499,7 +499,7 @@ impl<T: for<'a> Deserialize<'a> + Reflect> FromType<T> for ReflectDeserialize {
|
||||
/// from a pointer.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use bevy_reflect::{TypeRegistry, Reflect, ReflectFromPtr};
|
||||
/// use bevy_ptr::Ptr;
|
||||
/// use std::ptr::NonNull;
|
||||
|
@ -27,7 +27,7 @@ use std::ops::{Deref, DerefMut};
|
||||
///
|
||||
/// ## Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use bevy_ecs::prelude::*;
|
||||
/// use bevy_render::Extract;
|
||||
/// # #[derive(Component)]
|
||||
|
@ -149,15 +149,21 @@ impl<P: PhaseItem> DrawFunctions<P> {
|
||||
/// Multiple render commands can be combined together by wrapping them in a tuple.
|
||||
///
|
||||
/// # Example
|
||||
/// The `DrawPbr` draw function is created from the following render command
|
||||
///
|
||||
/// The `DrawMaterial` draw function is created from the following render command
|
||||
/// tuple. Const generics are used to set specific bind group locations:
|
||||
///
|
||||
/// ```ignore
|
||||
/// pub type DrawPbr = (
|
||||
/// ```
|
||||
/// # use bevy_render::render_phase::SetItemPipeline;
|
||||
/// # struct SetMeshViewBindGroup<const N: usize>;
|
||||
/// # struct SetMeshBindGroup<const N: usize>;
|
||||
/// # struct SetMaterialBindGroup<M, const N: usize>(core::marker::PhantomData<M>);
|
||||
/// # struct DrawMesh;
|
||||
/// pub type DrawMaterial<M> = (
|
||||
/// SetItemPipeline,
|
||||
/// SetMeshViewBindGroup<0>,
|
||||
/// SetStandardMaterialBindGroup<1>,
|
||||
/// SetTransformBindGroup<2>,
|
||||
/// SetMeshBindGroup<1>,
|
||||
/// SetMaterialBindGroup<M, 2>,
|
||||
/// DrawMesh,
|
||||
/// );
|
||||
/// ```
|
||||
|
@ -269,7 +269,7 @@ impl<'a> TrackedRenderPass<'a> {
|
||||
///
|
||||
/// The structure expected in `indirect_buffer` is the following:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// #[repr(C)]
|
||||
/// struct DrawIndirect {
|
||||
/// vertex_count: u32, // The number of vertices to draw.
|
||||
@ -292,7 +292,7 @@ impl<'a> TrackedRenderPass<'a> {
|
||||
///
|
||||
/// The structure expected in `indirect_buffer` is the following:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// #[repr(C)]
|
||||
/// struct DrawIndexedIndirect {
|
||||
/// vertex_count: u32, // The number of vertices to draw.
|
||||
@ -320,7 +320,7 @@ impl<'a> TrackedRenderPass<'a> {
|
||||
///
|
||||
/// `indirect_buffer` should contain `count` tightly packed elements of the following structure:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// #[repr(C)]
|
||||
/// struct DrawIndirect {
|
||||
/// vertex_count: u32, // The number of vertices to draw.
|
||||
@ -358,7 +358,7 @@ impl<'a> TrackedRenderPass<'a> {
|
||||
///
|
||||
/// `indirect_buffer` should contain `count` tightly packed elements of the following structure:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// #[repr(C)]
|
||||
/// struct DrawIndirect {
|
||||
/// vertex_count: u32, // The number of vertices to draw.
|
||||
@ -401,7 +401,7 @@ impl<'a> TrackedRenderPass<'a> {
|
||||
///
|
||||
/// `indirect_buffer` should contain `count` tightly packed elements of the following structure:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// #[repr(C)]
|
||||
/// struct DrawIndexedIndirect {
|
||||
/// vertex_count: u32, // The number of vertices to draw.
|
||||
@ -441,7 +441,7 @@ impl<'a> TrackedRenderPass<'a> {
|
||||
///
|
||||
/// `indirect_buffer` should contain `count` tightly packed elements of the following structure:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// #[repr(C)]
|
||||
/// struct DrawIndexedIndirect {
|
||||
/// vertex_count: u32, // The number of vertices to draw.
|
||||
|
@ -6,7 +6,7 @@ use super::{Sampler, TextureView};
|
||||
/// Helper for constructing bindgroups.
|
||||
///
|
||||
/// Allows constructing the descriptor's entries as:
|
||||
/// ```ignore
|
||||
/// ```ignore (render_device cannot be easily accessed)
|
||||
/// render_device.create_bind_group(
|
||||
/// "my_bind_group",
|
||||
/// &my_layout,
|
||||
@ -19,7 +19,7 @@ use super::{Sampler, TextureView};
|
||||
///
|
||||
/// instead of
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (render_device cannot be easily accessed)
|
||||
/// render_device.create_bind_group(
|
||||
/// "my_bind_group",
|
||||
/// &my_layout,
|
||||
@ -38,7 +38,7 @@ use super::{Sampler, TextureView};
|
||||
///
|
||||
/// or
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (render_device cannot be easily accessed)
|
||||
/// render_device.create_bind_group(
|
||||
/// "my_bind_group",
|
||||
/// &my_layout,
|
||||
@ -51,7 +51,7 @@ use super::{Sampler, TextureView};
|
||||
///
|
||||
/// instead of
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (render_device cannot be easily accessed)
|
||||
/// render_device.create_bind_group(
|
||||
/// "my_bind_group",
|
||||
/// &my_layout,
|
||||
@ -70,7 +70,7 @@ use super::{Sampler, TextureView};
|
||||
///
|
||||
/// or
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (render_device cannot be easily accessed)
|
||||
/// render_device.create_bind_group(
|
||||
/// "my_bind_group",
|
||||
/// &my_layout,
|
||||
@ -80,7 +80,7 @@ use super::{Sampler, TextureView};
|
||||
///
|
||||
/// instead of
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (render_device cannot be easily accessed)
|
||||
/// render_device.create_bind_group(
|
||||
/// "my_bind_group",
|
||||
/// &my_layout,
|
||||
|
@ -5,7 +5,7 @@ use wgpu::{BindGroupLayoutEntry, BindingType, ShaderStages};
|
||||
/// Helper for constructing bind group layouts.
|
||||
///
|
||||
/// Allows constructing the layout's entries as:
|
||||
/// ```ignore
|
||||
/// ```ignore (render_device cannot be easily accessed)
|
||||
/// let layout = render_device.create_bind_group_layout(
|
||||
/// "my_bind_group_layout",
|
||||
/// &BindGroupLayoutEntries::with_indices(
|
||||
@ -23,7 +23,7 @@ use wgpu::{BindGroupLayoutEntry, BindingType, ShaderStages};
|
||||
///
|
||||
/// instead of
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (render_device cannot be easily accessed)
|
||||
/// let layout = render_device.create_bind_group_layout(
|
||||
/// "my_bind_group_layout",
|
||||
/// &[
|
||||
@ -51,7 +51,7 @@ use wgpu::{BindGroupLayoutEntry, BindingType, ShaderStages};
|
||||
///
|
||||
/// or
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (render_device cannot be easily accessed)
|
||||
/// render_device.create_bind_group_layout(
|
||||
/// "my_bind_group_layout",
|
||||
/// &BindGroupLayoutEntries::sequential(
|
||||
@ -68,7 +68,7 @@ use wgpu::{BindGroupLayoutEntry, BindingType, ShaderStages};
|
||||
///
|
||||
/// instead of
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (render_device cannot be easily accessed)
|
||||
/// let layout = render_device.create_bind_group_layout(
|
||||
/// "my_bind_group_layout",
|
||||
/// &[
|
||||
@ -96,7 +96,7 @@ use wgpu::{BindGroupLayoutEntry, BindingType, ShaderStages};
|
||||
///
|
||||
/// or
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (render_device cannot be easily accessed)
|
||||
/// render_device.create_bind_group_layout(
|
||||
/// "my_bind_group_layout",
|
||||
/// &BindGroupLayoutEntries::single(
|
||||
@ -108,7 +108,7 @@ use wgpu::{BindGroupLayoutEntry, BindingType, ShaderStages};
|
||||
///
|
||||
/// instead of
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```ignore (render_device cannot be easily accessed)
|
||||
/// let layout = render_device.create_bind_group_layout(
|
||||
/// "my_bind_group_layout",
|
||||
/// &[
|
||||
|
@ -171,7 +171,7 @@ impl TaskPool {
|
||||
/// the local executor on the main thread as it needs to share time with
|
||||
/// other things.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use bevy_tasks::TaskPool;
|
||||
///
|
||||
/// TaskPool::new().with_local_executor(|local_executor| {
|
||||
|
@ -10,7 +10,7 @@ pub trait ParallelSlice<T: Sync>: AsRef<[T]> {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_tasks::prelude::*;
|
||||
/// # use bevy_tasks::TaskPool;
|
||||
/// let task_pool = TaskPool::new();
|
||||
@ -54,7 +54,7 @@ pub trait ParallelSlice<T: Sync>: AsRef<[T]> {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_tasks::prelude::*;
|
||||
/// # use bevy_tasks::TaskPool;
|
||||
/// let task_pool = TaskPool::new();
|
||||
@ -104,7 +104,7 @@ pub trait ParallelSliceMut<T: Send>: AsMut<[T]> {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_tasks::prelude::*;
|
||||
/// # use bevy_tasks::TaskPool;
|
||||
/// let task_pool = TaskPool::new();
|
||||
@ -151,7 +151,7 @@ pub trait ParallelSliceMut<T: Send>: AsMut<[T]> {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_tasks::prelude::*;
|
||||
/// # use bevy_tasks::TaskPool;
|
||||
/// let task_pool = TaskPool::new();
|
||||
|
@ -560,7 +560,7 @@ impl TaskPool {
|
||||
/// the local executor on the main thread as it needs to share time with
|
||||
/// other things.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// use bevy_tasks::TaskPool;
|
||||
///
|
||||
/// TaskPool::new().with_local_executor(|local_executor| {
|
||||
|
@ -10,7 +10,7 @@ use futures_lite::Future;
|
||||
/// can spawn `Send` tasks from other threads.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use std::sync::{Arc, atomic::{AtomicI32, Ordering}};
|
||||
/// use bevy_tasks::ThreadExecutor;
|
||||
///
|
||||
|
@ -5,7 +5,7 @@ use bevy_utils::Duration;
|
||||
/// Run condition that is active on a regular time interval, using [`Time`] to advance
|
||||
/// the timer. The timer ticks at the rate of [`Time::relative_speed`].
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// ```no_run
|
||||
/// # use bevy_app::{App, NoopPluginGroup as DefaultPlugins, PluginGroup, Update};
|
||||
/// # use bevy_ecs::schedule::IntoSystemConfigs;
|
||||
/// # use bevy_utils::Duration;
|
||||
@ -41,7 +41,7 @@ pub fn on_timer(duration: Duration) -> impl FnMut(Res<Time>) -> bool + Clone {
|
||||
/// Run condition that is active on a regular time interval, using [`Time<Real>`] to advance
|
||||
/// the timer. The timer ticks are not scaled.
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// ```no_run
|
||||
/// # use bevy_app::{App, NoopPluginGroup as DefaultPlugins, PluginGroup, Update};
|
||||
/// # use bevy_ecs::schedule::IntoSystemConfigs;
|
||||
/// # use bevy_utils::Duration;
|
||||
|
@ -115,7 +115,7 @@ impl GlobalTransform {
|
||||
/// Say you have an entity `e1` that you want to turn into a child of `e2`,
|
||||
/// but you want `e1` to keep the same global transform, even after re-parenting. You would use:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```
|
||||
/// # use bevy_transform::prelude::{GlobalTransform, Transform};
|
||||
/// # use bevy_ecs::prelude::{Entity, Query, Component, Commands};
|
||||
/// # use bevy_hierarchy::{prelude::Parent, BuildChildren};
|
||||
|
@ -33,7 +33,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
|
||||
/// The scene hierarchy currently looks somewhat like this:
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```text
|
||||
/// <Parent entity>
|
||||
/// + Mesh node (without `PbrBundle` or `SkinnedMesh` component)
|
||||
/// + Skinned mesh entity (with `PbrBundle` and `SkinnedMesh` component, created by glTF loader)
|
||||
|
Loading…
Reference in New Issue
Block a user