Skip to content

Commit 4c51ed4

Browse files
committed
Several doc improvements
1 parent 3734725 commit 4c51ed4

File tree

13 files changed

+34
-18
lines changed

13 files changed

+34
-18
lines changed

godot-core/src/builtin/aabb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ impl Aabb {
385385
impl std::fmt::Display for Aabb {
386386
/// Formats `Aabb` to match godot's display style.
387387
///
388-
/// Example:
388+
/// # Example
389389
/// ```
390390
/// use godot::prelude::*;
391391
/// let aabb = Aabb::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(1.0, 1.0, 1.0));

godot-core/src/builtin/array.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ impl<T: GodotType> fmt::Debug for Array<T> {
677677
impl<T: GodotType + fmt::Display> fmt::Display for Array<T> {
678678
/// Formats `Array` to match Godot's string representation.
679679
///
680-
/// Example:
680+
/// # Example
681681
/// ```no_run
682682
/// # use godot::prelude::*;
683683
/// let a = array![1,2,3,4];
@@ -985,13 +985,16 @@ impl<T: GodotType> PartialOrd for Array<T> {
985985
///
986986
/// The type of the array is inferred from the arguments.
987987
///
988-
/// Example:
988+
/// # Example
989989
/// ```no_run
990990
/// # use godot::prelude::*;
991991
/// let arr = array![3, 1, 4]; // Array<i32>
992992
/// ```
993993
///
994+
/// # See also
994995
/// To create an `Array` of variants, see the [`varray!`] macro.
996+
///
997+
/// For dictionaries, a similar macro [`dict!`] exists.
995998
#[macro_export]
996999
macro_rules! array {
9971000
($($elements:expr),* $(,)?) => {
@@ -1007,15 +1010,18 @@ macro_rules! array {
10071010

10081011
/// Constructs [`VariantArray`] literals, similar to Rust's standard `vec!` macro.
10091012
///
1010-
/// The type of the array is always [`Variant`].
1013+
/// The type of the array elements is always [`Variant`].
10111014
///
1012-
/// Example:
1015+
/// # Example
10131016
/// ```no_run
10141017
/// # use godot::prelude::*;
10151018
/// let arr: VariantArray = varray![42_i64, "hello", true];
10161019
/// ```
10171020
///
1021+
/// # See also
10181022
/// To create a typed `Array` with a single element type, see the [`array!`] macro.
1023+
///
1024+
/// For dictionaries, a similar macro [`dict!`] exists.
10191025
#[macro_export]
10201026
macro_rules! varray {
10211027
// Note: use to_variant() and not Variant::from(), as that works with both references and values

godot-core/src/builtin/color.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ fn to_be_words(mut u: u64) -> [u16; 4] {
520520
impl std::fmt::Display for Color {
521521
/// Formats `Color` to match Godot's string representation.
522522
///
523-
/// Example:
523+
/// # Example
524524
/// ```
525525
/// use godot::prelude::*;
526526
/// let color = Color::from_rgba(1.0,1.0,1.0,1.0);

godot-core/src/builtin/dictionary.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ impl<'a, K: FromGodot> Iterator for TypedKeys<'a, K> {
632632
/// Any value can be used as a key, but to use an expression you need to surround it
633633
/// in `()` or `{}`.
634634
///
635-
/// Example:
635+
/// # Example
636636
/// ```no_run
637637
/// use godot::builtin::{dict, Variant};
638638
///
@@ -644,6 +644,10 @@ impl<'a, K: FromGodot> Iterator for TypedKeys<'a, K> {
644644
/// (1 + 2): "final",
645645
/// };
646646
/// ```
647+
///
648+
/// # See also
649+
///
650+
/// For arrays, similar macros [`array!`][macro@crate::builtin::array] and [`varray!`][macro@crate::builtin::varray] exist.
647651
#[macro_export]
648652
macro_rules! dict {
649653
($($key:tt: $value:expr),* $(,)?) => {

godot-core/src/builtin/plane.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ impl ApproxEq for Plane {
288288
impl std::fmt::Display for Plane {
289289
/// Formats `Plane` to match Godot's string representation.
290290
///
291-
/// Example:
291+
/// # Example
292292
/// ```
293293
/// use godot::prelude::*;
294294
/// let plane = Plane::new(Vector3::new(1.0, 0.0, 0.0), 1.0);

godot-core/src/builtin/projection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ pub enum ProjectionEye {
581581
impl std::fmt::Display for Projection {
582582
/// Formats `Projection` to match Godot's string representation.
583583
///
584-
/// Example:
584+
/// # Example
585585
/// ```
586586
/// use godot::prelude::*;
587587
/// let proj = Projection::new([

godot-core/src/builtin/real.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ macro_rules! real {
202202

203203
/// Array of reals.
204204
///
205+
/// The expression has type `[real; N]` where `N` is the number of elements in the array.
206+
///
205207
/// # Example
206208
/// ```
207209
/// use godot_core::builtin::{real, reals};

godot-core/src/builtin/rect2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl ApproxEq for Rect2 {
278278
impl std::fmt::Display for Rect2 {
279279
/// Formats `Rect2` to match Godot's string representation.
280280
///
281-
/// Example:
281+
/// # Example
282282
/// ```
283283
/// use godot::prelude::*;
284284
/// let rect = Rect2::new(Vector2::new(0.0, 0.0), Vector2::new(1.0, 1.0));

godot-core/src/builtin/rect2i.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl_godot_as_self!(Rect2i);
279279
impl std::fmt::Display for Rect2i {
280280
/// Formats `Rect2i` to match Godot's string representation.
281281
///
282-
/// Example:
282+
/// # Example
283283
/// ```
284284
/// use godot::prelude::*;
285285
/// let rect = Rect2i::new(Vector2i::new(0, 0), Vector2i::new(1, 1));

godot-core/src/builtin/rid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl Rid {
101101
impl std::fmt::Display for Rid {
102102
/// Formats `Rid` to match Godot's string representation.
103103
///
104-
/// Example:
104+
/// # Example
105105
/// ```
106106
/// use godot::prelude::*;
107107
/// let id = Rid::new(1);

godot-core/src/log.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
66
*/
77

8+
//! Printing and logging functionality.
9+
810
#[macro_export]
911
#[doc(hidden)]
1012
macro_rules! inner_godot_msg {
@@ -33,7 +35,7 @@ macro_rules! inner_godot_msg {
3335

3436
/// Pushes a warning message to Godot's built-in debugger and to the OS terminal.
3537
///
36-
/// _Godot equivalent: @GlobalScope.push_warning()_
38+
/// _Godot equivalent: [`@GlobalScope.push_warning()`](https://docs.godotengine.org/en/stable/classes/[email protected]#class-globalscope-method-push-warning)_.
3739
#[macro_export]
3840
macro_rules! godot_warn {
3941
($fmt:literal $(, $args:expr)* $(,)?) => {
@@ -43,14 +45,15 @@ macro_rules! godot_warn {
4345

4446
/// Pushes an error message to Godot's built-in debugger and to the OS terminal.
4547
///
46-
/// _Godot equivalent: @GlobalScope.push_error()_
48+
/// _Godot equivalent: [`@GlobalScope.push_error()`](https://docs.godotengine.org/en/stable/classes/[email protected]#class-globalscope-method-push-error)_.
4749
#[macro_export]
4850
macro_rules! godot_error {
4951
($fmt:literal $(, $args:expr)* $(,)?) => {
5052
$crate::inner_godot_msg!(print_error; $fmt $(, $args)*);
5153
};
5254
}
5355

56+
/// Logs a script error to Godot's built-in debugger and to the OS terminal.
5457
#[macro_export]
5558
macro_rules! godot_script_error {
5659
($fmt:literal $(, $args:expr)* $(,)?) => {
@@ -60,7 +63,7 @@ macro_rules! godot_script_error {
6063

6164
/// Prints to the Godot console.
6265
///
63-
/// _Godot equivalent: @GlobalScope.print()_
66+
/// _Godot equivalent: [`@GlobalScope.print()`](https://docs.godotengine.org/en/stable/classes/[email protected]#class-globalscope-method-print)_.
6467
#[macro_export]
6568
macro_rules! godot_print {
6669
($fmt:literal $(, $args:expr)* $(,)?) => {
@@ -79,7 +82,7 @@ pub use crate::{godot_error, godot_print, godot_script_error, godot_warn};
7982
use crate::builtin::{StringName, Variant};
8083
use crate::sys::{self, GodotFfi};
8184

82-
/// Prints to the Godot console, used by the godot_print! macro.
85+
/// Prints to the Godot console, used by the [`godot_print!`] macro.
8386
pub fn print(varargs: &[Variant]) {
8487
unsafe {
8588
let method_name = StringName::from("print");

godot-core/src/obj/gd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ where
113113
/// The `init` function provides you with a `Base<T::Base>` object that you can use inside your `T`, which
114114
/// is then wrapped in a `Gd<T>`.
115115
///
116-
/// Example:
116+
/// # Example
117117
/// ```no_run
118118
/// # use godot::prelude::*;
119119
/// #[derive(GodotClass)]

godot/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,15 @@ compile_error!("Must opt-in using `experimental-wasm` Cargo feature; keep in min
192192
#[cfg(all(feature = "double-precision", not(feature = "custom-godot")))]
193193
compile_error!("The feature `double-precision` currently requires `custom-godot` due to incompatibilities in the GDExtension API JSON.");
194194

195+
/// Entry point and global init/shutdown of the library.
195196
pub mod init {
196197
pub use godot_core::init::*;
197198

198199
// Re-exports
199200
pub use godot_macros::gdextension;
200201
}
201202

202-
/// Register Rust symbols in Godot: classes, methods, enums...
203+
/// Register/export Rust symbols to Godot: classes, methods, enums...
203204
pub mod register {
204205
pub use godot_core::property;
205206
pub use godot_macros::{godot_api, Export, FromGodot, GodotClass, GodotConvert, ToGodot, Var};

0 commit comments

Comments
 (0)