Skip to content

Commit f252d57

Browse files
committed
Minor doc (mod export/init)
1 parent cc8ff55 commit f252d57

File tree

2 files changed

+38
-27
lines changed

2 files changed

+38
-27
lines changed

gdnative-core/src/export/mod.rs

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Functionality for user-defined types exported to the engine (native scripts)
1+
//! Functionality for user-defined types exported to the engine (native scripts).
22
//!
33
//! NativeScript allows users to have their own scripts in a native language (in this case Rust).
44
//! It is _not_ the same as GDNative, the native interface to call into Godot.
@@ -8,32 +8,7 @@
88
//! If you are looking for how to manage Godot core types or classes (objects), check
99
//! out the [`core_types`][crate::core_types] and [`object`][crate::object] modules, respectively.
1010
//!
11-
//! ## Init and exit hooks
12-
//!
13-
//! Three endpoints are automatically invoked by the engine during startup and shutdown:
14-
//!
15-
//! * [`godot_gdnative_init`],
16-
//! * [`godot_nativescript_init`],
17-
//! * [`godot_gdnative_terminate`],
18-
//!
19-
//! All three must be present. To quickly define all three endpoints using the default names,
20-
//! use [`godot_init`].
21-
//!
22-
//! ## Registering script classes
23-
//!
24-
//! [`InitHandle`] is the registry of all your exported symbols.
25-
//! To register script classes, call [`InitHandle::add_class()`] or [`InitHandle::add_tool_class()`]
26-
//! in your [`godot_nativescript_init`] or [`godot_init`] callback:
27-
//!
28-
//! ```ignore
29-
//! use gdnative::prelude::*;
30-
//!
31-
//! fn init(handle: InitHandle) {
32-
//! handle.add_class::<HelloWorld>();
33-
//! }
34-
//!
35-
//! godot_init!(init);
36-
//! ```
11+
//! To handle initialization and shutdown of godot-rust, take a look at the [`init`][crate::init] module.
3712
//!
3813
//! For full examples, see [`examples`](https://github.com/godot-rust/godot-rust/tree/master/examples)
3914
//! in the godot-rust repository.

gdnative-core/src/init/mod.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,40 @@
11
//! Global initialization and termination of the library.
2+
//!
3+
//! This module provides all the plumbing required for global initialization and shutdown of godot-rust.
4+
//!
5+
//! ## Init and exit hooks
6+
//!
7+
//! Three endpoints are automatically invoked by the engine during startup and shutdown:
8+
//!
9+
//! * [`godot_gdnative_init`],
10+
//! * [`godot_nativescript_init`],
11+
//! * [`godot_gdnative_terminate`],
12+
//!
13+
//! All three must be present. To quickly define all three endpoints using the default names,
14+
//! use [`godot_init`].
15+
//!
16+
//! ## Registering script classes
17+
//!
18+
//! [`InitHandle`] is the registry of all your exported symbols.
19+
//! To register script classes, call [`InitHandle::add_class()`] or [`InitHandle::add_tool_class()`]
20+
//! in your `godot_nativescript_init` or `godot_init` callback:
21+
//!
22+
//! ```no_run
23+
//! use gdnative::prelude::*;
24+
//!
25+
//! #[derive(NativeClass)]
26+
//! # #[no_constructor]
27+
//! struct HelloWorld { /* ... */ }
28+
//!
29+
//! #[methods]
30+
//! impl HelloWorld { /* ... */ }
31+
//!
32+
//! fn init(handle: InitHandle) {
33+
//! handle.add_class::<HelloWorld>();
34+
//! }
35+
//!
36+
//! godot_init!(init);
37+
//! ```
238
339
mod info;
440
mod init_handle;

0 commit comments

Comments
 (0)