Skip to content

Commit

Permalink
Standardize all "Prints" comments in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mickeon committed Nov 30, 2024
1 parent 893bbdf commit 1a67266
Show file tree
Hide file tree
Showing 24 changed files with 144 additions and 137 deletions.
58 changes: 29 additions & 29 deletions doc/classes/@GlobalScope.xml
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@
Returns a human-readable name for the given [enum Error] code.
[codeblock]
print(OK) # Prints 0
print(error_string(OK)) # Prints OK
print(error_string(ERR_BUSY)) # Prints Busy
print(error_string(ERR_OUT_OF_MEMORY)) # Prints Out of memory
print(error_string(OK)) # Prints "OK"
print(error_string(ERR_BUSY)) # Prints "Busy"
print(error_string(ERR_OUT_OF_MEMORY)) # Prints "Out of memory"
[/codeblock]
</description>
</method>
Expand Down Expand Up @@ -495,23 +495,23 @@
Returns the [Object] that corresponds to [param instance_id]. All Objects have a unique instance ID. See also [method Object.get_instance_id].
[codeblocks]
[gdscript]
var foo = "bar"
var drink = "water"

func _ready():
var id = get_instance_id()
var inst = instance_from_id(id)
print(inst.foo) # Prints bar
var instance = instance_from_id(id)
print(instance.foo) # Prints "water"
[/gdscript]
[csharp]
public partial class MyNode : Node
{
public string Foo { get; set; } = "bar";
public string Drink { get; set; } = "water";

public override void _Ready()
{
ulong id = GetInstanceId();
var inst = (MyNode)InstanceFromId(Id);
GD.Print(inst.Foo); // Prints bar
var instance = (MyNode)InstanceFromId(Id);
GD.Print(instance.Drink); // Prints "water"
}
}
[/csharp]
Expand Down Expand Up @@ -849,11 +849,11 @@
[codeblocks]
[gdscript]
var a = [1, 2, 3]
print("a", "b", a) # Prints ab[1, 2, 3]
print("a", "b", a) # Prints "ab[1, 2, 3]"
[/gdscript]
[csharp]
var a = new Godot.Collections.Array { 1, 2, 3 };
GD.Print("a", "b", a); // Prints ab[1, 2, 3]
GD.Print("a", "b", a); // Prints "ab[1, 2, 3]"
[/csharp]
[/codeblocks]
[b]Note:[/b] Consider using [method push_error] and [method push_warning] to print error and warning messages instead of [method print] or [method print_rich]. This distinguishes them from print messages used for debugging purposes, while also displaying a stack trace when an error or warning is printed. See also [member Engine.print_to_stdout] and [member ProjectSettings.application/run/disable_stdout].
Expand All @@ -868,10 +868,10 @@
When printing to standard output, the supported subset of BBCode is converted to ANSI escape codes for the terminal emulator to display. Support for ANSI escape codes varies across terminal emulators, especially for italic and strikethrough. In standard output, [code]code[/code] is represented with faint text but without any font change. Unsupported tags are left as-is in standard output.
[codeblocks]
[gdscript skip-lint]
print_rich("[color=green][b]Hello world![/b][/color]") # Prints out "Hello world!" in green with a bold font
print_rich("[color=green][b]Hello world![/b][/color]") # Prints "Hello world!", in green with a bold font.
[/gdscript]
[csharp skip-lint]
GD.PrintRich("[color=green][b]Hello world![/b][/color]"); // Prints out "Hello world!" in green with a bold font
GD.PrintRich("[color=green][b]Hello world![/b][/color]"); // Prints "Hello world!", in green with a bold font.
[/csharp]
[/codeblocks]
[b]Note:[/b] Consider using [method push_error] and [method push_warning] to print error and warning messages instead of [method print] or [method print_rich]. This distinguishes them from print messages used for debugging purposes, while also displaying a stack trace when an error or warning is printed.
Expand Down Expand Up @@ -903,16 +903,16 @@
[b]Note:[/b] The OS terminal is [i]not[/i] the same as the editor's Output dock. The output sent to the OS terminal can be seen when running Godot from a terminal. On Windows, this requires using the [code]console.exe[/code] executable.
[codeblocks]
[gdscript]
# Prints "ABC" to terminal.
printraw("A")
printraw("B")
printraw("C")
# Prints ABC to terminal
[/gdscript]
[csharp]
// Prints "ABC" to terminal.
GD.PrintRaw("A");
GD.PrintRaw("B");
GD.PrintRaw("C");
// Prints ABC to terminal
[/csharp]
[/codeblocks]
</description>
Expand All @@ -922,10 +922,10 @@
Prints one or more arguments to the console with a space between each argument.
[codeblocks]
[gdscript]
prints("A", "B", "C") # Prints A B C
prints("A", "B", "C") # Prints "A B C"
[/gdscript]
[csharp]
GD.PrintS("A", "B", "C"); // Prints A B C
GD.PrintS("A", "B", "C"); // Prints "A B C"
[/csharp]
[/codeblocks]
</description>
Expand All @@ -935,10 +935,10 @@
Prints one or more arguments to the console with a tab between each argument.
[codeblocks]
[gdscript]
printt("A", "B", "C") # Prints A B C
printt("A", "B", "C") # Prints "A B C"
[/gdscript]
[csharp]
GD.PrintT("A", "B", "C"); // Prints A B C
GD.PrintT("A", "B", "C"); // Prints "A B C"
[/csharp]
[/codeblocks]
</description>
Expand All @@ -948,10 +948,10 @@
Pushes an error message to Godot's built-in debugger and to the OS terminal.
[codeblocks]
[gdscript]
push_error("test error") # Prints "test error" to debugger and terminal as error call
push_error("test error") # Prints "test error" to debugger and terminal as an error.
[/gdscript]
[csharp]
GD.PushError("test error"); // Prints "test error" to debugger and terminal as error call
GD.PushError("test error"); // Prints "test error" to debugger and terminal as an error.
[/csharp]
[/codeblocks]
[b]Note:[/b] This function does not pause project execution. To print an error message and pause project execution in debug builds, use [code]assert(false, "test error")[/code] instead.
Expand All @@ -962,10 +962,10 @@
Pushes a warning message to Godot's built-in debugger and to the OS terminal.
[codeblocks]
[gdscript]
push_warning("test warning") # Prints "test warning" to debugger and terminal as warning call
push_warning("test warning") # Prints "test warning" to debugger and terminal as a warning.
[/gdscript]
[csharp]
GD.PushWarning("test warning"); // Prints "test warning" to debugger and terminal as warning call
GD.PushWarning("test warning"); // Prints "test warning" to debugger and terminal as a warning.
[/csharp]
[/codeblocks]
</description>
Expand Down Expand Up @@ -1403,9 +1403,9 @@
<description>
Returns a human-readable name of the given [param type], using the [enum Variant.Type] values.
[codeblock]
print(TYPE_INT) # Prints 2.
print(type_string(TYPE_INT)) # Prints "int".
print(type_string(TYPE_STRING)) # Prints "String".
print(TYPE_INT) # Prints 2
print(type_string(TYPE_INT)) # Prints "int"
print(type_string(TYPE_STRING)) # Prints "String"
[/codeblock]
See also [method typeof].
</description>
Expand All @@ -1419,10 +1419,10 @@
var json = JSON.new()
json.parse('["a", "b", "c"]')
var result = json.get_data()
if typeof(result) == TYPE_ARRAY:
print(result[0]) # Prints a
if result is Array:
print(result[0]) # Prints "a"
else:
print("Unexpected result")
print("Unexpected result!")
[/codeblock]
See also [method type_string].
</description>
Expand Down
8 changes: 4 additions & 4 deletions doc/classes/AStarGrid2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
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();
astarGrid.Region = new Rect2I(0, 0, 32, 32);
astarGrid.CellSize = new Vector2I(16, 16);
astarGrid.Update();
GD.Print(astarGrid.GetIdPath(Vector2I.Zero, new Vector2I(3, 4))); // prints (0, 0), (1, 1), (2, 2), (3, 3), (3, 4)
GD.Print(astarGrid.GetPointPath(Vector2I.Zero, new Vector2I(3, 4))); // prints (0, 0), (16, 16), (32, 32), (48, 48), (48, 64)
GD.Print(astarGrid.GetIdPath(Vector2I.Zero, new Vector2I(3, 4))); // Prints [(0, 0), (1, 1), (2, 2), (3, 3), (3, 4)]
GD.Print(astarGrid.GetPointPath(Vector2I.Zero, new Vector2I(3, 4))); // Prints [(0, 0), (16, 16), (32, 32), (48, 48), (48, 64)]
[/csharp]
[/codeblocks]
To remove a point from the pathfinding grid, it must be set as "solid" with [method set_point_solid].
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/Array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@
return number % 2 == 0

