From 7ef8801cfff71abab08b9a9a5425d5538e64a3da Mon Sep 17 00:00:00 2001 From: Julien Cretin Date: Wed, 17 Apr 2024 17:56:34 +0200 Subject: [PATCH] Add documentation to generated public items (#236) Fixes #235 --- derive/src/traits.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/derive/src/traits.rs b/derive/src/traits.rs index f99d722..5ba6f9f 100644 --- a/derive/src/traits.rs +++ b/derive/src/traits.rs @@ -485,6 +485,7 @@ fn generate_checked_bit_pattern_struct( Ok(( quote! { + #[doc = #GENERATED_TYPE_DOCUMENTATION] #repr #[derive(Clone, Copy, #crate_name::AnyBitPattern)] #derive_dbg @@ -652,6 +653,7 @@ fn generate_checked_bit_pattern_enum_with_fields( Ok(( quote! { + #[doc = #GENERATED_TYPE_DOCUMENTATION] #[derive(::core::clone::Clone, ::core::marker::Copy, #crate_name::AnyBitPattern)] #derive_dbg #bits_repr @@ -703,6 +705,7 @@ fn generate_checked_bit_pattern_enum_with_fields( Ok(( quote! { + #[doc = #GENERATED_TYPE_DOCUMENTATION] #[derive(::core::clone::Clone, ::core::marker::Copy, #crate_name::CheckedBitPattern)] #[repr(C)] #vis struct #bits_ty(#(#fields),*); @@ -775,6 +778,7 @@ fn generate_checked_bit_pattern_enum_with_fields( Ok(( quote! { + #[doc = #GENERATED_TYPE_DOCUMENTATION] #[derive(::core::clone::Clone, ::core::marker::Copy, #crate_name::AnyBitPattern)] #bits_repr #[allow(non_snake_case)] @@ -1263,3 +1267,6 @@ pub fn bytemuck_crate_name(input: &DeriveInput) -> TokenStream { return crate_name; } + +const GENERATED_TYPE_DOCUMENTATION: &str = + " `bytemuck`-generated type for internal purposes only.";