@@ -73,6 +73,13 @@ struct GeneratedClassModule {
73
73
is_pub_sidecar : bool ,
74
74
}
75
75
76
+ struct Construction {
77
+ constructor : TokenStream ,
78
+ construct_doc : & ' static str ,
79
+ final_doc : Option < & ' static str > ,
80
+ godot_default_impl : TokenStream ,
81
+ }
82
+
76
83
fn make_class ( class : & Class , ctx : & mut Context , view : & ApiView ) -> GeneratedClass {
77
84
let class_name = class. name ( ) ;
78
85
@@ -90,8 +97,16 @@ fn make_class(class: &Class, ctx: &mut Context, view: &ApiView) -> GeneratedClas
90
97
None => ( quote ! { crate :: obj:: NoBase } , None ) ,
91
98
} ;
92
99
93
- let ( constructor, construct_doc, godot_default_impl) = make_constructor_and_default ( class, ctx) ;
94
- let construct_doc = construct_doc. replace ( "Self" , & class_name. rust_ty . to_string ( ) ) ;
100
+ let Construction {
101
+ constructor,
102
+ construct_doc,
103
+ final_doc,
104
+ godot_default_impl,
105
+ } = make_constructor_and_default ( class, ctx) ;
106
+
107
+ let mut extended_class_doc = construct_doc. replace ( "Self" , & class_name. rust_ty . to_string ( ) ) ;
108
+ extended_class_doc. push_str ( final_doc. unwrap_or_default ( ) ) ;
109
+
95
110
let api_level = class. api_level ;
96
111
let init_level = api_level. to_init_level ( ) ;
97
112
@@ -194,7 +209,7 @@ fn make_class(class: &Class, ctx: &mut Context, view: &ApiView) -> GeneratedClas
194
209
use super :: * ;
195
210
196
211
#[ doc = #class_doc]
197
- #[ doc = #construct_doc ]
212
+ #[ doc = #extended_class_doc ]
198
213
#cfg_attributes
199
214
#[ derive( Debug ) ]
200
215
#[ repr( C ) ]
@@ -386,10 +401,7 @@ fn make_class_module_file(classes_and_modules: Vec<GeneratedClassModule>) -> Tok
386
401
}
387
402
}
388
403
389
- fn make_constructor_and_default (
390
- class : & Class ,
391
- ctx : & Context ,
392
- ) -> ( TokenStream , & ' static str , TokenStream ) {
404
+ fn make_constructor_and_default ( class : & Class , ctx : & Context ) -> Construction {
393
405
let class_name = class. name ( ) ;
394
406
395
407
let godot_class_stringname = make_string_name ( & class_name. godot_ty ) ;
@@ -437,6 +449,15 @@ fn make_constructor_and_default(
437
449
has_godot_default_impl = true ;
438
450
}
439
451
452
+ let final_doc = if class. is_final {
453
+ Some (
454
+ "\n \n # Final class\n \n \
455
+ This class is _final_, meaning you cannot inherit from it.",
456
+ )
457
+ } else {
458
+ None
459
+ } ;
460
+
440
461
let godot_default_impl = if has_godot_default_impl {
441
462
let class_name = & class. name ( ) . rust_ty ;
442
463
quote ! {
@@ -450,7 +471,12 @@ fn make_constructor_and_default(
450
471
TokenStream :: new ( )
451
472
} ;
452
473
453
- ( constructor, construct_doc, godot_default_impl)
474
+ Construction {
475
+ constructor,
476
+ construct_doc,
477
+ final_doc,
478
+ godot_default_impl,
479
+ }
454
480
}
455
481
456
482
fn make_deref_impl ( class_name : & TyName , base_ty : & TokenStream ) -> TokenStream {
0 commit comments