Improve the Object, Reference and Resource class documentations

This commit is contained in:
Hugo Locurcio 2020-07-27 09:59:02 +02:00
parent 1ab0644532
commit 4275e6aad5
4 changed files with 9 additions and 5 deletions

View File

@ -17,8 +17,10 @@
[/codeblock] [/codeblock]
The [code]in[/code] operator will evaluate to [code]true[/code] as long as the key exists, even if the value is [code]null[/code]. The [code]in[/code] operator will evaluate to [code]true[/code] as long as the key exists, even if the value is [code]null[/code].
Objects also receive notifications. Notifications are a simple way to notify the object about different events, so they can all be handled together. See [method _notification]. Objects also receive notifications. Notifications are a simple way to notify the object about different events, so they can all be handled together. See [method _notification].
[b]Note:[/b] Unlike references to a [Reference], references to an Object stored in a variable can become invalid without warning. Therefore, it's recommended to use [Reference] for data classes instead of [Object].
</description> </description>
<tutorials> <tutorials>
<link title="When and how to avoid using nodes for everything">https://docs.godotengine.org/en/latest/getting_started/workflow/best_practices/node_alternatives.html</link>
</tutorials> </tutorials>
<methods> <methods>
<method name="_get" qualifiers="virtual"> <method name="_get" qualifiers="virtual">
@ -518,7 +520,7 @@
One-shot connections disconnect themselves after emission. One-shot connections disconnect themselves after emission.
</constant> </constant>
<constant name="CONNECT_REFERENCE_COUNTED" value="8" enum="ConnectFlags"> <constant name="CONNECT_REFERENCE_COUNTED" value="8" enum="ConnectFlags">
Connect a signal as reference counted. This means that a given signal can be connected several times to the same target, and will only be fully disconnected once no references are left. Connect a signal as reference-counted. This means that a given signal can be connected several times to the same target, and will only be fully disconnected once no references are left.
</constant> </constant>
</constants> </constants>
</class> </class>

View File

@ -5,10 +5,11 @@
</brief_description> </brief_description>
<description> <description>
Base class for any object that keeps a reference count. [Resource] and many other helper objects inherit this class. Base class for any object that keeps a reference count. [Resource] and many other helper objects inherit this class.
References keep an internal reference counter so that they are automatically released when no longer in use, and only then. References therefore do not need to be freed manually with [method Object.free]. Unlike [Object]s, References keep an internal reference counter so that they are automatically released when no longer in use, and only then. References therefore do not need to be freed manually with [method Object.free].
In the vast majority of use cases, instantiating and using [Reference]-derived types is all you need to do. The methods provided in this class are only for advanced users, and can cause issues if misused. In the vast majority of use cases, instantiating and using [Reference]-derived types is all you need to do. The methods provided in this class are only for advanced users, and can cause issues if misused.
</description> </description>
<tutorials> <tutorials>
<link title="When and how to avoid using nodes for everything">https://docs.godotengine.org/en/latest/getting_started/workflow/best_practices/node_alternatives.html</link>
</tutorials> </tutorials>
<methods> <methods>
<method name="init_ref"> <method name="init_ref">

View File

@ -4,10 +4,11 @@
Base class for all resources. Base class for all resources.
</brief_description> </brief_description>
<description> <description>
Resource is the base class for all Godot-specific resource types, serving primarily as data containers. They are reference counted and freed when no longer in use. They are also cached once loaded from disk, so that any further attempts to load a resource from a given path will return the same reference (all this in contrast to a [Node], which is not reference counted and can be instanced from disk as many times as desired). Resources can be saved externally on disk or bundled into another object, such as a [Node] or another resource. Resource is the base class for all Godot-specific resource types, serving primarily as data containers. Unlike [Object]s, they are reference-counted and freed when no longer in use. They are also cached once loaded from disk, so that any further attempts to load a resource from a given path will return the same reference (all this in contrast to a [Node], which is not reference-counted and can be instanced from disk as many times as desired). Resources can be saved externally on disk or bundled into another object, such as a [Node] or another resource.
</description> </description>
<tutorials> <tutorials>
<link>https://docs.godotengine.org/en/latest/getting_started/step_by_step/resources.html</link> <link title="Resources">https://docs.godotengine.org/en/latest/getting_started/step_by_step/resources.html</link>
<link title="When and how to avoid using nodes for everything">https://docs.godotengine.org/en/latest/getting_started/workflow/best_practices/node_alternatives.html</link>
</tutorials> </tutorials>
<methods> <methods>
<method name="_setup_local_to_scene" qualifiers="virtual"> <method name="_setup_local_to_scene" qualifiers="virtual">

View File

@ -4,7 +4,7 @@
Built-in string class. Built-in string class.
</brief_description> </brief_description>
<description> <description>
This is the built-in string class (and the one used by GDScript). It supports Unicode and provides all necessary means for string handling. Strings are reference counted and use a copy-on-write approach, so passing them around is cheap in resources. This is the built-in string class (and the one used by GDScript). It supports Unicode and provides all necessary means for string handling. Strings are reference-counted and use a copy-on-write approach, so passing them around is cheap in resources.
</description> </description>
<tutorials> <tutorials>
<link>https://docs.godotengine.org/en/latest/getting_started/scripting/gdscript/gdscript_format_string.html</link> <link>https://docs.godotengine.org/en/latest/getting_started/scripting/gdscript/gdscript_format_string.html</link>