Skip to content

Commit

Permalink
Merge pull request #99081 from Mickeon/documentation-floats-now-print…
Browse files Browse the repository at this point in the history
…-the-trailing-zero

Update documentation's "Prints" comments after #47502
  • Loading branch information
Repiteo committed Dec 11, 2024
2 parents c2e4ae7 + d90f045 commit 61f2001
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 84 deletions.
36 changes: 18 additions & 18 deletions doc/classes/AABB.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
[gdscript]
var box = AABB(Vector3(5, 0, 5), Vector3(-20, -10, -5))
var absolute = box.abs()
print(absolute.position) # Prints (-15, -10, 0)
print(absolute.size) # Prints (20, 10, 5)
print(absolute.position) # Prints (-15.0, -10.0, 0.0)
print(absolute.size) # Prints (20.0, 10.0, 5.0)
[/gdscript]
[csharp]
var box = new Aabb(new Vector3(5, 0, 5), new Vector3(-20, -10, -5));
Expand Down Expand Up @@ -96,12 +96,12 @@
var box = AABB(Vector3(0, 0, 0), Vector3(5, 2, 5))

box = box.expand(Vector3(10, 0, 0))
print(box.position) # Prints (0, 0, 0)
print(box.size) # Prints (10, 2, 5)
print(box.position) # Prints (0.0, 0.0, 0.0)
print(box.size) # Prints (10.0, 2.0, 5.0)

box = box.expand(Vector3(-5, 0, 5))
print(box.position) # Prints (-5, 0, 0)
print(box.size) # Prints (15, 2, 5)
print(box.position) # Prints (-5.0, 0.0, 0.0)
print(box.size) # Prints (15.0, 2.0, 5.0)
[/gdscript]
[csharp]
var box = new Aabb(new Vector3(0, 0, 0), new Vector3(5, 2, 5));
Expand Down Expand Up @@ -138,15 +138,15 @@
[gdscript]
var box = AABB(Vector3(0, 0, 0), Vector3(2, 4, 8))

print(box.get_longest_axis()) # Prints (0, 0, 1)
print(box.get_longest_axis()) # Prints (0.0, 0.0, 1.0)
print(box.get_longest_axis_index()) # Prints 2
print(box.get_longest_axis_size()) # Prints 8
print(box.get_longest_axis_size()) # Prints 8.0
[/gdscript]
[csharp]
var box = new Aabb(new Vector3(0, 0, 0), new Vector3(2, 4, 8));

GD.Print(box.GetLongestAxis()); // Prints (0, 0, 1)
GD.Print(box.GetLongestAxisIndex()); // Prints 2
GD.Print(box.GetLongestAxisIndex()); // Prints Z
GD.Print(box.GetLongestAxisSize()); // Prints 8
[/csharp]
[/codeblocks]
Expand Down Expand Up @@ -175,15 +175,15 @@
[gdscript]
var box = AABB(Vector3(0, 0, 0), Vector3(2, 4, 8))

print(box.get_shortest_axis()) # Prints (1, 0, 0)
print(box.get_shortest_axis()) # Prints (1.0, 0.0, 0.0)
print(box.get_shortest_axis_index()) # Prints 0
print(box.get_shortest_axis_size()) # Prints 2
print(box.get_shortest_axis_size()) # Prints 2.0
[/gdscript]
[csharp]
var box = new Aabb(new Vector3(0, 0, 0), new Vector3(2, 4, 8));

GD.Print(box.GetShortestAxis()); // Prints (1, 0, 0)
GD.Print(box.GetShortestAxisIndex()); // Prints 0
GD.Print(box.GetShortestAxisIndex()); // Prints X
GD.Print(box.GetShortestAxisSize()); // Prints 2
[/csharp]
[/codeblocks]
Expand Down Expand Up @@ -225,12 +225,12 @@
[codeblocks]
[gdscript]
var a = AABB(Vector3(4, 4, 4), Vector3(8, 8, 8)).grow(4)
print(a.position) # Prints (0, 0, 0)
print(a.size) # Prints (16, 16, 16)
print(a.position) # Prints (0.0, 0.0, 0.0)
print(a.size) # Prints (16.0, 16.0, 16.0)

