Skip to content

Commit

Permalink
Merge #229
Browse files Browse the repository at this point in the history
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 <lili.andersen@nrk.no>
  • Loading branch information
bors[bot] and lilizoey authored Apr 14, 2023
2 parents 230480d + 8ff69e0 commit 885bb91
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
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

0 comments on commit 885bb91

Please sign in to comment.