Enable sorting of operator methods in class documentation.

This commit is contained in:
Marcel Admiraal 2021-11-28 08:48:57 +00:00
parent 52b7d5fa34
commit 272b3c3728
7 changed files with 75 additions and 64 deletions

View File

@ -70,18 +70,29 @@ public:
Vector<int> errors_returned; Vector<int> errors_returned;
bool operator<(const MethodDoc &p_method) const { bool operator<(const MethodDoc &p_method) const {
if (name == p_method.name) { if (name == p_method.name) {
// Must be a constructor since there is no overloading. // Must be an operator or a constructor since there is no other overloading
// We want this arbitrary order for a class "Foo": if (name.left(8) == "operator") {
// - 1. Default constructor: Foo() if (arguments.size() == p_method.arguments.size()) {
// - 2. Copy constructor: Foo(Foo) if (arguments.size() == 0) {
// - 3+. Other constructors Foo(Bar, ...) based on first argument's name return false;
if (arguments.size() == 0 || p_method.arguments.size() == 0) { // 1. }
return arguments[0].type < p_method.arguments[0].type;
}
return arguments.size() < p_method.arguments.size(); return arguments.size() < p_method.arguments.size();
} else {
// Must be a constructor
// We want this arbitrary order for a class "Foo":
// - 1. Default constructor: Foo()
// - 2. Copy constructor: Foo(Foo)
// - 3+. Other constructors Foo(Bar, ...) based on first argument's name
if (arguments.size() == 0 || p_method.arguments.size() == 0) { // 1.
return arguments.size() < p_method.arguments.size();
}
if (arguments[0].type == return_type || p_method.arguments[0].type == p_method.return_type) { // 2.
return (arguments[0].type == return_type) || (p_method.arguments[0].type != p_method.return_type);
}
return arguments[0] < p_method.arguments[0];
} }
if (arguments[0].type == return_type || p_method.arguments[0].type == p_method.return_type) { // 2.
return (arguments[0].type == return_type) || (p_method.arguments[0].type != p_method.return_type);
}
return arguments[0] < p_method.arguments[0];
} }
return name < p_method.name; return name < p_method.name;
} }

View File

@ -224,13 +224,6 @@
Transforms (multiplies) each element of the [Vector2] array by the given [Transform2D] matrix. Transforms (multiplies) each element of the [Vector2] array by the given [Transform2D] matrix.
</description> </description>
</operator> </operator>
<operator name="operator *">
<return type="Transform2D" />
<argument index="0" name="right" type="Transform2D" />
<description>
Composes these two transformation matrices by multiplying them together. This has the effect of transforming the second transform (the child) by the first transform (the parent).
</description>
</operator>
<operator name="operator *"> <operator name="operator *">
<return type="Rect2" /> <return type="Rect2" />
<argument index="0" name="right" type="Rect2" /> <argument index="0" name="right" type="Rect2" />
@ -238,6 +231,13 @@
Transforms (multiplies) the [Rect2] by the given [Transform2D] matrix. Transforms (multiplies) the [Rect2] by the given [Transform2D] matrix.
</description> </description>
</operator> </operator>
<operator name="operator *">
<return type="Transform2D" />
<argument index="0" name="right" type="Transform2D" />
<description>
Composes these two transformation matrices by multiplying them together. This has the effect of transforming the second transform (the child) by the first transform (the parent).
</description>
</operator>
<operator name="operator *"> <operator name="operator *">
<return type="Vector2" /> <return type="Vector2" />
<argument index="0" name="right" type="Vector2" /> <argument index="0" name="right" type="Vector2" />

View File