var b = AABB(Vector3(0, 0, 0), Vector3(8, 4, 2)).grow(2)
print(b.position) # Prints (-2, -2, -2)
print(b.size) # Prints (12, 8, 6)
print(b.position) # Prints (-2.0, -2.0, -2.0)
print(b.size) # Prints (12.0, 8.0, 6.0)
[/gdscript]
[csharp]
var a = new Aabb(new Vector3(4, 4, 4), new Vector3(8, 8, 8)).Grow(4);
Expand Down Expand Up @@ -275,8 +275,8 @@
var box2 = AABB(Vector3(2, 0, 2), Vector3(8, 4, 4))

var intersection = box1.intersection(box2)
print(intersection.position) # Prints (2, 0, 2)
print(intersection.size) # Prints (3, 2, 4)
print(intersection.position) # Prints (2.0, 0.0, 2.0)
print(intersection.size) # Prints (3.0, 2.0, 4.0)
[/gdscript]
[csharp]
var box1 = new Aabb(new Vector3(0, 0, 0), new Vector3(5, 2, 8));
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/AStarGrid2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
astar_grid.region = Rect2i(0, 0, 32, 32)
astar_grid.cell_size = Vector2(16, 16)
astar_grid.update()
print(astar_grid.get_id_path(Vector2i(0, 0), Vector2i(3, 4))) # prints (0, 0), (1, 1), (2, 2), (3, 3), (3, 4)
print(astar_grid.get_point_path(Vector2i(0, 0), Vector2i(3, 4))) # prints (0, 0), (16, 16), (32, 32), (48, 48), (48, 64)
print(astar_grid.get_id_path(Vector2i(0, 0), Vector2i(3, 4))) # Prints [(0, 0), (1, 1), (2, 2), (3, 3), (3, 4)]
print(astar_grid.get_point_path(Vector2i(0, 0), Vector2i(3, 4))) # Prints [(0, 0), (16, 16), (32, 32), (48, 48), (48, 64)]
[/gdscript]
[csharp]
AStarGrid2D astarGrid = new AStarGrid2D();
Expand Down
24 changes: 12 additions & 12 deletions doc/classes/Basis.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
# Creates a Basis whose z axis points down.
var my_basis = Basis.from_euler(Vector3(TAU / 4, 0, 0))

print(my_basis.z) # Prints (0, -1, 0)
print(my_basis.z) # Prints (0.0, -1.0, 0.0)
[/gdscript]
[csharp]
// Creates a Basis whose z axis points down.
Expand All @@ -112,9 +112,9 @@
[gdscript]
var my_basis = Basis.from_scale(Vector3(2, 4, 8))

print(my_basis.x) # Prints (2, 0, 0)
print(my_basis.y) # Prints (0, 4, 0)
print(my_basis.z) # Prints (0, 0, 8)
print(my_basis.x) # Prints (2.0, 0.0, 0.0)
print(my_basis.y) # Prints (0.0, 4.0, 0.0)
print(my_basis.z) # Prints (0.0, 0.0, 8.0)
[/gdscript]
[csharp]
var myBasis = Basis.FromScale(new Vector3(2.0f, 4.0f, 8.0f));
Expand Down Expand Up @@ -163,7 +163,7 @@
my_basis = my_basis.rotated(Vector3.UP, TAU / 2)
my_basis = my_basis.rotated(Vector3.RIGHT, TAU / 4)

print(my_basis.get_scale()) # Prints (2, 4, 8)
print(my_basis.get_scale()) # Prints (2.0, 4.0, 8.0)
[/gdscript]
[csharp]
var myBasis = new Basis(
Expand Down Expand Up @@ -285,9 +285,9 @@
)
my_basis = my_basis.scaled(Vector3(0, 2, -2))

