Skip to content

Commit efa1443

Browse files
committed
Merge pull request godotengine#99876 from Mickeon/documentation-prints-obsession
Standardize all "Prints" comments in documentation
2 parents a9b6b3d + ca4b29b commit efa1443

19 files changed

+104
-97
lines changed

doc/classes/@GlobalScope.xml

+29-29
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,9 @@
388388
Returns a human-readable name for the given [enum Error] code.
389389
[codeblock]
390390
print(OK) # Prints 0
391-
print(error_string(OK)) # Prints OK
392-
print(error_string(ERR_BUSY)) # Prints Busy
393-
print(error_string(ERR_OUT_OF_MEMORY)) # Prints Out of memory
391+
print(error_string(OK)) # Prints "OK"
392+
print(error_string(ERR_BUSY)) # Prints "Busy"
393+
print(error_string(ERR_OUT_OF_MEMORY)) # Prints "Out of memory"
394394
[/codeblock]
395395
</description>
396396
</method>
@@ -495,23 +495,23 @@
495495
Returns the [Object] that corresponds to [param instance_id]. All Objects have a unique instance ID. See also [method Object.get_instance_id].
496496
[codeblocks]
497497
[gdscript]
498-
var foo = "bar"
498+
var drink = "water"
499499

500500
func _ready():
501501
var id = get_instance_id()
502-
var inst = instance_from_id(id)
503-
print(inst.foo) # Prints bar
502+
var instance = instance_from_id(id)
503+
print(instance.foo) # Prints "water"
504504
[/gdscript]
505505
[csharp]
506506
public partial class MyNode : Node
507507
{
508-
public string Foo { get; set; } = "bar";
508+
public string Drink { get; set; } = "water";
509509

510510
public override void _Ready()
511511
{
512512
ulong id = GetInstanceId();
513-
var inst = (MyNode)InstanceFromId(Id);
514-
GD.Print(inst.Foo); // Prints bar
513+
var instance = (MyNode)InstanceFromId(Id);
514+
GD.Print(instance.Drink); // Prints "water"
515515
}
516516
}
517517
[/csharp]
@@ -850,11 +850,11 @@
850850
[codeblocks]
851851
[gdscript]
852852
var a = [1, 2, 3]
853-
print("a", "b", a) # Prints ab[1, 2, 3]
853+
print("a", "b", a) # Prints "ab[1, 2, 3]"
854854
[/gdscript]
855855
[csharp]
856856
Godot.Collections.Array a = [1, 2, 3];
857-
GD.Print("a", "b", a); // Prints ab[1, 2, 3]
857+
GD.Print("a", "b", a); // Prints "ab[1, 2, 3]"
858858
[/csharp]
859859
[/codeblocks]
860860
[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].
@@ -869,10 +869,10 @@
869869
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.
870870
[codeblocks]
871871
[gdscript skip-lint]
872-
print_rich("[color=green][b]Hello world![/b][/color]") # Prints out "Hello world!" in green with a bold font
872+
print_rich("[color=green][b]Hello world![/b][/color]") # Prints "Hello world!", in green with a bold font.
873873
[/gdscript]
874874
[csharp skip-lint]
875-
GD.PrintRich("[color=green][b]Hello world![/b][/color]"); // Prints out "Hello world!" in green with a bold font
875+
GD.PrintRich("[color=green][b]Hello world![/b][/color]"); // Prints "Hello world!", in green with a bold font.
876876
[/csharp]
877877
[/codeblocks]
878878
[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.
@@ -907,16 +907,16 @@
907907
[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.
908908
[codeblocks]
909909
[gdscript]
910+
# Prints "ABC" to terminal.
910911
printraw("A")
911912
printraw("B")
912913
printraw("C")
913-
# Prints ABC to terminal
914914
[/gdscript]
915915
[csharp]
916+
// Prints "ABC" to terminal.
916917
GD.PrintRaw("A");
917918
GD.PrintRaw("B");
918919
GD.PrintRaw("C");
919-
// Prints ABC to terminal
920920
[/csharp]
921921
[/codeblocks]
922922
</description>
@@ -927,10 +927,10 @@
927927
Prints one or more arguments to the console with a space between each argument.
928928
[codeblocks]
929929
[gdscript]
930-
prints("A", "B", "C") # Prints A B C
930+
prints("A", "B", "C") # Prints "A B C"
931931
[/gdscript]
932932
[csharp]
933-
GD.PrintS("A", "B", "C"); // Prints A B C
933+
GD.PrintS("A", "B", "C"); // Prints "A B C"
934934
[/csharp]
935935
[/codeblocks]
936936
</description>
@@ -941,10 +941,10 @@
941941
Prints one or more arguments to the console with a tab between each argument.
942942
[codeblocks]
943943
[gdscript]
944-
printt("A", "B", "C") # Prints A B C
944+
printt("A", "B", "C") # Prints "A B C"
945945
[/gdscript]
946946
[csharp]
947-
GD.PrintT("A", "B", "C"); // Prints A B C
947+
GD.PrintT("A", "B", "C"); // Prints "A B C"
948948
[/csharp]
949949
[/codeblocks]
950950
</description>
@@ -955,10 +955,10 @@
955955
Pushes an error message to Godot's built-in debugger and to the OS terminal.
956956
[codeblocks]
957957
[gdscript]
958-
push_error("test error") # Prints "test error" to debugger and terminal as error call
958+
push_error("test error") # Prints "test error" to debugger and terminal as an error.
959959
[/gdscript]
960960
[csharp]
961-
GD.PushError("test error"); // Prints "test error" to debugger and terminal as error call
961+
GD.PushError("test error"); // Prints "test error" to debugger and terminal as an error.
962962
[/csharp]
963963
[/codeblocks]
964964
[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.
@@ -970,10 +970,10 @@
970970
Pushes a warning message to Godot's built-in debugger and to the OS terminal.
971971
[codeblocks]
972972
[gdscript]
973-
push_warning("test warning") # Prints "test warning" to debugger and terminal as warning call
973+
push_warning("test warning") # Prints "test warning" to debugger and terminal as a warning.
974974
[/gdscript]
975975
[csharp]
976-
GD.PushWarning("test warning"); // Prints "test warning" to debugger and terminal as warning call
976+
GD.PushWarning("test warning"); // Prints "test warning" to debugger and terminal as a warning.
977977
[/csharp]
978978
[/codeblocks]
979979
</description>
@@ -1413,9 +1413,9 @@
14131413
<description>
14141414
Returns a human-readable name of the given [param type], using the [enum Variant.Type] values.
14151415
[codeblock]
1416-
print(TYPE_INT) # Prints 2.
1417-
print(type_string(TYPE_INT)) # Prints "int".
1418-
print(type_string(TYPE_STRING)) # Prints "String".
1416+
print(TYPE_INT) # Prints 2
1417+
print(type_string(TYPE_INT)) # Prints "int"
1418+
print(type_string(TYPE_STRING)) # Prints "String"
14191419
[/codeblock]
14201420
See also [method typeof].
14211421
</description>
@@ -1429,10 +1429,10 @@
14291429
var json = JSON.new()
14301430
json.parse('["a", "b", "c"]')
14311431
var result = json.get_data()
1432-
if typeof(result) == TYPE_ARRAY:
1433-
print(result[0]) # Prints a
1432+
if result is Array:
1433+
print(result[0]) # Prints "a"
14341434
else:
1435-
print("Unexpected result")
1435+
print("Unexpected result!")
14361436
[/codeblock]
14371437
See also [method type_string].
14381438
</description>

doc/classes/AStarGrid2D.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
astarGrid.Region = new Rect2I(0, 0, 32, 32);
2121
astarGrid.CellSize = new Vector2I(16, 16);
2222
astarGrid.Update();
23-
GD.Print(astarGrid.GetIdPath(Vector2I.Zero, new Vector2I(3, 4))); // prints (0, 0), (1, 1), (2, 2), (3, 3), (3, 4)
24-
GD.Print(astarGrid.GetPointPath(Vector2I.Zero, new Vector2I(3, 4))); // prints (0, 0), (16, 16), (32, 32), (48, 48), (48, 64)
23+
GD.Print(astarGrid.GetIdPath(Vector2I.Zero, new Vector2I(3, 4))); // Prints [(0, 0), (1, 1), (2, 2), (3, 3), (3, 4)]
24+
GD.Print(astarGrid.GetPointPath(Vector2I.Zero, new Vector2I(3, 4))); // Prints [(0, 0), (16, 16), (32, 32), (48, 48), (48, 64)]
2525
[/csharp]
2626
[/codeblocks]
2727
To remove a point from the pathfinding grid, it must be set as "solid" with [method set_point_solid].

doc/classes/Array.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@
410410
return number % 2 == 0
411411

412412
func _ready():
413-
print([1, 3, 4, 7].find_custom(is_even.bind())) # prints 2
413+
print([1, 3, 4, 7].find_custom(is_even.bind())) # Prints 2
414414
[/gdscript]
415415
[/codeblocks]
416416
</description>
@@ -637,10 +637,10 @@
637637
If [method max] is not desirable, this method may also be used to implement a custom comparator:
638638
[codeblock]
639639
func _ready():
640-
var arr = [Vector2(5, 0), Vector2(3, 4), Vector2(1, 2)]
640+
var arr = [Vector2i(5, 0), Vector2i(3, 4), Vector2i(1, 2)]
641641

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

645645
func is_length_greater(a, b):
646646
return a.length() &gt; b.length()
@@ -652,11 +652,11 @@
652652

653653
func _ready():
654654
var arr = [1, 2, 3, 4, 5]
655-
# Increment count if it's even, else leaves count the same.
655+
# If the current element is even, increment count, otherwise leave count the same.
656656
var even_count = arr.reduce(func(count, next): return count + 1 if is_even(next) else count, 0)
657657
print(even_count) # Prints 2
658658
[/codeblock]
659-
See also [method map], [method filter], [method any] and [method all].
659+
See also [method map], [method filter], [method any], and [method all].
660660
</description>
661661
</method>
662662
<method name="remove_at">

doc/classes/Callable.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
func test():
1414
var callable = Callable(self, "print_args")
1515
callable.call("hello", "world") # Prints "hello world ".
16-
callable.call(Vector2.UP, 42, callable) # Prints "(0.0, -1.0) 42 Node(node.gd)::print_args".
16+
callable.call(Vector2.UP, 42, callable) # Prints "(0.0, -1.0) 42 Node(node.gd)::print_args"
1717
callable.call("invalid") # Invalid call, should have at least 2 arguments.
1818
[/gdscript]
1919
[csharp]
@@ -28,7 +28,7 @@
2828
// Invalid calls fail silently.
2929
Callable callable = new Callable(this, MethodName.PrintArgs);
3030
callable.Call("hello", "world"); // Default parameter values are not supported, should have 3 arguments.
31-
callable.Call(Vector2.Up, 42, callable); // Prints "(0, -1) 42 Node(Node.cs)::PrintArgs".
31+
callable.Call(Vector2.Up, 42, callable); // Prints "(0, -1) 42 Node(Node.cs)::PrintArgs"
3232
callable.Call("invalid"); // Invalid call, should have 3 arguments.
3333
}
3434
[/csharp]
@@ -39,7 +39,7 @@
3939
var my_lambda = func (message):
4040
print(message)
4141

42-
# Prints Hello everyone!
42+
# Prints "Hello everyone!"
4343
my_lambda.call("Hello everyone!")
4444

4545
# Prints "Attack!", when the button_pressed signal is emitted.

doc/classes/JSON.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
if error == OK:
1919
var data_received = json.data
2020
if typeof(data_received) == TYPE_ARRAY:
21-
print(data_received) # Prints array
21+
print(data_received) # Prints the array.
2222
else:
2323
print("Unexpected data")
2424
else:

doc/classes/JavaScriptObject.xml

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313

1414
func _init():
1515
var buf = JavaScriptBridge.create_object("ArrayBuffer", 10) # new ArrayBuffer(10)
16-
print(buf) # prints [JavaScriptObject:OBJECT_ID]
16+
print(buf) # Prints [JavaScriptObject:OBJECT_ID]
1717
var uint8arr = JavaScriptBridge.create_object("Uint8Array", buf) # new Uint8Array(buf)
1818
uint8arr[1] = 255
19-
prints(uint8arr[1], uint8arr.byteLength) # prints 255 10
20-
console.log(uint8arr) # prints in browser console "Uint8Array(10) [ 0, 255, 0, 0, 0, 0, 0, 0, 0, 0 ]"
19+
prints(uint8arr[1], uint8arr.byteLength) # Prints "255 10"
20+
21+
# Prints "Uint8Array(10) [ 0, 255, 0, 0, 0, 0, 0, 0, 0, 0 ]" in the browser's console.
22+
console.log(uint8arr)
2123

2224
# Equivalent of JavaScriptBridge: Array.from(uint8arr).forEach(myCallback)
2325
JavaScriptBridge.get_interface("Array").from(uint8arr).forEach(_my_js_callback)

doc/classes/NodePath.xml

+13-13
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100

101101
// propertyPath points to the "position" in the "x" axis of this node.
102102
NodePath propertyPath = nodePath.GetAsPropertyPath();
103-
GD.Print(propertyPath); // Prints ":position:x".
103+
GD.Print(propertyPath); // Prints ":position:x"
104104
[/csharp]
105105
[/codeblocks]
106106
</description>
@@ -118,11 +118,11 @@
118118
[codeblocks]
119119
[gdscript]
120120
var node_path = ^"Sprite2D:texture:resource_name"
121-
print(node_path.get_concatenated_subnames()) # Prints "texture:resource_name".
121+
print(node_path.get_concatenated_subnames()) # Prints "texture:resource_name"
122122
[/gdscript]
123123
[csharp]
124124
var nodePath = new NodePath("Sprite2D:texture:resource_name");
125-
GD.Print(nodePath.GetConcatenatedSubnames()); // Prints "texture:resource_name".
125+
GD.Print(nodePath.GetConcatenatedSubnames()); // Prints "texture:resource_name"
126126
[/csharp]
127127
[/codeblocks]
128128
</description>
@@ -135,15 +135,15 @@
135135
[codeblocks]
136136
[gdscript]
137137
var sprite_path = NodePath("../RigidBody2D/Sprite2D")
138-
print(sprite_path.get_name(0)) # Prints "..".
139-
print(sprite_path.get_name(1)) # Prints "RigidBody2D".
140-
print(sprite_path.get_name(2)) # Prints "Sprite".
138+
print(sprite_path.get_name(0)) # Prints ".."
139+
print(sprite_path.get_name(1)) # Prints "RigidBody2D"
140+
print(sprite_path.get_name(2)) # Prints "Sprite"
141141
[/gdscript]
142142
[csharp]
143143
var spritePath = new NodePath("../RigidBody2D/Sprite2D");
144-
GD.Print(spritePath.GetName(0)); // Prints "..".
145-
GD.Print(spritePath.GetName(1)); // Prints "PathFollow2D".
146-
GD.Print(spritePath.GetName(2)); // Prints "Sprite".
144+
GD.Print(spritePath.GetName(0)); // Prints ".."
145+
GD.Print(spritePath.GetName(1)); // Prints "PathFollow2D"
146+
GD.Print(spritePath.GetName(2)); // Prints "Sprite"
147147
[/csharp]
148148
[/codeblocks]
149149
</description>
@@ -163,13 +163,13 @@
163163
[codeblocks]
164164
[gdscript]
165165
var path_to_name = NodePath("Sprite2D:texture:resource_name")
166-
print(path_to_name.get_subname(0)) # Prints "texture".
167-
print(path_to_name.get_subname(1)) # Prints "resource_name".
166+
print(path_to_name.get_subname(0)) # Prints "texture"
167+
print(path_to_name.get_subname(1)) # Prints "resource_name"
168168
[/gdscript]
169169
[csharp]
170170
var pathToName = new NodePath("Sprite2D:texture:resource_name");
171-
GD.Print(pathToName.GetSubname(0)); // Prints "texture".
172-
GD.Print(pathToName.GetSubname(1)); // Prints "resource_name".
171+
GD.Print(pathToName.GetSubname(0)); // Prints "texture"
172+
GD.Print(pathToName.GetSubname(1)); // Prints "resource_name"
173173
[/csharp]
174174
[/codeblocks]
175175
</description>

doc/classes/PackedByteArray.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,11 @@
366366
[codeblocks]
367367
[gdscript]
368368
var array = PackedByteArray([11, 46, 255])
369-
print(array.hex_encode()) # Prints: 0b2eff
369+
print(array.hex_encode()) # Prints "0b2eff"
370370
[/gdscript]
371371
[csharp]
372372
byte[] array = [11, 46, 255];
373-
GD.Print(array.HexEncode()); // Prints: 0b2eff
373+
GD.Print(array.HexEncode()); // Prints "0b2eff"
374374
[/csharp]
375375
[/codeblocks]
376376
</description>

doc/classes/PackedDataContainer.xml

+6-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
var container = load("packed_data.res")
1717
for key in container:
1818
prints(key, container[key])
19-
20-
# Prints:
21-
# key value
22-
# lock (0, 0)
23-
# another_key 123
19+
[/codeblock]
20+
Prints:
21+
[codeblock lang=text]
22+
key value
23+
lock (0, 0)
24+
another_key 123
2425
[/codeblock]
2526
Nested containers will be packed recursively. While iterating, they will be returned as [PackedDataContainerRef].
2627
</description>

doc/classes/PackedDataContainerRef.xml

+12-11
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,25 @@
77
When packing nested containers using [PackedDataContainer], they are recursively packed into [PackedDataContainerRef] (only applies to [Array] and [Dictionary]). Their data can be retrieved the same way as from [PackedDataContainer].
88
[codeblock]
99
var packed = PackedDataContainer.new()
10-
packed.pack([1, 2, 3, ["abc", "def"], 4, 5, 6])
10+
packed.pack([1, 2, 3, ["nested1", "nested2"], 4, 5, 6])
1111

1212
for element in packed:
1313
if element is PackedDataContainerRef:
1414
for subelement in element:
1515
print("::", subelement)
1616
else:
1717
print(element)
18-
19-
# Prints:
20-
# 1
21-
# 2
22-
# 3
23-
# ::abc
24-
# ::def
25-
# 4
26-
# 5
27-
# 6
18+
[/codeblock]
19+
Prints:
20+
[codeblock lang=text]
21+
1
22+
2
23+
3
24+
::nested1
25+
::nested2
26+
4
27+
5
28+
6
2829
[/codeblock]
2930
</description>
3031
<tutorials>

0 commit comments

Comments
 (0)