DocData: Fix serialization of Variant default values

Co-authored-by: Bojidar Marinov <bojidar.marinov.bg@gmail.com>
This commit is contained in:
Rémi Verschelde 2020-03-09 10:51:17 +01:00
parent da1f80c1f2
commit 788765709d
9 changed files with 24 additions and 23 deletions

View File

@ -127,7 +127,7 @@
</return> </return>
<argument index="0" name="value" type="Variant"> <argument index="0" name="value" type="Variant">
</argument> </argument>
<argument index="1" name="before" type="bool" default="True"> <argument index="1" name="before" type="bool" default="true">
</argument> </argument>
<description> <description>
Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search. Optionally, a [code]before[/code] specifier can be passed. If [code]false[/code], the returned index comes after all existing entries of the value in the array. Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search. Optionally, a [code]before[/code] specifier can be passed. If [code]false[/code], the returned index comes after all existing entries of the value in the array.
@ -143,7 +143,7 @@
</argument> </argument>
<argument index="2" name="func" type="String"> <argument index="2" name="func" type="String">
</argument> </argument>
<argument index="3" name="before" type="bool" default="True"> <argument index="3" name="before" type="bool" default="true">
</argument> </argument>
<description> <description>
Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search and a custom comparison method. Optionally, a [code]before[/code] specifier can be passed. If [code]false[/code], the returned index comes after all existing entries of the value in the array. The custom method receives two arguments (an element from the array and the value searched for) and must return [code]true[/code] if the first argument is less than the second, and return [code]false[/code] otherwise. Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search and a custom comparison method. Optionally, a [code]before[/code] specifier can be passed. If [code]false[/code], the returned index comes after all existing entries of the value in the array. The custom method receives two arguments (an element from the array and the value searched for) and must return [code]true[/code] if the first argument is less than the second, and return [code]false[/code] otherwise.
@ -169,7 +169,7 @@
<method name="duplicate"> <method name="duplicate">
<return type="Array"> <return type="Array">
</return> </return>
<argument index="0" name="deep" type="bool" default="False"> <argument index="0" name="deep" type="bool" default="false">
</argument> </argument>
<description> <description>
Returns a copy of the array. Returns a copy of the array.
@ -357,7 +357,7 @@
</argument> </argument>
<argument index="2" name="step" type="int" default="1"> <argument index="2" name="step" type="int" default="1">
</argument> </argument>
<argument index="3" name="deep" type="bool" default="False"> <argument index="3" name="deep" type="bool" default="false">
</argument> </argument>
<description> <description>
Duplicates the subset described in the function and returns it in an array, deeply copying the array if [code]deep[/code] is [code]true[/code]. Lower and upper index are inclusive, with the [code]step[/code] describing the change between indices while slicing. Duplicates the subset described in the function and returns it in an array, deeply copying the array if [code]deep[/code] is [code]true[/code]. Lower and upper index are inclusive, with the [code]step[/code] describing the change between indices while slicing.

View File