print(my_basis.x) # Prints (0, 2, -2)
print(my_basis.y) # Prints (0, 4, -4)
print(my_basis.z) # Prints (0, 6, -6)
print(my_basis.x) # Prints (0.0, 2.0, -2.0)
print(my_basis.y) # Prints (0.0, 4.0, -4.0)
print(my_basis.z) # Prints (0.0, 6.0, -6.0)
[/gdscript]
[csharp]
var myBasis = new Basis(
Expand Down Expand Up @@ -360,9 +360,9 @@
)
my_basis = my_basis.transposed()

print(my_basis.x) # Prints (1, 4, 7)
print(my_basis.y) # Prints (2, 5, 8)
print(my_basis.z) # Prints (3, 6, 9)
print(my_basis.x) # Prints (1.0, 4.0, 7.0)
print(my_basis.y) # Prints (2.0, 5.0, 8.0)
print(my_basis.z) # Prints (3.0, 6.0, 9.0)
[/gdscript]
[csharp]
var myBasis = new Basis(
Expand Down Expand Up @@ -454,7 +454,7 @@
[gdscript]
# Basis that swaps the X/Z axes and doubles the scale.
var my_basis = Basis(Vector3(0, 2, 0), Vector3(2, 0, 0), Vector3(0, 0, 2))
print(my_basis * Vector3(1, 2, 3)) # Prints (4, 2, 6)
print(my_basis * Vector3(1, 2, 3)) # Prints (4.0, 2.0, 6.0)
[/gdscript]
[csharp]
// Basis that swaps the X/Z axes and doubles the scale.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/Callable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
func test():
var callable = Callable(self, "print_args")
callable.call("hello", "world") # Prints "hello world ".
callable.call(Vector2.UP, 42, callable) # Prints "(0, -1) 42 Node(node.gd)::print_args".
callable.call(Vector2.UP, 42, callable) # Prints "(0.0, -1.0) 42 Node(node.gd)::print_args".
callable.call("invalid") # Invalid call, should have at least 2 arguments.
[/gdscript]
[csharp]
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/Geometry2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@
var polygon = PackedVector2Array([Vector2(0, 0), Vector2(100, 0), Vector2(100, 100), Vector2(0, 100)])
var offset = Vector2(50, 50)
polygon = Transform2D(0, offset) * polygon
print(polygon) # prints [(50, 50), (150, 50), (150, 150), (50, 150)]
print(polygon) # Prints [(50.0, 50.0), (150.0, 50.0), (150.0, 150.0), (50.0, 150.0)]
[/gdscript]
[csharp]
var polygon = new Vector2[] { new Vector2(0, 0), new Vector2(100, 0), new Vector2(100, 100), new Vector2(0, 100) };
var offset = new Vector2(50, 50);
polygon = new Transform2D(0, offset) * polygon;
GD.Print((Variant)polygon); // prints [(50, 50), (150, 50), (150, 150), (50, 150)]
GD.Print((Variant)polygon); // Prints [(50, 50), (150, 50), (150, 150), (50, 150)]
[/csharp]
[/codeblocks]
</description>
Expand Down
8 changes: 4 additions & 4 deletions doc/classes/Object.xml
Original file line number Diff line number Diff line change
Expand Up @@ -987,12 +987,12 @@
[gdscript]
var node = Node2D.new()
node.set("global_scale", Vector2(8, 2.5))
print(node.global_scale) # Prints (8, 2.5)
print(node.global_scale) # Prints (8.0, 2.5)
[/gdscript]
[csharp]
var node = new Node2D();
node.Set(Node2D.PropertyName.GlobalScale, new Vector2(8, 2.5));
GD.Print(node.GlobalScale); // Prints Vector2(8, 2.5)
node.Set(Node2D.PropertyName.GlobalScale, new Vector2(8, 2.5f));
GD.Print(node.GlobalScale); // Prints (8, 2.5)
[/csharp]
[/codeblocks]
[b]Note:[/b] In C#, [param property] must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the [code]PropertyName[/code] class to avoid allocating a new [StringName] on each call.
Expand Down Expand Up @@ -1047,7 +1047,7 @@
var node = Node2D.new()
node.set_indexed("position", Vector2(42, 0))
node.set_indexed("position:y", -10)
print(node.position) # Prints (42, -10)
print(node.position) # Prints (42.0, -10.0)
[/gdscript]
[csharp]
var node = new Node2D();
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/Transform2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
# Rotating the Transform2D in any way preserves its scale.
my_transform = my_transform.rotated(TAU / 2)

print(my_transform.get_scale()) # Prints (2, 4)
print(my_transform.get_scale()) # Prints (2.0, 4.0)
[/gdscript]
[csharp]
var myTransform = new Transform2D(
Expand Down
14 changes: 7 additions & 7 deletions doc/classes/Vector2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@
<description>
Creates a unit [Vector2] rotated to the given [param angle] in radians. This is equivalent to doing [code]Vector2(cos(angle), sin(angle))[/code] or [code]Vector2.RIGHT.rotated(angle)[/code].
[codeblock]
print(Vector2.from_angle(0)) # Prints (1, 0).
print(Vector2(1, 0).angle()) # Prints 0, which is the angle used above.
print(Vector2.from_angle(PI / 2)) # Prints (0, 1).
print(Vector2.from_angle(0)) # Prints (1.0, 0.0).
print(Vector2(1, 0).angle()) # Prints 0.0, which is the angle used above.
print(Vector2.from_angle(PI / 2)) # Prints (0.0, 1.0).
[/codeblock]
</description>
</method>
Expand Down Expand Up @@ -477,7 +477,7 @@
<description>
Multiplies each component of the [Vector2] by the components of the given [Vector2].
[codeblock]
print(Vector2(10, 20) * Vector2(3, 4)) # Prints "(30, 80)"
print(Vector2(10, 20) * Vector2(3, 4)) # Prints (30.0, 80.0)
[/codeblock]
</description>
</operator>
Expand All @@ -501,7 +501,7 @@
<description>
Adds each component of the [Vector2] by the components of the given [Vector2].
[codeblock]
print(Vector2(10, 20) + Vector2(3, 4)) # Prints "(13, 24)"
print(Vector2(10, 20) + Vector2(3, 4)) # Prints (13.0, 24.0)
[/codeblock]
</description>
</operator>
Expand All @@ -511,7 +511,7 @@
<description>
Subtracts each component of the [Vector2] by the components of the given [Vector2].
[codeblock]
print(Vector2(10, 20) - Vector2(3, 4)) # Prints "(7, 16)"
print(Vector2(10, 20) - Vector2(3, 4)) # Prints (7.0, 16.0)
[/codeblock]
</description>
</operator>
Expand All @@ -521,7 +521,7 @@
<description>
Divides each component of the [Vector2] by the components of the given [Vector2].
[codeblock]
print(Vector2(10, 20) / Vector2(2, 5)) # Prints "(5, 4)"
print(Vector2(10, 20) / Vector2(2, 5)) # Prints (5.0, 4.0)
[/codeblock]
</description>
</operator>
Expand Down
16 changes: 8 additions & 8 deletions doc/classes/Vector2i.xml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
<description>
Gets the remainder of each component of the [Vector2i] with the components of the given [Vector2i]. This operation uses truncated division, which is often not desired as it does not work well with negative numbers. Consider using [method @GlobalScope.posmod] instead if you want to handle negative numbers.
[codeblock]
print(Vector2i(10, -20) % Vector2i(7, 8)) # Prints "(3, -4)"
print(Vector2i(10, -20) % Vector2i(7, 8)) # Prints (3, -4)
[/codeblock]
</description>
</operator>
Expand All @@ -225,7 +225,7 @@
<description>
Gets the remainder of each component of the [Vector2i] with the given [int]. This operation uses truncated division, which is often not desired as it does not work well with negative numbers. Consider using [method @GlobalScope.posmod] instead if you want to handle negative numbers.
[codeblock]
print(Vector2i(10, -20) % 7) # Prints "(3, -6)"
print(Vector2i(10, -20) % 7) # Prints (3, -6)
[/codeblock]
</description>
</operator>
Expand All @@ -235,7 +235,7 @@
<description>
Multiplies each component of the [Vector2i] by the components of the given [Vector2i].
[codeblock]
print(Vector2i(10, 20) * Vector2i(3, 4)) # Prints "(30, 80)"
print(Vector2i(10, 20) * Vector2i(3, 4)) # Prints (30, 80)
[/codeblock]
</description>
</operator>
Expand All @@ -245,7 +245,7 @@
<description>
Multiplies each component of the [Vector2i] by the given [float]. Returns a [Vector2].
[codeblock]
print(Vector2i(10, 15) * 0.9) # Prints "(9, 13.5)"
print(Vector2i(10, 15) * 0.9) # Prints (9.0, 13.5)
[/codeblock]
</description>
</operator>
Expand All @@ -262,7 +262,7 @@
<description>
Adds each component of the [Vector2i] by the components of the given [Vector2i].
[codeblock]
print(Vector2i(10, 20) + Vector2i(3, 4)) # Prints "(13, 24)"
print(Vector2i(10, 20) + Vector2i(3, 4)) # Prints (13, 24)
[/codeblock]
</description>
</operator>
Expand All @@ -272,7 +272,7 @@
<description>
Subtracts each component of the [Vector2i] by the components of the given [Vector2i].
[codeblock]
print(Vector2i(10, 20) - Vector2i(3, 4)) # Prints "(7, 16)"
print(Vector2i(10, 20) - Vector2i(3, 4)) # Prints (7, 16)
[/codeblock]
</description>
</operator>
Expand All @@ -282,7 +282,7 @@
<description>
Divides each component of the [Vector2i] by the components of the given [Vector2i].
[codeblock]
print(Vector2i(10, 20) / Vector2i(2, 5)) # Prints "(5, 4)"
print(Vector2i(10, 20) / Vector2i(2, 5)) # Prints (5, 4)
[/codeblock]
</description>
</operator>
Expand All @@ -292,7 +292,7 @@
<description>
Divides each component of the [Vector2i] by the given [float]. Returns a [Vector2].
[codeblock]
print(Vector2i(10, 20) / 2.9) # Prints "(5, 10)"
print(Vector2i(10, 20) / 2.9) # Prints (5.0, 10.0)
[/codeblock]
</description>
</operator>
Expand Down
8 changes: 4 additions & 4 deletions doc/classes/Vector3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@
<description>
Multiplies each component of the [Vector3] by the components of the given [Vector3].
[codeblock]
print(Vector3(10, 20, 30) * Vector3(3, 4, 5)) # Prints "(30, 80, 150)"
print(Vector3(10, 20, 30) * Vector3(3, 4, 5)) # Prints (30.0, 80.0, 150.0)
[/codeblock]
</description>
</operator>
Expand All @@ -542,7 +542,7 @@
<description>
Adds each component of the [Vector3] by the components of the given [Vector3].
[codeblock]
print(Vector3(10, 20, 30) + Vector3(3, 4, 5)) # Prints "(13, 24, 35)"
print(Vector3(10, 20, 30) + Vector3(3, 4, 5)) # Prints (13.0, 24.0, 35.0)
[/codeblock]
</description>
</operator>
Expand All @@ -552,7 +552,7 @@
<description>
Subtracts each component of the [Vector3] by the components of the given [Vector3].
[codeblock]
print(Vector3(10, 20, 30) - Vector3(3, 4, 5)) # Prints "(7, 16, 25)"
print(Vector3(10, 20, 30) - Vector3(3, 4, 5)) # Prints (7.0, 16.0, 25.0)
[/codeblock]
</description>
</operator>
Expand All @@ -562,7 +562,7 @@
<description>
Divides each component of the [Vector3] by the components of the given [Vector3].
[codeblock]
print(Vector3(10, 20, 30) / Vector3(2, 5, 3)) # Prints "(5, 4, 10)"
print(Vector3(10, 20, 30) / Vector3(2, 5, 3)) # Prints (5.0, 4.0, 10.0)
[/codeblock]
</description>
</operator>
Expand Down
Loading

0 comments on commit 61f2001

Please sign in to comment.