Skip to content

Commit

Permalink
Style: Misc docs and comment style and language fixes
Browse files Browse the repository at this point in the history
- Removed empty paragraphs in XML.
- Consistently use bold style for "Example:", on a new line.
- Fix usage of `[code]` when hyperlinks could be used (`[member]`, `[constant]`).
- Fix invalid usage of backticks for inline code in BBCode.
- Fix some American/British English spelling inconsistencies.
- Other minor fixes spotted along the way, including typo fixes with codespell.
- Don't specify `@GlobalScope` for `enum` and `constant`.
  • Loading branch information
akien-mga committed Nov 2, 2022
1 parent 39cece3 commit f7c611a
Show file tree
Hide file tree
Showing 107 changed files with 243 additions and 239 deletions.
2 changes: 1 addition & 1 deletion core/input/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ void Input::parse_mapping(String p_mapping) {
JoyButton output_button = _get_output_button(output);
JoyAxis output_axis = _get_output_axis(output);
ERR_CONTINUE_MSG(output_button == JoyButton::INVALID && output_axis == JoyAxis::INVALID,
vformat("Unrecognised output string \"%s\" in mapping:\n%s", output, p_mapping));
vformat("Unrecognized output string \"%s\" in mapping:\n%s", output, p_mapping));
ERR_CONTINUE_MSG(output_button != JoyButton::INVALID && output_axis != JoyAxis::INVALID,
vformat("Output string \"%s\" matched both button and axis in mapping:\n%s", output, p_mapping));

Expand Down
8 changes: 4 additions & 4 deletions core/math/audio_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "core/math/vector2.h"
#include "core/typedefs.h"

