@@ -22,7 +22,27 @@ use crate::util::ident;
22
22
// Below intra-doc link to the trait only works as HTML, not as symbol link.
23
23
/// Derive macro for [`GodotClass`](../obj/trait.GodotClass.html) on structs.
24
24
///
25
- /// You must use this macro; manual implementations of the `GodotClass` trait are not supported.
25
+ /// You should use this macro; manual implementations of the `GodotClass` trait are not encouraged.
26
+ ///
27
+ /// This is typically used in combination with [`#[godot_api]`](attr.godot_api.html), which can implement custom functions and constants,
28
+ /// as well as override virtual methods.
29
+ ///
30
+ /// See also [book chapter _Registering classes_](https://godot-rust.github.io/book/register/classes.html).
31
+ ///
32
+ /// **Table of contents:**
33
+ /// - [Construction](#construction)
34
+ /// - [Inheritance](#inheritance)
35
+ /// - [Properties and exports](#properties-and-exports)
36
+ /// - [Property registration](#property-registration)
37
+ /// - [Property exports](#property-exports)
38
+ /// - [Signals](#signals)
39
+ /// - [Further class customization](#further-class-customization)
40
+ /// - [Running code in the editor](#running-code-in-the-editor)
41
+ /// - [Editor plugins](#editor-plugins)
42
+ /// - [Class renaming](#class-renaming)
43
+ /// - [Class hiding](#class-hiding)
44
+ /// - [Further field customization](#further-field-customization)
45
+ /// - [Fine-grained inference hints](#fine-grained-inference-hints)
26
46
///
27
47
///
28
48
/// # Construction
@@ -117,12 +137,15 @@ use crate::util::ident;
117
137
///
118
138
/// # Properties and exports
119
139
///
140
+ /// See also [book chapter _Registering properties_](https://godot-rust.github.io/book/register/properties.html#registering-properties).
141
+ ///
120
142
/// In GDScript, there is a distinction between
121
143
/// [properties](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html#properties-setters-and-getters)
122
144
/// (fields with a `get` or `set` declaration) and
123
145
/// [exports](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_exports.html)
124
- /// (fields annotated with `@export`). In the GDExtension API, these two concepts are represented with
125
- /// `#[var]` and `#[export]` attributes respectively.
146
+ /// (fields annotated with `@export`). In the gdext API, these two concepts are represented with `#[var]` and `#[export]` attributes respectively.
147
+ ///
148
+ /// ## Property registration
126
149
///
127
150
/// To create a property, you can use the `#[var]` annotation:
128
151
///
@@ -190,6 +213,8 @@ use crate::util::ident;
190
213
/// }
191
214
/// ```
192
215
///
216
+ /// ## Property exports
217
+ ///
193
218
/// For exporting properties to the editor, you can use the `#[export]` attribute:
194
219
///
195
220
/// ```
@@ -314,7 +339,9 @@ use crate::util::ident;
314
339
/// }
315
340
/// ```
316
341
///
317
- /// # Running code in the editor
342
+ /// # Further class customization
343
+ ///
344
+ /// ## Running code in the editor
318
345
///
319
346
/// If you annotate a class with `#[class(tool)]`, its lifecycle methods (`ready()`, `process()` etc.) will be invoked in the editor. This
320
347
/// is useful for writing custom editor plugins, as opposed to classes running simply in-game.
@@ -324,7 +351,7 @@ use crate::util::ident;
324
351
///
325
352
/// This is very similar to [GDScript's `@tool` feature](https://docs.godotengine.org/en/stable/tutorials/plugins/running_code_in_the_editor.html).
326
353
///
327
- /// # Editor plugins
354
+ /// ## Editor plugins
328
355
///
329
356
/// If you annotate a class with `#[class(editor_plugin)]`, it will be turned into an editor plugin. The
330
357
/// class must then inherit from `EditorPlugin`, and an instance of that class will be automatically added
@@ -338,7 +365,7 @@ use crate::util::ident;
338
365
/// This should usually be combined with `#[class(tool)]` so that the code you write will actually run in the
339
366
/// editor.
340
367
///
341
- /// # Class renaming
368
+ /// ## Class renaming
342
369
///
343
370
/// You may want to have structs with the same name. With Rust, this is allowed using `mod`. However in GDScript,
344
371
/// there are no modules, namespaces, or any such disambiguation. Therefore, you need to change the names before they
@@ -362,7 +389,7 @@ use crate::util::ident;
362
389
///
363
390
/// These classes will appear in the Godot editor and GDScript as "AnimalToad" or "NpcToad".
364
391
///
365
- /// # Hiding classes
392
+ /// ## Class hiding
366
393
///
367
394
/// If you want to register a class with Godot, but not have it show up in the editor then you can use `#[class(hide)]`.
368
395
///
@@ -376,7 +403,9 @@ use crate::util::ident;
376
403
/// Even though this class is a `Node` and it has an init function, it still won't show up in the editor as a node you can add to a scene
377
404
/// because we have added a `hide` key to the class. This will also prevent it from showing up in documentation.
378
405
///
379
- /// # Fine-grained inference hints
406
+ /// # Further field customization
407
+ ///
408
+ /// ## Fine-grained inference hints
380
409
///
381
410
/// The derive macro is relatively smart about recognizing `Base<T>` and `OnReady<T>` types, and works also if those are qualified.
382
411
///
@@ -415,18 +444,20 @@ pub fn derive_godot_class(input: TokenStream) -> TokenStream {
415
444
416
445
/// Proc-macro attribute to be used with `impl` blocks of [`#[derive(GodotClass)]`][GodotClass] structs.
417
446
///
447
+ /// See also [book chapter _Registering functions_](https://godot-rust.github.io/book/register/functions.html) and following.
448
+ ///
418
449
/// Can be used in two ways:
419
450
/// ```no_run
420
451
/// # use godot::prelude::*;
421
452
/// #[derive(GodotClass)]
422
453
/// #[class(init, base=Node)]
423
454
/// struct MyClass {}
424
455
///
425
- /// // 1) inherent impl block: user-defined, custom API
456
+ /// // 1) inherent impl block: user-defined, custom API.
426
457
/// #[godot_api]
427
458
/// impl MyClass { /* ... */ }
428
459
///
429
- /// // 2) trait impl block: implement Godot-specific APIs
460
+ /// // 2) trait impl block: implement Godot-specific APIs.
430
461
/// #[godot_api]
431
462
/// impl INode for MyClass { /* ... */ }
432
463
/// ```
@@ -635,8 +666,7 @@ pub fn bench(meta: TokenStream, input: TokenStream) -> TokenStream {
635
666
636
667
/// Proc-macro attribute to be used in combination with the [`ExtensionLibrary`] trait.
637
668
///
638
- /// [`ExtensionLibrary`]: trait.ExtensionLibrary.html
639
- // FIXME intra-doc link
669
+ /// [`ExtensionLibrary`]: ../init/trait.ExtensionLibrary.html
640
670
#[ proc_macro_attribute]
641
671
pub fn gdextension ( meta : TokenStream , input : TokenStream ) -> TokenStream {
642
672
translate_meta (
0 commit comments