Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ track_location = ["bevy_internal/track_location"]
# Enable function reflection
reflect_functions = ["bevy_internal/reflect_functions"]

# Enable documentation reflection
# Enables bevy_reflect to access documentation comments of rust code at runtime
reflect_documentation = ["bevy_internal/reflect_documentation"]

# Enable automatic reflect registration
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ reflect_auto_register_static = [
"bevy_ecs/reflect_auto_register",
]

# Enable documentation reflection
reflect_documentation = ["bevy_reflect/documentation"]
# Enables bevy_reflect to access documentation comments of rust code at runtime
reflect_documentation = ["bevy_reflect/reflect_documentation"]

# Enable custom cursor support
custom_cursor = ["bevy_window/custom_cursor", "bevy_winit/custom_cursor"]
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_reflect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default = ["std", "smallvec", "debug", "auto_register_inventory"]
# Features

## When enabled, allows documentation comments to be accessed via reflection
documentation = ["bevy_reflect_derive/documentation"]
reflect_documentation = ["bevy_reflect_derive/reflect_documentation"]

## Enables function reflection
functions = ["bevy_reflect_derive/functions"]
Expand Down Expand Up @@ -143,7 +143,7 @@ static_assertions = "1.1.0"
[[example]]
name = "reflect_docs"
path = "examples/reflect_docs.rs"
required-features = ["documentation"]
required-features = ["reflect_documentation"]

[lints]
workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_reflect/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ proc-macro = true
[features]
default = []
# When enabled, allows documentation comments to be processed by the reflection macros
documentation = []
reflect_documentation = []
# Enables macro logic related to function reflection
functions = []
# Enables automatic reflect registration. Does nothing by itself,
Expand Down
30 changes: 15 additions & 15 deletions crates/bevy_reflect/derive/src/derive_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub(crate) struct ReflectMeta<'a> {
/// A cached instance of the path to the `bevy_reflect` crate.
bevy_reflect_path: Path,
/// The documentation for this type, if any
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
docs: crate::documentation::Documentation,
}

Expand Down Expand Up @@ -115,7 +115,7 @@ pub(crate) struct StructField<'a> {
/// [ignored]: crate::field_attributes::ReflectIgnoreBehavior::IgnoreAlways
pub reflection_index: Option<usize>,
/// The documentation for this field, if any
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
pub doc: crate::documentation::Documentation,
}

Expand All @@ -128,7 +128,7 @@ pub(crate) struct EnumVariant<'a> {
/// The reflection-based attributes on the variant.
pub attrs: FieldAttributes,
/// The documentation for this variant, if any
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
pub doc: crate::documentation::Documentation,
}

Expand Down Expand Up @@ -191,7 +191,7 @@ impl<'a> ReflectDerive<'a> {
// Should indicate whether `#[type_name = "..."]` was used.
let mut custom_type_name: Option<Ident> = None;

#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
let mut doc = crate::documentation::Documentation::default();

for attribute in &input.attrs {
Expand Down Expand Up @@ -239,7 +239,7 @@ impl<'a> ReflectDerive<'a> {

custom_type_name = Some(parse_str(&lit.value())?);
}
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
Meta::NameValue(pair) if pair.path.is_ident("doc") => {
if let syn::Expr::Lit(syn::ExprLit {
lit: syn::Lit::Str(lit),
Expand Down Expand Up @@ -284,7 +284,7 @@ impl<'a> ReflectDerive<'a> {
));
}

#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
let meta = meta.with_docs(doc);

if meta.attrs().is_opaque() {
Expand Down Expand Up @@ -391,7 +391,7 @@ impl<'a> ReflectDerive<'a> {
reflection_index,
attrs,
data: field,
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
doc: crate::documentation::Documentation::from_attributes(&field.attrs),
})
},
Expand All @@ -418,7 +418,7 @@ impl<'a> ReflectDerive<'a> {
fields,
attrs: FieldAttributes::parse_attributes(&variant.attrs)?,
data: variant,
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
doc: crate::documentation::Documentation::from_attributes(&variant.attrs),
})
})
Expand All @@ -435,13 +435,13 @@ impl<'a> ReflectMeta<'a> {
type_path,
remote_ty: None,
bevy_reflect_path: crate::meta::get_bevy_reflect_path(),
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
docs: Default::default(),
}
}

/// Sets the documentation for this type.
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
pub fn with_docs(self, docs: crate::documentation::Documentation) -> Self {
Self { docs, ..self }
}
Expand Down Expand Up @@ -498,7 +498,7 @@ impl<'a> ReflectMeta<'a> {
}

