Add documentation to generated public items (#236)

Fixes #235
This commit is contained in:
Julien Cretin 2024-04-17 17:56:34 +02:00 committed by GitHub
parent eeb6e9dd53
commit 7ef8801cff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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.";