Skip to content

Fix (no base) showing up in all the docs #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2023
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
7 changes: 1 addition & 6 deletions godot-core/src/builtin/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,12 +883,7 @@ struct TypeInfo {
impl TypeInfo {
fn new<T: VariantMetadata>() -> Self {
let variant_type = T::variant_type();
let class_name = match variant_type {
VariantType::Object => StringName::from(T::class_name()),
// TODO for variant types other than Object, class_name() returns "(no base)"; just
// make it return "" instead?
_ => StringName::default(),
};
let class_name: StringName = T::class_name().into();
Self {
variant_type,
class_name,
Expand Down
7 changes: 7 additions & 0 deletions godot-core/src/builtin/meta/class_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ pub struct ClassName {
}

impl ClassName {
/// In Godot, an empty `StringName` in a place that expects a class name, means that there is no class.
pub fn none() -> Self {
Self {
backing: StringName::default(),
}
}

pub fn of<T: GodotClass>() -> Self {
Self {
backing: StringName::from(T::CLASS_NAME),
Expand Down
3 changes: 2 additions & 1 deletion godot-core/src/builtin/meta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ pub trait VariantMetadata {
fn variant_type() -> VariantType;

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

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