@ -100,7 +100,7 @@
</return> </return>
<argument index="0" name="b" type="Basis"> <argument index="0" name="b" type="Basis">
</argument> </argument>
<argument index="1" name="epsilon" type="float" default="0.00001"> <argument index="1" name="epsilon" type="float" default="1e-05">
</argument> </argument>
<description> <description>
Returns [code]true[/code] if this basis and [code]b[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component. Returns [code]true[/code] if this basis and [code]b[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component.

View File

@ -119,7 +119,7 @@
</argument> </argument>
<argument index="2" name="v" type="float"> <argument index="2" name="v" type="float">
</argument> </argument>
<argument index="3" name="a" type="float" default="1"> <argument index="3" name="a" type="float" default="1.0">
</argument> </argument>
<description> <description>
Constructs a color from an HSV profile. [code]h[/code], [code]s[/code], and [code]v[/code] are values between 0 and 1. Constructs a color from an HSV profile. [code]h[/code], [code]s[/code], and [code]v[/code] are values between 0 and 1.
@ -224,7 +224,7 @@
<method name="to_html"> <method name="to_html">
<return type="String"> <return type="String">
</return> </return>
<argument index="0" name="with_alpha" type="bool" default="True"> <argument index="0" name="with_alpha" type="bool" default="true">
</argument> </argument>
<description> <description>
Returns the color's HTML hexadecimal color string in ARGB format (ex: [code]ff34f822[/code]). Returns the color's HTML hexadecimal color string in ARGB format (ex: [code]ff34f822[/code]).

View File

@ -75,7 +75,7 @@
<method name="duplicate"> <method name="duplicate">
<return type="Dictionary"> <return type="Dictionary">
</return> </return>
<argument index="0" name="deep" type="bool" default="False"> <argument index="0" name="deep" type="bool" default="false">
</argument> </argument>
<description> <description>
Creates a copy of the dictionary, and returns it. Creates a copy of the dictionary, and returns it.
@ -102,7 +102,7 @@
</return> </return>
<argument index="0" name="key" type="Variant"> <argument index="0" name="key" type="Variant">
</argument> </argument>
<argument index="1" name="default" type="Variant" default="Null"> <argument index="1" name="default" type="Variant" default="null">
</argument> </argument>
<description> <description>
Returns the current value for the specified key in the [Dictionary]. If the key does not exist, the method returns the value of the optional default argument, or [code]null[/code] if it is omitted. Returns the current value for the specified key in the [Dictionary]. If the key does not exist, the method returns the value of the optional default argument, or [code]null[/code] if it is omitted.

View File

@ -77,7 +77,7 @@
</return> </return>
<argument index="0" name="point" type="Vector3"> <argument index="0" name="point" type="Vector3">
</argument> </argument>
<argument index="1" name="epsilon" type="float" default="0.00001"> <argument index="1" name="epsilon" type="float" default="1e-05">
</argument> </argument>
<description> <description>
Returns [code]true[/code] if [code]point[/code] is inside the plane (by a very minimum [code]epsilon[/code] threshold). Returns [code]true[/code] if [code]point[/code] is inside the plane (by a very minimum [code]epsilon[/code] threshold).

View File

@ -143,7 +143,7 @@
</return> </return>
<argument index="0" name="b" type="Rect2"> <argument index="0" name="b" type="Rect2">
</argument> </argument>
<argument index="1" name="include_borders" type="bool" default="False"> <argument index="1" name="include_borders" type="bool" default="false">
</argument> </argument>
<description> <description>
Returns [code]true[/code] if the [Rect2] overlaps with [code]b[/code] (i.e. they have at least one point in common). Returns [code]true[/code] if the [Rect2] overlaps with [code]b[/code] (i.e. they have at least one point in common).

View File

@ -440,7 +440,7 @@
</return> </return>
<argument index="0" name="values" type="Variant"> <argument index="0" name="values" type="Variant">
</argument> </argument>
<argument index="1" name="placeholder" type="String" default="{_}"> <argument index="1" name="placeholder" type="String" default="&quot;{_}&quot;">
</argument> </argument>
<description> <description>
Formats the string by replacing all occurrences of [code]placeholder[/code] with [code]values[/code]. Formats the string by replacing all occurrences of [code]placeholder[/code] with [code]values[/code].
@ -586,7 +586,7 @@
<method name="is_valid_hex_number"> <method name="is_valid_hex_number">
<return type="bool"> <return type="bool">
</return> </return>
<argument index="0" name="with_prefix" type="bool" default="False"> <argument index="0" name="with_prefix" type="bool" default="false">
</argument> </argument>
<description> <description>
Returns [code]true[/code] if this string contains a valid hexadecimal number. If [code]with_prefix[/code] is [code]true[/code], then a validity of the hexadecimal number is determined by [code]0x[/code] prefix, for instance: [code]0xDEADC0DE[/code]. Returns [code]true[/code] if this string contains a valid hexadecimal number. If [code]with_prefix[/code] is [code]true[/code], then a validity of the hexadecimal number is determined by [code]0x[/code] prefix, for instance: [code]0xDEADC0DE[/code].
@ -810,7 +810,7 @@
</return> </return>
<argument index="0" name="delimiter" type="String"> <argument index="0" name="delimiter" type="String">
</argument> </argument>
<argument index="1" name="allow_empty" type="bool" default="True"> <argument index="1" name="allow_empty" type="bool" default="true">
</argument> </argument>
<argument index="2" name="maxsplit" type="int" default="0"> <argument index="2" name="maxsplit" type="int" default="0">
</argument> </argument>
@ -879,7 +879,7 @@
</return> </return>
<argument index="0" name="delimiter" type="String"> <argument index="0" name="delimiter" type="String">
</argument> </argument>
<argument index="1" name="allow_empty" type="bool" default="True"> <argument index="1" name="allow_empty" type="bool" default="true">
</argument> </argument>
<argument index="2" name="maxsplit" type="int" default="0"> <argument index="2" name="maxsplit" type="int" default="0">
</argument> </argument>
@ -901,7 +901,7 @@
</return> </return>
<argument index="0" name="delimiter" type="String"> <argument index="0" name="delimiter" type="String">
</argument> </argument>
<argument index="1" name="allow_empty" type="bool" default="True"> <argument index="1" name="allow_empty" type="bool" default="true">
</argument> </argument>
<description> <description>
Splits the string in floats by using a delimiter string and returns an array of the substrings. Splits the string in floats by using a delimiter string and returns an array of the substrings.
@ -911,9 +911,9 @@
<method name="strip_edges"> <method name="strip_edges">
<return type="String"> <return type="String">
</return> </return>
<argument index="0" name="left" type="bool" default="True"> <argument index="0" name="left" type="bool" default="true">
</argument> </argument>
<argument index="1" name="right" type="bool" default="True"> <argument index="1" name="right" type="bool" default="true">
</argument> </argument>
<description> <description>
Returns a copy of the string stripped of any non-printable character (including tabulations, spaces and line breaks) at the beginning and the end. The optional arguments are used to toggle stripping on the left and right edges respectively. Returns a copy of the string stripped of any non-printable character (including tabulations, spaces and line breaks) at the beginning and the end. The optional arguments are used to toggle stripping on the left and right edges respectively.

View File

@ -555,9 +555,11 @@ void DocData::generate(bool p_basic_types) {
argument_doc_from_arginfo(ad, mi.arguments[j]); argument_doc_from_arginfo(ad, mi.arguments[j]);
ad.name = arginfo.name; ad.name = arginfo.name;
int defarg = mi.default_arguments.size() - mi.arguments.size() + j; int darg_idx = mi.default_arguments.size() - mi.arguments.size() + j;
if (defarg >= 0) if (darg_idx >= 0) {
ad.default_value = mi.default_arguments[defarg]; Variant default_arg = mi.default_arguments[darg_idx];
ad.default_value = default_arg.get_construct_string();
}
method.arguments.push_back(ad); method.arguments.push_back(ad);
} }
@ -674,7 +676,6 @@ void DocData::generate(bool p_basic_types) {
argument_doc_from_arginfo(ad, mi.arguments[j]); argument_doc_from_arginfo(ad, mi.arguments[j]);
int darg_idx = j - (mi.arguments.size() - mi.default_arguments.size()); int darg_idx = j - (mi.arguments.size() - mi.default_arguments.size());
if (darg_idx >= 0) { if (darg_idx >= 0) {
Variant default_arg = E->get().default_arguments[darg_idx]; Variant default_arg = E->get().default_arguments[darg_idx];
ad.default_value = default_arg.get_construct_string(); ad.default_value = default_arg.get_construct_string();