Skip to content

Commit 885bb91

Browse files
bors[bot]lilizoey
andauthored
Merge #229
229: Fix `(no base)` showing up in all the docs r=Bromeon a=sayaks We were setting `class_name` to be `(no base)` in the `PropertyInfo` for all types by default. However that makes godot show the `class_name` in return values and arguments. I dont know if there's a good way to test this? It would involve us checking what documentation is generated by godot which doesn't seem like something we can easily do. closes #159 Co-authored-by: Lili Zoey <[email protected]>
2 parents 230480d + 8ff69e0 commit 885bb91

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

godot-core/src/builtin/array.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -883,12 +883,7 @@ struct TypeInfo {
883883
impl TypeInfo {
884884
fn new<T: VariantMetadata>() -> Self {
885885
let variant_type = T::variant_type();
886-
let class_name = match variant_type {
887-
VariantType::Object => StringName::from(T::class_name()),
888-
// TODO for variant types other than Object, class_name() returns "(no base)"; just
889-
// make it return "" instead?
890-
_ => StringName::default(),
891-
};
886+
let class_name: StringName = T::class_name().into();
892887
Self {
893888
variant_type,
894889
class_name,

godot-core/src/builtin/meta/class_name.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ pub struct ClassName {
1919
}
2020

2121
impl ClassName {
22+
/// In Godot, an empty `StringName` in a place that expects a class name, means that there is no class.
23+
pub fn none() -> Self {
24+
Self {
25+
backing: StringName::default(),
26+
}
27+
}
28+
2229
pub fn of<T: GodotClass>() -> Self {
2330
Self {
2431
backing: StringName::from(T::CLASS_NAME),

godot-core/src/builtin/meta/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ pub trait VariantMetadata {
2323
fn variant_type() -> VariantType;
2424

2525
fn class_name() -> ClassName {
26-
ClassName::of::<()>() // FIXME Option or so
26+
// If we use `ClassName::of::<()>()` then this type shows up as `(no base)` in documentation.
27+
ClassName::none()
2728
}
2829

2930
fn property_info(property_name: &str) -> PropertyInfo {

0 commit comments

Comments
 (0)