/// The collection of docstrings for this type, if any.
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
pub fn doc(&self) -> &crate::documentation::Documentation {
&self.docs
}
Expand Down Expand Up @@ -536,7 +536,7 @@ impl<'a> StructField<'a> {
});
}

#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
{
let docs = &self.doc;
if !docs.is_empty() {
Expand Down Expand Up @@ -684,7 +684,7 @@ impl<'a> ReflectStruct<'a> {
});
}

#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
{
let docs = self.meta().doc();
if !docs.is_empty() {
Expand Down Expand Up @@ -907,7 +907,7 @@ impl<'a> ReflectEnum<'a> {
});
}

#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
{
let docs = self.meta().doc();
if !docs.is_empty() {
Expand Down Expand Up @@ -1026,7 +1026,7 @@ impl<'a> EnumVariant<'a> {
});
}

#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
{
let docs = &self.doc;
if !docs.is_empty() {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_reflect/derive/src/impls/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ pub(crate) fn impl_opaque(meta: &ReflectMeta) -> proc_macro2::TokenStream {
let bevy_reflect_path = meta.bevy_reflect_path();
let type_path = meta.type_path();

#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
let with_docs = {
let doc = quote::ToTokens::to_token_stream(meta.doc());
Some(quote!(.with_docs(#doc)))
};
#[cfg(not(feature = "documentation"))]
#[cfg(not(feature = "reflect_documentation"))]
let with_docs: Option<proc_macro2::TokenStream> = None;

let where_clause_options = WhereClauseOptions::new(meta);
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_reflect/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extern crate proc_macro;
mod container_attributes;
mod custom_attributes;
mod derive_data;
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
mod documentation;
mod enum_utility;
mod field_attributes;
Expand Down Expand Up @@ -680,7 +680,7 @@ pub fn impl_reflect_opaque(input: TokenStream) -> TokenStream {

let meta = ReflectMeta::new(type_path, def.traits.unwrap_or_default());

#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
let meta = meta.with_docs(documentation::Documentation::from_attributes(&def.attrs));

let reflect_impls = impls::impl_opaque(&meta);
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_reflect/derive/src/reflect_opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use syn::{parenthesized, parse::ParseStream, token::Paren, Attribute, Generics,
/// ```
pub(crate) struct ReflectOpaqueDef {
#[cfg_attr(
not(feature = "documentation"),
not(feature = "reflect_documentation"),
expect(
dead_code,
reason = "The is used when the `documentation` feature is enabled.",
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_reflect/examples/reflect_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! For example, you may want to generate schemas or other external documentation for scripting.
//! Or perhaps you want your custom editor to display tooltips for certain properties that match the documentation.
//!
//! These scenarios can readily be achieved by using `bevy_reflect` with the `documentation` feature.
//! These scenarios can readily be achieved by using `bevy_reflect` with the `reflect_documentation` feature.

#![expect(clippy::print_stdout, reason = "Allowed in examples.")]

Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_reflect/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub struct ArrayInfo {
item_info: fn() -> Option<&'static TypeInfo>,
item_ty: Type,
capacity: usize,
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
docs: Option<&'static str>,
}

Expand All @@ -109,13 +109,13 @@ impl ArrayInfo {
item_info: TItem::maybe_type_info,
item_ty: Type::of::<TItem>(),
capacity,
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
docs: None,
}
}

/// Sets the docstring for this array.
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
pub fn with_docs(self, docs: Option<&'static str>) -> Self {
Self { docs, ..self }
}
Expand Down Expand Up @@ -143,7 +143,7 @@ impl ArrayInfo {
}

/// The docstring of this array, if any.
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
pub fn docs(&self) -> Option<&'static str> {
self.docs
}
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_reflect/src/enums/enum_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub struct EnumInfo {
variant_names: Box<[&'static str]>,
variant_indices: HashMap<&'static str, usize>,
custom_attributes: Arc<CustomAttributes>,
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
docs: Option<&'static str>,
}

Expand All @@ -180,13 +180,13 @@ impl EnumInfo {
variant_names,
variant_indices,
custom_attributes: Arc::new(CustomAttributes::default()),
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
docs: None,
}
}

/// Sets the docstring for this enum.
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
pub fn with_docs(self, docs: Option<&'static str>) -> Self {
Self { docs, ..self }
}
Expand Down Expand Up @@ -246,7 +246,7 @@ impl EnumInfo {
impl_type_methods!(ty);

/// The docstring of this enum, if any.
#[cfg(feature = "documentation")]
#[cfg(feature = "reflect_documentation")]
pub fn docs(&self) -> Option<&'static str> {
self.docs
}
Expand Down
Loading