浏览代码

Merge pull request #99185 from Mickeon/documentation-damn-it

Fix `format` description being different between String and StringName
Thaddeus Crews 10 月之前
父节点
当前提交
0b2a75b995
共有 2 个文件被更改,包括 9 次插入3 次删除
  1. 2 2
      doc/classes/String.xml
  2. 7 1
      doc/classes/StringName.xml

+ 2 - 2
doc/classes/String.xml

@@ -248,7 +248,7 @@
 			<param index="1" name="placeholder" type="String" default="&quot;{_}&quot;" />
 			<param index="1" name="placeholder" type="String" default="&quot;{_}&quot;" />
 			<description>
 			<description>
 				Formats the string by replacing all occurrences of [param placeholder] with the elements of [param values].
 				Formats the string by replacing all occurrences of [param placeholder] with the elements of [param values].
-				[param values] can be a [Dictionary], an [Array] or an [Object]. Any underscores in [param placeholder] will be replaced with the corresponding keys in advance. Array elements use their index as keys.
+				[param values] can be a [Dictionary], an [Array], or an [Object]. Any underscores in [param placeholder] will be replaced with the corresponding keys in advance. Array elements use their index as keys.
 				[codeblock]
 				[codeblock]
 				# Prints "Waiting for Godot is a play by Samuel Beckett, and Godot Engine is named after it."
 				# Prints "Waiting for Godot is a play by Samuel Beckett, and Godot Engine is named after it."
 				var use_array_values = "Waiting for {0} is a play by {1}, and {0} Engine is named after it."
 				var use_array_values = "Waiting for {0} is a play by {1}, and {0} Engine is named after it."
@@ -265,7 +265,7 @@
 				[/codeblock]
 				[/codeblock]
 				When passing an [Object], the property names from [method Object.get_property_list] are used as keys.
 				When passing an [Object], the property names from [method Object.get_property_list] are used as keys.
 				[codeblock]
 				[codeblock]
-				# Prints: Visible true, position (0, 0).
+				# Prints "Visible true, position (0, 0)"
 				var node = Node2D.new()
 				var node = Node2D.new()
 				print("Visible {visible}, position {position}".format(node))
 				print("Visible {visible}, position {position}".format(node))
 				[/codeblock]
 				[/codeblock]

+ 7 - 1
doc/classes/StringName.xml

@@ -231,7 +231,7 @@
 			<param index="1" name="placeholder" type="String" default="&quot;{_}&quot;" />
 			<param index="1" name="placeholder" type="String" default="&quot;{_}&quot;" />
 			<description>
 			<description>
 				Formats the string by replacing all occurrences of [param placeholder] with the elements of [param values].
 				Formats the string by replacing all occurrences of [param placeholder] with the elements of [param values].
-				[param values] can be a [Dictionary] or an [Array]. Any underscores in [param placeholder] will be replaced with the corresponding keys in advance. Array elements use their index as keys.
+				[param values] can be a [Dictionary], an [Array], or an [Object]. Any underscores in [param placeholder] will be replaced with the corresponding keys in advance. Array elements use their index as keys.
 				[codeblock]
 				[codeblock]
 				# Prints "Waiting for Godot is a play by Samuel Beckett, and Godot Engine is named after it."
 				# Prints "Waiting for Godot is a play by Samuel Beckett, and Godot Engine is named after it."
 				var use_array_values = "Waiting for {0} is a play by {1}, and {0} Engine is named after it."
 				var use_array_values = "Waiting for {0} is a play by {1}, and {0} Engine is named after it."
@@ -246,6 +246,12 @@
 				print("User {} is {}.".format([42, "Godot"], "{}"))
 				print("User {} is {}.".format([42, "Godot"], "{}"))
 				print("User {id} is {name}.".format([["id", 42], ["name", "Godot"]]))
 				print("User {id} is {name}.".format([["id", 42], ["name", "Godot"]]))
 				[/codeblock]
 				[/codeblock]
+				When passing an [Object], the property names from [method Object.get_property_list] are used as keys.
+				[codeblock]
+				# Prints "Visible true, position (0, 0)"
+				var node = Node2D.new()
+				print("Visible {visible}, position {position}".format(node))
+				[/codeblock]
 				See also the [url=$DOCS_URL/tutorials/scripting/gdscript/gdscript_format_string.html]GDScript format string[/url] tutorial.
 				See also the [url=$DOCS_URL/tutorials/scripting/gdscript/gdscript_format_string.html]GDScript format string[/url] tutorial.
 				[b]Note:[/b] Each replacement is done sequentially for each element of [param values], [b]not[/b] all at once. This means that if any element is inserted and it contains another placeholder, it may be changed by the next replacement. While this can be very useful, it often causes unexpected results. If not necessary, make sure [param values]'s elements do not contain placeholders.
 				[b]Note:[/b] Each replacement is done sequentially for each element of [param values], [b]not[/b] all at once. This means that if any element is inserted and it contains another placeholder, it may be changed by the next replacement. While this can be very useful, it often causes unexpected results. If not necessary, make sure [param values]'s elements do not contain placeholders.
 				[codeblock]
 				[codeblock]