func _ready():
print([1, 3, 4, 7].find_custom(is_even.bind())) # prints 2
print([1, 3, 4, 7].find_custom(is_even.bind())) # Prints 2
[/gdscript]
[/codeblocks]
</description>
Expand Down Expand Up @@ -640,7 +640,7 @@
var arr = [Vector2(5, 0), Vector2(3, 4), Vector2(1, 2)]

var longest_vec = arr.reduce(func(max, vec): return vec if is_length_greater(vec, max) else max)
print(longest_vec) # Prints Vector2(3, 4).
print(longest_vec) # Prints (3, 4)

func is_length_greater(a, b):
return a.length() &gt; b.length()
Expand Down
8 changes: 4 additions & 4 deletions doc/classes/Callable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

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("hello", "world") # Prints "hello world "
callable.call(Vector2.UP, 42, callable) # Prints "(0, -1) 42 Node(node.gd)::print_args"
callable.call("invalid") # Invalid call, should have at least 2 arguments.
[/gdscript]
[csharp]
Expand All @@ -28,7 +28,7 @@
// Invalid calls fail silently.
Callable callable = new Callable(this, MethodName.PrintArgs);
callable.Call("hello", "world"); // Default parameter values are not supported, should have 3 arguments.
callable.Call(Vector2.Up, 42, callable); // Prints "(0, -1) 42 Node(Node.cs)::PrintArgs".
callable.Call(Vector2.Up, 42, callable); // Prints "(0, -1) 42 Node(Node.cs)::PrintArgs"
callable.Call("invalid"); // Invalid call, should have 3 arguments.
}
[/csharp]
Expand All @@ -39,7 +39,7 @@
var my_lambda = func (message):
print(message)