@ -151,6 +151,13 @@
[b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable. [b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable.
</description> </description>
</operator> </operator>
<operator name="operator *">
<return type="AABB" />
<argument index="0" name="right" type="AABB" />
<description>
Transforms (multiplies) the [AABB] by the given [Transform3D] matrix.
</description>
</operator>
<operator name="operator *"> <operator name="operator *">
<return type="PackedVector3Array" /> <return type="PackedVector3Array" />
<argument index="0" name="right" type="PackedVector3Array" /> <argument index="0" name="right" type="PackedVector3Array" />
@ -165,13 +172,6 @@
Composes these two transformation matrices by multiplying them together. This has the effect of transforming the second transform (the child) by the first transform (the parent). Composes these two transformation matrices by multiplying them together. This has the effect of transforming the second transform (the child) by the first transform (the parent).
</description> </description>
</operator> </operator>
<operator name="operator *">
<return type="AABB" />
<argument index="0" name="right" type="AABB" />
<description>
Transforms (multiplies) the [AABB] by the given [Transform3D] matrix.
</description>
</operator>
<operator name="operator *"> <operator name="operator *">
<return type="Vector3" /> <return type="Vector3" />
<argument index="0" name="right" type="Vector3" /> <argument index="0" name="right" type="Vector3" />

View File

@ -356,6 +356,13 @@
[b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable. [b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable.
</description> </description>
</operator> </operator>
<operator name="operator *">
<return type="Vector2" />
<argument index="0" name="right" type="Transform2D" />
<description>
Inversely transforms (multiplies) the [Vector2] by the given [Transform2D] transformation matrix.
</description>
</operator>
<operator name="operator *"> <operator name="operator *">
<return type="Vector2" /> <return type="Vector2" />
<argument index="0" name="right" type="Vector2" /> <argument index="0" name="right" type="Vector2" />
@ -366,13 +373,6 @@
[/codeblock] [/codeblock]
</description> </description>
</operator> </operator>
<operator name="operator *">
<return type="Vector2" />
<argument index="0" name="right" type="Transform2D" />
<description>
Inversely transforms (multiplies) the [Vector2] by the given [Transform2D] transformation matrix.
</description>
</operator>
<operator name="operator *"> <operator name="operator *">
<return type="Vector2" /> <return type="Vector2" />
<argument index="0" name="right" type="float" /> <argument index="0" name="right" type="float" />

View File

@ -371,16 +371,6 @@
[b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable. [b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable.
</description> </description>
</operator> </operator>
<operator name="operator *">
<return type="Vector3" />
<argument index="0" name="right" type="Vector3" />
<description>
Multiplies each component of the [Vector3] by the components of the given [Vector3].
[codeblock]
print(Vector3(10, 20, 30) * Vector3(3, 4, 5)) # Prints "(30, 80, 150)"
[/codeblock]
</description>
</operator>
<operator name="operator *"> <operator name="operator *">
<return type="Vector3" /> <return type="Vector3" />
<argument index="0" name="right" type="Basis" /> <argument index="0" name="right" type="Basis" />
@ -402,6 +392,16 @@
Inversely transforms (multiplies) the [Vector3] by the given [Transform3D] transformation matrix. Inversely transforms (multiplies) the [Vector3] by the given [Transform3D] transformation matrix.
</description> </description>
</operator> </operator>
<operator name="operator *">
<return type="Vector3" />
<argument index="0" name="right" type="Vector3" />
<description>
Multiplies each component of the [Vector3] by the components of the given [Vector3].
[codeblock]
print(Vector3(10, 20, 30) * Vector3(3, 4, 5)) # Prints "(30, 80, 150)"
[/codeblock]
</description>
</operator>
<operator name="operator *"> <operator name="operator *">
<return type="Vector3" /> <return type="Vector3" />
<argument index="0" name="right" type="float" /> <argument index="0" name="right" type="float" />

View File

@ -62,10 +62,13 @@
</description> </description>
</operator> </operator>
<operator name="operator *"> <operator name="operator *">
<return type="float" /> <return type="Color" />
<argument index="0" name="right" type="float" /> <argument index="0" name="right" type="Color" />
<description> <description>
Multiplies two [float]s. Multiplies each component of the [Color] by the given [float].
[codeblock]
print(1.5 * Color(0.5, 0.5, 0.5)) # Color(0.75, 0.75, 0.75)
[/codeblock]
</description> </description>
</operator> </operator>
<operator name="operator *"> <operator name="operator *">
@ -113,13 +116,10 @@
</description> </description>
</operator> </operator>
<operator name="operator *"> <operator name="operator *">
<return type="Color" /> <return type="float" />
<argument index="0" name="right" type="Color" /> <argument index="0" name="right" type="float" />
<description> <description>
Multiplies each component of the [Color] by the given [float]. Multiplies two [float]s.
[codeblock]
print(1.5 * Color(0.5, 0.5, 0.5)) # Color(0.75, 0.75, 0.75)
[/codeblock]
</description> </description>
</operator> </operator>
<operator name="operator *"> <operator name="operator *">

View File

@ -131,20 +131,6 @@
Multiplies each component of the [Quaternion] by the given [int]. This operation is not meaningful on its own, but it can be used as a part of a larger expression. Multiplies each component of the [Quaternion] by the given [int]. This operation is not meaningful on its own, but it can be used as a part of a larger expression.
</description> </description>
</operator> </operator>
<operator name="operator *">
<return type="int" />
<argument index="0" name="right" type="int" />
<description>
Multiplies two [int]s.
</description>
</operator>
<operator name="operator *">
<return type="float" />
<argument index="0" name="right" type="float" />
<description>
Multiplies an [int] and a [float]. The result is a [float].
</description>
</operator>
<operator name="operator *"> <operator name="operator *">
<return type="Vector2" /> <return type="Vector2" />
<argument index="0" name="right" type="Vector2" /> <argument index="0" name="right" type="Vector2" />
@ -176,6 +162,20 @@
Multiplies each component of the [Vector3i] by the given [int]. Multiplies each component of the [Vector3i] by the given [int].
</description> </description>
</operator> </operator>
<operator name="operator *">
<return type="float" />
<argument index="0" name="right" type="float" />
<description>
Multiplies an [int] and a [float]. The result is a [float].
</description>
</operator>
<operator name="operator *">
<return type="int" />
<argument index="0" name="right" type="int" />
<description>
Multiplies two [int]s.
</description>
</operator>
<operator name="operator +"> <operator name="operator +">
<return type="float" /> <return type="float" />
<argument index="0" name="right" type="float" /> <argument index="0" name="right" type="float" />