Skip to content

Commit 122e29f

Browse files
committed
Update macro doc link syntax
1 parent a228a84 commit 122e29f

File tree

8 files changed

+20
-31
lines changed

8 files changed

+20
-31
lines changed

crates/bevy_reflect/bevy_reflect_derive/src/lib.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ pub(crate) static REFLECT_VALUE_ATTRIBUTE_NAME: &str = "reflect_value";
5959
/// one for `ReflectFoo` and another for `ReflectBar`.
6060
/// This assumes these types are indeed in-scope wherever this macro is called.
6161
///
62-
/// This is often used with traits that have been marked by the [`reflect_trait`] macro
63-
/// in order to register the type's implementation of that trait.
62+
/// This is often used with traits that have been marked by the [`#[reflect_trait]`](macro@reflect_trait)
63+
/// macro in order to register the type's implementation of that trait.
6464
///
6565
/// ### Special Identifiers
6666
///
@@ -146,7 +146,7 @@ pub fn derive_reflect(input: TokenStream) -> TokenStream {
146146
///
147147
/// ## `#[reflect(ignore)]`
148148
///
149-
/// The `#[reflect(ignore)]` attribute is shared with the [`Reflect` derive macro] and has much of the same
149+
/// The `#[reflect(ignore)]` attribute is shared with the [`#[derive(Reflect)]`](Reflect) macro and has much of the same
150150
/// functionality in that it marks a field to be ignored by the reflection API.
151151
///
152152
/// The only major difference is that using it with this derive requires that the field implements [`Default`].
@@ -166,8 +166,6 @@ pub fn derive_reflect(input: TokenStream) -> TokenStream {
166166
/// or to remove the `Default` requirement on fields marked with `#[reflect(ignore)]`.
167167
/// Additionally, either form of this attribute can be used to fill in fields that are simply missing,
168168
/// such as when converting a partially-constructed dynamic type to a concrete one.
169-
///
170-
/// [`Reflect` derive macro]: Reflect
171169
#[proc_macro_derive(FromReflect, attributes(reflect))]
172170
pub fn derive_from_reflect(input: TokenStream) -> TokenStream {
173171
let ast = parse_macro_input!(input as DeriveInput);
@@ -202,7 +200,7 @@ pub fn derive_type_uuid(input: TokenStream) -> TokenStream {
202200
/// For a trait named `MyTrait`, this will generate the struct `ReflectMyTrait`.
203201
/// The generated struct can be created using `FromType` with any type that implements the trait.
204202
/// The creation and registration of this generated struct as type data can be automatically handled
205-
/// by the [`Reflect` derive macro].
203+
/// by [`#[derive(Reflect)]`](Reflect).
206204
///
207205
/// # Example
208206
///
@@ -241,7 +239,6 @@ pub fn derive_type_uuid(input: TokenStream) -> TokenStream {
241239
/// ```
242240
///
243241
/// [object-safe]: https://doc.rust-lang.org/reference/items/traits.html#object-safety
244-
/// [`Reflect` derive macro]: Reflect
245242
#[proc_macro_attribute]
246243
pub fn reflect_trait(args: TokenStream, input: TokenStream) -> TokenStream {
247244
trait_reflection::reflect_trait(&args, input)

crates/bevy_reflect/src/enums/enum_trait.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use std::slice::Iter;
3939
///
4040
/// # Implementation
4141
///
42-
/// > 💡 This trait can be automatically implemented using the [`Reflect` derive macro]
42+
/// > 💡 This trait can be automatically implemented using [`#[derive(Reflect)]`](derive@crate::Reflect)
4343
/// > on an enum definition.
4444
///
4545
/// Despite the fact that enums can represent multiple states, traits only exist in one state
@@ -52,7 +52,7 @@ use std::slice::Iter;
5252
/// accessing fields!
5353
/// Again, this is to account for _all three_ variant types.
5454
///
55-
/// We recommend using the built-in [`Reflect` derive macro] to automatically handle all the
55+
/// We recommend using the built-in [`#[derive(Reflect)]`](derive@crate::Reflect) macro to automatically handle all the
5656
/// implementation details for you.
5757
/// However, if you _must_ implement this trait manually, there are a few things to keep in mind...
5858
///
@@ -87,7 +87,6 @@ use std::slice::Iter;
8787
/// [`None`]: core::option::Option<T>::None
8888
/// [`Some`]: core::option::Option<T>::Some
8989
/// [`Reflect`]: bevy_reflect_derive::Reflect
90-
/// [`Reflect` derive macro]: bevy_reflect_derive::Reflect
9190
pub trait Enum: Reflect {
9291
/// Returns a reference to the value of the field (in the current variant) with the given name.
9392
///

crates/bevy_reflect/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@
217217
//!
218218
//! With the derive macro, fields can be ignored or given default values for when a field is missing
219219
//! in the passed value.
220-
//! See the [derive macro documentation](bevy_reflect_derive::FromReflect) for details.
220+
//! See the [derive macro documentation](derive@crate::FromReflect) for details.
221221
//!
222222
//! All primitives and simple types implement `FromReflect` by relying on their [`Default`] implementation.
223223
//!
@@ -270,7 +270,7 @@
270270
//! These allow traits to be used directly on a `dyn Reflect` while utilizing the underlying type's implementation.
271271
//!
272272
//! For any [object-safe] trait, we can easily generate a corresponding `ReflectTrait` type for our trait
273-
//! using the [`reflect_trait`] macro.
273+
//! using the [`#[reflect_trait]`](reflect_trait) macro.
274274
//!
275275
//! ```
276276
//! # use bevy_reflect::{Reflect, reflect_trait, TypeRegistry};
@@ -380,9 +380,9 @@
380380
//! [Bevy]: https://bevyengine.org/
381381
//! [`bevy_reflect`]: crate
382382
//! [runtime cost]: https://doc.rust-lang.org/book/ch17-02-trait-objects.html#trait-objects-perform-dynamic-dispatch
383-
//! [derive macro]: bevy_reflect_derive::Reflect
383+
//! [derive macro]: derive@crate::Reflect
384384
//! [`'static` lifetime]: https://doc.rust-lang.org/rust-by-example/scope/lifetime/static_lifetime.html#trait-bound
385-
//! [derive macro documentation]: bevy_reflect_derive::Reflect
385+
//! [derive macro documentation]: derive@crate::Reflect
386386
//! [type data]: TypeData
387387
//! [`ReflectDefault`]: std_traits::ReflectDefault
388388
//! [object-safe]: https://doc.rust-lang.org/reference/items/traits.html#object-safety
@@ -399,7 +399,7 @@
399399
//! [`smallvec`]: https://docs.rs/smallvec/latest/smallvec/
400400
//! [orphan rule]: https://doc.rust-lang.org/book/ch10-02-traits.html#implementing-a-trait-on-a-type:~:text=But%20we%20can%E2%80%99t,implementation%20to%20use.
401401
//! [`bevy_reflect_derive/documentation`]: bevy_reflect_derive
402-
//! [derive `Reflect`]: bevy_reflect_derive::Reflect
402+
//! [derive `Reflect`]: derive@crate::Reflect
403403
404404
mod array;
405405
mod fields;

crates/bevy_reflect/src/map.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{DynamicInfo, Reflect, ReflectMut, ReflectOwned, ReflectRef, TypeInfo
1616
/// # Hashing
1717
///
1818
/// All keys are expected to return a valid hash value from [`Reflect::reflect_hash`].
19-
/// If using the [`Reflect` derive macro], this can be done by adding `#[reflect(Hash)]`
19+
/// If using the [`#[derive(Reflect)]`](derive@crate::Reflect) macro, this can be done by adding `#[reflect(Hash)]`
2020
/// to the entire struct or enum.
2121
/// This is true even for manual implementors who do not use the hashed value,
2222
/// as it is still relied on by [`DynamicMap`].
@@ -39,7 +39,6 @@ use crate::{DynamicInfo, Reflect, ReflectMut, ReflectOwned, ReflectRef, TypeInfo
3939
/// [map-like]: https://doc.rust-lang.org/book/ch08-03-hash-maps.html
4040
/// [reflection]: crate
4141
/// [`HashMap`]: bevy_utils::HashMap
42-
/// [`Reflect` derive macro]: bevy_reflect_derive::Reflect
4342
pub trait Map: Reflect {
4443
/// Returns a reference to the value associated with the given key.
4544
///

crates/bevy_reflect/src/struct_trait.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::{
1515
/// This trait uses the [`Reflect`] trait to allow implementors to have their fields
1616
/// be dynamically addressed by both name and index.
1717
///
18-
/// When using the [`Reflect` derive macro] on a standard struct,
18+
/// When using [`#[derive(Reflect)]`](derive@crate::Reflect) on a standard struct,
1919
/// this trait will be automatically implemented.
2020
/// This goes for [unit structs] as well.
2121
///
@@ -40,7 +40,7 @@ use std::{
4040
///
4141
/// [struct-like]: https://doc.rust-lang.org/book/ch05-01-defining-structs.html
4242
/// [reflection]: crate
43-
/// [`Reflect` derive macro]: bevy_reflect_derive::Reflect
43+
4444
/// [unit structs]: https://doc.rust-lang.org/book/ch05-01-defining-structs.html#unit-like-structs-without-any-fields
4545
pub trait Struct: Reflect {
4646
/// Returns a reference to the value of the field named `name` as a `&dyn

crates/bevy_reflect/src/tuple_struct.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::slice::Iter;
1111
/// This trait uses the [`Reflect`] trait to allow implementors to have their fields
1212
/// be dynamically addressed by index.
1313
///
14-
/// When using the [`Reflect` derive macro] on a tuple struct,
14+
/// When using [`#[derive(Reflect)]`](derive@crate::Reflect) on a tuple struct,
1515
/// this trait will be automatically implemented.
1616
///
1717
/// # Example
@@ -32,7 +32,6 @@ use std::slice::Iter;
3232
///
3333
/// [tuple struct-like]: https://doc.rust-lang.org/book/ch05-01-defining-structs.html#using-tuple-structs-without-named-fields-to-create-different-types
3434
/// [reflection]: crate
35-
/// [`Reflect` derive macro]: bevy_reflect_derive::Reflect
3635
pub trait TupleStruct: Reflect {
3736
/// Returns a reference to the value of the field with index `index` as a
3837
/// `&dyn Reflect`.

crates/bevy_reflect/src/type_info.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::any::{Any, TypeId};
55

66
/// A static accessor to compile-time type information.
77
///
8-
/// This trait is automatically implemented by the [`Reflect` derive macro]
8+
/// This trait is automatically implemented by the [`#[derive(Reflect)]`](derive@crate::Reflect) macro
99
/// and allows type information to be processed without an instance of that type.
1010
///
1111
/// # Implementing
@@ -65,7 +65,6 @@ use std::any::{Any, TypeId};
6565
/// # }
6666
/// ```
6767
///
68-
/// [`Reflect` derive macro]: bevy_reflect_derive::Reflect
6968
/// [utility]: crate::utility
7069
pub trait Typed: Reflect {
7170
/// Returns the compile-time [info] for the underlying type.

crates/bevy_reflect/src/type_registry.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ use std::{any::TypeId, fmt::Debug, sync::Arc};
1111
/// This struct is used as the central store for type information.
1212
/// [Registering] a type will generate a new [`TypeRegistration`] entry in this store
1313
/// using a type's [`GetTypeRegistration`] implementation
14-
/// (which will is automatically implemented when using the [`Reflect` derive macro]).
14+
/// (which is automatically implemented when using [`#[derive(Reflect)]`](derive@crate::Reflect)).
1515
///
1616
/// See the [crate-level documentation] for more information.
1717
///
1818
/// [reflected]: crate
1919
/// [Registering]: TypeRegistry::register
20-
/// [`Reflect` derive macro]: bevy_reflect_derive::Reflect
2120
/// [crate-level documentation]: crate
2221
pub struct TypeRegistry {
2322
registrations: HashMap<TypeId, TypeRegistration>,
@@ -43,12 +42,11 @@ impl Debug for TypeRegistryArc {
4342
/// A trait which allows a type to generate its [`TypeRegistration`]
4443
/// for registration into the [`TypeRegistry`].
4544
///
46-
/// This trait is automatically implemented for items using the [`Reflect` derive macro].
45+
/// This trait is automatically implemented for items using [`#[derive(Reflect)]`](derive@crate::Reflect).
4746
/// The macro also allows [`TypeData`] to be more easily registered.
4847
///
4948
/// See the [crate-level documentation] for more information on type registration.
5049
///
51-
/// [`Reflect` derive macro]: bevy_reflect_derive::Reflect
5250
/// [crate-level documentation]: crate
5351
pub trait GetTypeRegistration {
5452
fn get_type_registration() -> TypeRegistration;
@@ -279,7 +277,7 @@ impl TypeRegistryArc {
279277
/// Runtime storage for type metadata, registered into the [`TypeRegistry`].
280278
///
281279
/// An instance of `TypeRegistration` can be created using the [`TypeRegistration::of`] method,
282-
/// but is more often automatically generated using the [`Reflect` derive macro] which itself generates
280+
/// but is more often automatically generated using [`#[derive(Reflect)]`](derive@crate::Reflect) which itself generates
283281
/// an implementation of the [`GetTypeRegistration`] trait.
284282
///
285283
/// Along with the type's [`TypeInfo`] and [short name],
@@ -300,7 +298,6 @@ impl TypeRegistryArc {
300298
/// assert!(registration.data::<ReflectDefault>().is_some())
301299
/// ```
302300
///
303-
/// [`Reflect` derive macro]: bevy_reflect_derive::Reflect
304301
/// [short name]: bevy_utils::get_short_name
305302
/// [crate-level documentation]: crate
306303
pub struct TypeRegistration {
@@ -403,13 +400,12 @@ impl Clone for TypeRegistration {
403400
///
404401
/// Type data can be registered to the [`TypeRegistry`] and stored on a type's [`TypeRegistration`].
405402
///
406-
/// While type data is often generated using the [`#[reflect_trait]`][0] macro,
403+
/// While type data is often generated using the [`#[reflect_trait]`](crate::reflect_trait) macro,
407404
/// almost any type that implements [`Clone`] can be considered "type data".
408405
/// This is because it has a blanket implementation over all `T` where `T: Clone + Send + Sync + 'static`.
409406
///
410407
/// See the [crate-level documentation] for more information on type data and type registration.
411408
///
412-
/// [0]: crate::reflect_trait
413409
/// [crate-level documentation]: crate
414410
pub trait TypeData: Downcast + Send + Sync {
415411
fn clone_type_data(&self) -> Box<dyn TypeData>;

0 commit comments

Comments
 (0)