From e7a309ff5fcc477fcf4ed3fd14c452dafe74f4c6 Mon Sep 17 00:00:00 2001 From: theotherphil Date: Wed, 4 Jun 2025 01:06:32 +0100 Subject: [PATCH] deny(missing_docs) for bevy_derive (#19483) # Objective Deny missing docs in bevy_derive, towards https://github.com/bevyengine/bevy/issues/3492. --- crates/bevy_derive/src/lib.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/bevy_derive/src/lib.rs b/crates/bevy_derive/src/lib.rs index e446d0f50d..c2ce08cbae 100644 --- a/crates/bevy_derive/src/lib.rs +++ b/crates/bevy_derive/src/lib.rs @@ -1,4 +1,5 @@ -#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")] +//! Assorted proc macro derive functions. + #![forbid(unsafe_code)] #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![doc( @@ -188,11 +189,34 @@ pub fn derive_deref_mut(input: TokenStream) -> TokenStream { derefs::derive_deref_mut(input) } +/// Generates the required main function boilerplate for Android. #[proc_macro_attribute] pub fn bevy_main(attr: TokenStream, item: TokenStream) -> TokenStream { bevy_main::bevy_main(attr, item) } +/// Adds `enum_variant_index` and `enum_variant_name` functions to enums. +/// +/// # Example +/// +/// ``` +/// use bevy_derive::{EnumVariantMeta}; +/// +/// #[derive(EnumVariantMeta)] +/// enum MyEnum { +/// A, +/// B, +/// } +/// +/// let a = MyEnum::A; +/// let b = MyEnum::B; +/// +/// assert_eq!(0, a.enum_variant_index()); +/// assert_eq!("A", a.enum_variant_name()); +/// +/// assert_eq!(1, b.enum_variant_index()); +/// assert_eq!("B", b.enum_variant_name()); +/// ``` #[proc_macro_derive(EnumVariantMeta)] pub fn derive_enum_variant_meta(input: TokenStream) -> TokenStream { enum_variant_meta::derive_enum_variant_meta(input)