# Prints Hello everyone!
# Prints "Hello everyone!"
my_lambda.call("Hello everyone!")

# Prints "Attack!", when the button_pressed signal is emitted.
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, 50), (150, 50), (150, 150), (50, 150)]
[/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
2 changes: 1 addition & 1 deletion doc/classes/JSON.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
if error == OK:
var data_received = json.data
if typeof(data_received) == TYPE_ARRAY:
print(data_received) # Prints array
print(data_received) # Prints the array.
else:
print("Unexpected data")
else:
Expand Down
8 changes: 5 additions & 3 deletions doc/classes/JavaScriptObject.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

func _init():
var buf = JavaScriptBridge.create_object("ArrayBuffer", 10) # new ArrayBuffer(10)
print(buf) # prints [JavaScriptObject:OBJECT_ID]
print(buf) # Prints [JavaScriptObject:OBJECT_ID]
var uint8arr = JavaScriptBridge.create_object("Uint8Array", buf) # new Uint8Array(buf)
uint8arr[1] = 255
prints(uint8arr[1], uint8arr.byteLength) # prints 255 10
console.log(uint8arr) # prints in browser console "Uint8Array(10) [ 0, 255, 0, 0, 0, 0, 0, 0, 0, 0 ]"
prints(uint8arr[1], uint8arr.byteLength) # Prints "255 10"

# Prints "Uint8Array(10) [ 0, 255, 0, 0, 0, 0, 0, 0, 0, 0 ]" in the browser's console.
console.log(uint8arr)

# Equivalent of JavaScriptBridge: Array.from(uint8arr).forEach(myCallback)
JavaScriptBridge.get_interface("Array").from(uint8arr).forEach(_my_js_callback)
Expand Down
26 changes: 13 additions & 13 deletions doc/classes/NodePath.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

// propertyPath points to the "position" in the "x" axis of this node.
NodePath propertyPath = nodePath.GetAsPropertyPath();
GD.Print(propertyPath); // Prints ":position:x".
GD.Print(propertyPath); // Prints ":position:x"
[/csharp]
[/codeblocks]
</description>
Expand All @@ -118,11 +118,11 @@
[codeblocks]
[gdscript]
var node_path = ^"Sprite2D:texture:resource_name"
print(node_path.get_concatenated_subnames()) # Prints "texture:resource_name".
print(node_path.get_concatenated_subnames()) # Prints "texture:resource_name"
[/gdscript]
[csharp]
var nodePath = new NodePath("Sprite2D:texture:resource_name");
GD.Print(nodePath.GetConcatenatedSubnames()); // Prints "texture:resource_name".
GD.Print(nodePath.GetConcatenatedSubnames()); // Prints "texture:resource_name"
[/csharp]
[/codeblocks]
</description>
Expand All @@ -135,15 +135,15 @@
[codeblocks]
[gdscript]
var sprite_path = NodePath("../RigidBody2D/Sprite2D")
print(sprite_path.get_name(0)) # Prints "..".
print(sprite_path.get_name(1)) # Prints "RigidBody2D".
print(sprite_path.get_name(2)) # Prints "Sprite".
print(sprite_path.get_name(0)) # Prints ".."
print(sprite_path.get_name(1)) # Prints "RigidBody2D"
print(sprite_path.get_name(2)) # Prints "Sprite"
[/gdscript]
[csharp]
var spritePath = new NodePath("../RigidBody2D/Sprite2D");
GD.Print(spritePath.GetName(0)); // Prints "..".
GD.Print(spritePath.GetName(1)); // Prints "PathFollow2D".
GD.Print(spritePath.GetName(2)); // Prints "Sprite".
GD.Print(spritePath.GetName(0)); // Prints ".."
GD.Print(spritePath.GetName(1)); // Prints "PathFollow2D"
GD.Print(spritePath.GetName(2)); // Prints "Sprite"
[/csharp]
[/codeblocks]
</description>
Expand All @@ -163,13 +163,13 @@
[codeblocks]
[gdscript]
var path_to_name = NodePath("Sprite2D:texture:resource_name")
print(path_to_name.get_subname(0)) # Prints "texture".
print(path_to_name.get_subname(1)) # Prints "resource_name".
print(path_to_name.get_subname(0)) # Prints "texture"
print(path_to_name.get_subname(1)) # Prints "resource_name"
[/gdscript]
[csharp]
var pathToName = new NodePath("Sprite2D:texture:resource_name");
GD.Print(pathToName.GetSubname(0)); // Prints "texture".
GD.Print(pathToName.GetSubname(1)); // Prints "resource_name".
GD.Print(pathToName.GetSubname(0)); // Prints "texture"
GD.Print(pathToName.GetSubname(1)); // Prints "resource_name"
[/csharp]
[/codeblocks]
</description>
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/Object.xml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
func _ready():
var my_range = MyRange.new(2, 5)
for x in my_range:
print(x) # Prints 2, 3, 4.
print(x) # Prints 2, 3, and 4.
[/codeblock]
[b]Note:[/b] Alternatively, you can ignore [param iter] and use the object's state instead, see [url=$DOCS_URL/tutorials/scripting/gdscript/gdscript_advanced.html#custom-iterators]online docs[/url] for an example. Note that in this case you will not be able to reuse the same iterator instance in nested loops. Also, make sure you reset the iterator state in this method if you want to reuse the same instance multiple times.
</description>
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/PackedByteArray.xml
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,11 @@
[codeblocks]
[gdscript]
var array = PackedByteArray([11, 46, 255])
print(array.hex_encode()) # Prints: 0b2eff
print(array.hex_encode()) # Prints "0b2eff"
[/gdscript]
[csharp]
var array = new byte[] {11, 46, 255};
GD.Print(array.HexEncode()); // Prints: 0b2eff
GD.Print(array.HexEncode()); // Prints "0b2eff"
[/csharp]
[/codeblocks]
</description>
Expand Down
11 changes: 6 additions & 5 deletions doc/classes/PackedDataContainer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
var container = load("packed_data.res")
for key in container:
prints(key, container[key])

# Prints:
# key value
# lock (0, 0)
# another_key 123
[/codeblock]
Prints:
[codeblock lang=text]
key value
lock (0, 0)
another_key 123
[/codeblock]
Nested containers will be packed recursively. While iterating, they will be returned as [PackedDataContainerRef].
</description>
Expand Down
Loading

0 comments on commit 1a67266

Please sign in to comment.