static inline float undenormalise(volatile float f) {
static inline float undenormalize(volatile float f) {
union {
uint32_t i;
float f;
Expand Down Expand Up @@ -101,9 +101,9 @@ struct AudioFrame {
r /= p_sample;
}

_ALWAYS_INLINE_ void undenormalise() {
l = ::undenormalise(l);
r = ::undenormalise(r);
_ALWAYS_INLINE_ void undenormalize() {
l = ::undenormalize(l);
r = ::undenormalize(r);
}

_FORCE_INLINE_ AudioFrame lerp(const AudioFrame &p_b, float p_t) const {
Expand Down
2 changes: 1 addition & 1 deletion core/math/basis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
return;
}
// As we have reached here there are no singularities so we can handle normally.
double s = Math::sqrt((rows[2][1] - rows[1][2]) * (rows[2][1] - rows[1][2]) + (rows[0][2] - rows[2][0]) * (rows[0][2] - rows[2][0]) + (rows[1][0] - rows[0][1]) * (rows[1][0] - rows[0][1])); // Used to normalise.
double s = Math::sqrt((rows[2][1] - rows[1][2]) * (rows[2][1] - rows[1][2]) + (rows[0][2] - rows[2][0]) * (rows[0][2] - rows[2][0]) + (rows[1][0] - rows[0][1]) * (rows[1][0] - rows[0][1])); // Used to normalize.

if (Math::abs(s) < CMP_EPSILON) {
// Prevent divide by zero, should not happen if matrix is orthogonal and should be caught by singularity test above.
Expand Down
14 changes: 9 additions & 5 deletions doc/classes/@GlobalScope.xml
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@
<return type="float" />
<param index="0" name="lin" type="float" />
<description>
Converts from linear energy to decibels (audio). This can be used to implement volume sliders that behave as expected (since volume isn't linear). Example:
Converts from linear energy to decibels (audio). This can be used to implement volume sliders that behave as expected (since volume isn't linear).
[b]Example:[/b]
[codeblock]
# "Slider" refers to a node that inherits Range such as HSlider or VSlider.
# Its range must be configured to go from 0 to 1.
Expand Down Expand Up @@ -841,7 +842,7 @@
<return type="PackedInt64Array" />
<param index="0" name="seed" type="int" />
<description>
Given a [param seed], returns a [PackedInt64Array] of size [code]2[/code], where its first element is the randomised [int] value, and the second element is the same as [param seed]. Passing the same [param seed] consistently returns the same array.
Given a [param seed], returns a [PackedInt64Array] of size [code]2[/code], where its first element is the randomized [int] value, and the second element is the same as [param seed]. Passing the same [param seed] consistently returns the same array.
[b]Note:[/b] "Seed" here refers to the internal state of the pseudo random number generator, currently implemented as a 64 bit integer.
[codeblock]
var a = rand_from_seed(4)
Expand Down Expand Up @@ -2487,7 +2488,8 @@
</constant>
<constant name="OK" value="0" enum="Error">
Methods that return [enum Error] return [constant OK] when no error occurred.
Since [constant OK] has value 0, and all other error constants are positive integers, it can also be used in boolean checks. For example:
Since [constant OK] has value 0, and all other error constants are positive integers, it can also be used in boolean checks.
[b]Example:[/b]
[codeblock]
var error = method_that_returns_error()
if error != OK:
Expand Down Expand Up @@ -2648,7 +2650,8 @@
The property has no hint for the editor.
</constant>
<constant name="PROPERTY_HINT_RANGE" value="1" enum="PropertyHint">
Hints that an [int] or [float] property should be within a range specified via the hint string [code]"min,max"[/code] or [code]"min,max,step"[/code]. The hint string can optionally include [code]"or_greater"[/code] and/or [code]"or_less"[/code] to allow manual input going respectively above the max or below the min values. Example: [code]"-360,360,1,or_greater,or_less"[/code].
Hints that an [int] or [float] property should be within a range specified via the hint string [code]"min,max"[/code] or [code]"min,max,step"[/code]. The hint string can optionally include [code]"or_greater"[/code] and/or [code]"or_less"[/code] to allow manual input going respectively above the max or below the min values.
[b]Example:[/b] [code]"-360,360,1,or_greater,or_less"[/code].
Additionally, other keywords can be included: [code]"exp"[/code] for exponential range editing, [code]"radians"[/code] for editing radian angles in degrees, [code]"degrees"[/code] to hint at an angle and [code]"hide_slider"[/code] to hide the slider.
</constant>
<constant name="PROPERTY_HINT_ENUM" value="2" enum="PropertyHint">
Expand Down Expand Up @@ -2722,7 +2725,8 @@
<constant name="PROPERTY_HINT_OBJECT_ID" value="24" enum="PropertyHint">
</constant>
<constant name="PROPERTY_HINT_TYPE_STRING" value="25" enum="PropertyHint">
Hints that a property represents a particular type. If a property is [constant TYPE_STRING], allows to set a type from the create dialog. If you need to create an [Array] to contain elements of a specific type, the [code]hint_string[/code] must encode nested types using [code]":"[/code] and [code]"/"[/code] for specifying [Resource] types. For example:
Hints that a property represents a particular type. If a property is [constant TYPE_STRING], allows to set a type from the create dialog. If you need to create an [Array] to contain elements of a specific type, the [code]hint_string[/code] must encode nested types using [code]":"[/code] and [code]"/"[/code] for specifying [Resource] types.
[b]Example:[/b]
[codeblock]
hint_string = "%s:" % [TYPE_INT] # Array of integers.
hint_string = "%s:%s:" % [TYPE_ARRAY, TYPE_REAL] # Two-dimensional array of floats.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/AcceptDialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
Sets autowrapping for the text in the dialog.
</member>
<member name="dialog_close_on_escape" type="bool" setter="set_close_on_escape" getter="get_close_on_escape" default="true">
If [code]true[/code], the dialog will be hidden when the escape key ([constant @GlobalScope.KEY_ESCAPE]) is pressed.
If [code]true[/code], the dialog will be hidden when the escape key ([constant KEY_ESCAPE]) is pressed.
</member>
<member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" default="true">
If [code]true[/code], the dialog is hidden when the OK button is pressed. You can set it to [code]false[/code] if you want to do e.g. input validation when receiving the [signal confirmed] signal, and handle hiding the dialog in your own logic.
Expand Down
7 changes: 3 additions & 4 deletions doc/classes/Array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,13 @@
<method name="get_typed_builtin" qualifiers="const">
<return type="int" />
<description>
Returns the [code]TYPE[/code] constant for a typed array. If the [Array] is not typed, returns [constant @GlobalScope.TYPE_NIL].
Returns the [enum Variant.Type] constant for a typed array. If the [Array] is not typed, returns [constant TYPE_NIL].
</description>
</method>
<method name="get_typed_class_name" qualifiers="const">
<return type="StringName" />
<description>
Returns a class name of a typed [Array] of type [constant @GlobalScope.TYPE_OBJECT].
Returns a class name of a typed [Array] of type [constant TYPE_OBJECT].
</description>
</method>
<method name="get_typed_script" qualifiers="const">
Expand Down Expand Up @@ -353,7 +353,6 @@
GD.Print(arr.Contains("7")); // False
[/csharp]
[/codeblocks]

[b]Note:[/b] This is equivalent to using the [code]in[/code] operator as follows:
[codeblocks]
[gdscript]
Expand Down Expand Up @@ -543,7 +542,7 @@
<param index="1" name="class_name" type="StringName" />
<param index="2" name="script" type="Variant" />
<description>
Makes the [Array] typed. The [param type] should be one of the [@GlobalScope] [code]TYPE[/code] constants. [param class_name] is optional and can only be provided for [constant @GlobalScope.TYPE_OBJECT]. [param script] can only be provided if [param class_name] is not empty.
Makes the [Array] typed. The [param type] should be one of the [enum Variant.Type] constants. [param class_name] is optional and can only be provided for [constant TYPE_OBJECT]. [param script] can only be provided if [param class_name] is not empty.
The method fails if an array is already typed.
</description>
</method>
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/BitMap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<method name="convert_to_image" qualifiers="const">
<return type="Image" />
<description>
Returns an image of the same size as the bitmap and with a [enum Image.Format] of type [code]FORMAT_L8[/code]. [code]true[/code] bits of the bitmap are being converted into white pixels, and [code]false[/code] bits into black.
Returns an image of the same size as the bitmap and with a [enum Image.Format] of type [constant Image.FORMAT_L8]. [code]true[/code] bits of the bitmap are being converted into white pixels, and [code]false[/code] bits into black.
</description>
</method>
<method name="create">
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/Button.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</tutorials>
<members>
<member name="alignment" type="int" setter="set_text_alignment" getter="get_text_alignment" enum="HorizontalAlignment" default="1">
Text alignment policy for the button's text, use one of the [enum @GlobalScope.HorizontalAlignment] constants.
Text alignment policy for the button's text, use one of the [enum HorizontalAlignment] constants.
</member>
<member name="clip_text" type="bool" setter="set_clip_text" getter="get_clip_text" default="false">
When this property is enabled, text that is too large to fit the button is clipped, when disabled the Button will always be wide enough to hold the text.
Expand All @@ -58,7 +58,7 @@
To edit margin and spacing of the icon, use [theme_item h_separation] theme property and [code]content_margin_*[/code] properties of the used [StyleBox]es.
</member>
<member name="icon_alignment" type="int" setter="set_icon_alignment" getter="get_icon_alignment" enum="HorizontalAlignment" default="0">
Specifies if the icon should be aligned to the left, right, or center of a button. Uses the same [enum @GlobalScope.HorizontalAlignment] constants as the text alignment. If centered, text will draw on top of the icon.
Specifies if the icon should be aligned to the left, right, or center of a button. Uses the same [enum HorizontalAlignment] constants as the text alignment. If centered, text will draw on top of the icon.
</member>
<member name="language" type="String" setter="set_language" getter="get_language" default="&quot;&quot;">
Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
Expand Down
3 changes: 2 additions & 1 deletion doc/classes/CallbackTweener.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
<return type="CallbackTweener" />
<param index="0" name="delay" type="float" />
<description>
Makes the callback call delayed by given time in seconds. Example:
Makes the callback call delayed by given time in seconds.
[b]Example:[/b]
[codeblock]
var tween = get_tree().create_tween()
tween.tween_callback(queue_free).set_delay(2) #this will call queue_free() after 2 seconds
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/CharacterBody2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
</member>
<member name="floor_snap_length" type="float" setter="set_floor_snap_length" getter="get_floor_snap_length" default="1.0">
Sets a snapping distance. When set to a value different from [code]0.0[/code], the body is kept attached to slopes when calling [method move_and_slide]. The snapping vector is determined by the given distance along the opposite direction of the [member up_direction].
As long as the snapping vector is in contact with the ground and the body moves against `up_direction`, the body will remain attached to the surface. Snapping is not applied if the body moves along `up_direction`, so it will be able to detach from the ground when jumping.
As long as the snapping vector is in contact with the ground and the body moves against [member up_direction], the body will remain attached to the surface. Snapping is not applied if the body moves along [member up_direction], so it will be able to detach from the ground when jumping.
</member>
<member name="floor_stop_on_slope" type="bool" setter="set_floor_stop_on_slope_enabled" getter="is_floor_stop_on_slope_enabled" default="true">
If [code]true[/code], the body will not slide on slopes when calling [method move_and_slide] when the body is standing still.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/CharacterBody3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
</member>
<member name="floor_snap_length" type="float" setter="set_floor_snap_length" getter="get_floor_snap_length" default="0.1">
Sets a snapping distance. When set to a value different from [code]0.0[/code], the body is kept attached to slopes when calling [method move_and_slide]. The snapping vector is determined by the given distance along the opposite direction of the [member up_direction].
As long as the snapping vector is in contact with the ground and the body moves against `up_direction`, the body will remain attached to the surface. Snapping is not applied if the body moves along `up_direction`, so it will be able to detach from the ground when jumping.
As long as the snapping vector is in contact with the ground and the body moves against [member up_direction], the body will remain attached to the surface. Snapping is not applied if the body moves along [member up_direction], so it will be able to detach from the ground when jumping.
</member>
<member name="floor_stop_on_slope" type="bool" setter="set_floor_stop_on_slope_enabled" getter="is_floor_stop_on_slope_enabled" default="true">
If [code]true[/code], the body will not slide on slopes when calling [method move_and_slide] when the body is standing still.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/CodeEdit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Multiline text control intended for editing code.
</brief_description>
<description>
CodeEdit is a specialised [TextEdit] designed for editing plain text code files. It contains a bunch of features commonly found in code editors such as line numbers, line folding, code completion, indent management and string / comment management.
CodeEdit is a specialized [TextEdit] designed for editing plain text code files. It contains a bunch of features commonly found in code editors such as line numbers, line folding, code completion, indent management and string / comment management.
[b]Note:[/b] By default [CodeEdit] always use left-to-right text direction to correctly display source code.
</description>
<tutorials>
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/Color.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
<description>
Returns the luminance of the color in the [code][0.0, 1.0][/code] range.
This is useful when determining light or dark color. Colors with a luminance smaller than 0.5 can be generally considered dark.
[b]Note:[/b] [method get_luminance] relies on the colour being in the linear color space to return an accurate relative luminance value. If the color is in the sRGB color space, use [method srgb_to_linear] to convert it to the linear color space first.
[b]Note:[/b] [method get_luminance] relies on the color being in the linear color space to return an accurate relative luminance value. If the color is in the sRGB color space, use [method srgb_to_linear] to convert it to the linear color space first.
</description>
</method>
<method name="hex" qualifiers="static">
Expand Down
14 changes: 7 additions & 7 deletions doc/classes/ConfigFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
<param index="0" name="path" type="String" />
<description>
Loads the config file specified as a parameter. The file's contents are parsed and loaded in the [ConfigFile] object which the method was called on.
Returns one of the [enum Error] code constants ([code]OK[/code] on success).
Returns one of the [enum Error] code constants ([constant OK] on success).
</description>
</method>
<method name="load_encrypted">
Expand All @@ -172,7 +172,7 @@
<param index="1" name="key" type="PackedByteArray" />
<description>
Loads the encrypted config file specified as a parameter, using the provided [param key] to decrypt it. The file's contents are parsed and loaded in the [ConfigFile] object which the method was called on.
Returns one of the [enum Error] code constants ([code]OK[/code] on success).
Returns one of the [enum Error] code constants ([constant OK] on success).
</description>
</method>
<method name="load_encrypted_pass">
Expand All @@ -181,23 +181,23 @@
<param index="1" name="password" type="String" />
<description>
Loads the encrypted config file specified as a parameter, using the provided [param password] to decrypt it. The file's contents are parsed and loaded in the [ConfigFile] object which the method was called on.
Returns one of the [enum Error] code constants ([code]OK[/code] on success).
Returns one of the [enum Error] code constants ([constant OK] on success).
</description>
</method>
<method name="parse">
<return type="int" enum="Error" />
<param index="0" name="data" type="String" />
<description>
Parses the passed string as the contents of a config file. The string is parsed and loaded in the ConfigFile object which the method was called on.
Returns one of the [enum Error] code constants ([code]OK[/code] on success).
Returns one of the [enum Error] code constants ([constant OK] on success).
</description>
</method>
<method name="save">
<return type="int" enum="Error" />
<param index="0" name="path" type="String" />
<description>
Saves the contents of the [ConfigFile] object to the file specified as a parameter. The output file uses an INI-style structure.
Returns one of the [enum Error] code constants ([code]OK[/code] on success).
Returns one of the [enum Error] code constants ([constant OK] on success).
</description>
</method>
<method name="save_encrypted">
Expand All @@ -206,7 +206,7 @@
<param index="1" name="key" type="PackedByteArray" />
<description>
Saves the contents of the [ConfigFile] object to the AES-256 encrypted file specified as a parameter, using the provided [param key] to encrypt it. The output file uses an INI-style structure.
Returns one of the [enum Error] code constants ([code]OK[/code] on success).
Returns one of the [enum Error] code constants ([constant OK] on success).
</description>
</method>
<method name="save_encrypted_pass">
Expand All @@ -215,7 +215,7 @@
<param index="1" name="password" type="String" />
<description>
Saves the contents of the [ConfigFile] object to the AES-256 encrypted file specified as a parameter, using the provided [param password] to encrypt it. The output file uses an INI-style structure.
Returns one of the [enum Error] code constants ([code]OK[/code] on success).
Returns one of the [enum Error] code constants ([constant OK] on success).
</description>
</method>
<method name="set_value">
Expand Down
Loading

0 comments on commit f7c611a

Please sign in to comment.