Skip to content

Commit d7c6485

Browse files
authored
Merge pull request #1272 from godot-rust/qol/hide-editor-prefix
Require that classes starting with "Editor" be marked internal
2 parents ddc5b76 + 4a98dde commit d7c6485

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

godot-macros/src/class/derive_godot_class.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,15 @@ fn parse_struct_attributes(class: &venial::Struct) -> ParseResult<ClassAttribute
538538
if let Some(span) = parser.handle_alone_with_span("internal")? {
539539
require_api_version!("4.2", span, "#[class(internal)]")?;
540540
is_internal = true;
541+
} else {
542+
// Godot has an edge case where classes starting with "Editor" are implicitly hidden:
543+
// https://github.com/godotengine/godot/blob/ca452113d430cb96de409a297ff5b52389f1c9d9/editor/gui/create_dialog.cpp#L171-L173
544+
if class.name.to_string().starts_with("Editor") {
545+
return bail!(
546+
class.name.span(),
547+
"Classes starting with `Editor` are implicitly hidden by Godot; use #[class(internal)] to make this explicit",
548+
);
549+
}
541550
}
542551

543552
// Deprecated #[class(hidden)]

godot-macros/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,9 @@ use crate::util::{bail, ident, KvParser};
452452
///
453453
/// ## Class hiding
454454
///
455-
/// If you want to register a class with Godot, but not have it show up in the editor then you can use `#[class(internal)]`.
455+
/// If you want to register a class with Godot, but not display in the editor (e.g. when creating a new node), you can use `#[class(internal)]`.
456+
///
457+
/// Classes starting with "Editor" are auto-hidden by Godot. They *must* be marked as internal in godot-rust.
456458
///
457459
/// ```
458460
/// # use godot::prelude::*;
@@ -540,7 +542,8 @@ use crate::util::{bail, ident, KvParser};
540542
alias = "var",
541543
alias = "export",
542544
alias = "tool",
543-
alias = "rename"
545+
alias = "rename",
546+
alias = "internal"
544547
)]
545548
#[proc_macro_derive(
546549
GodotClass,

0 commit comments

Comments
 (0)