Commit Graph

130 Commits

Author SHA1 Message Date
George Marques b880bde10f Remove outdated note about const in Dictionary and Array docs
(cherry picked from commit d2b1d6e69b)
2023-03-13 14:27:48 +01:00
Rémi Verschelde bbff9fd7a4
Merge pull request #71786 from raulsntos/dotnet/array
Sync C# Array with Core
2023-02-04 00:24:06 +01:00
Dmitrii Maganov 5909f9f075 GDScript: Fix issues with typed arrays 2023-01-31 11:54:41 +02:00
bruvzg 5aa87ccc03
Move Array:set_typed to internal GDExtension structure and unexposed it. 2023-01-30 14:23:31 +02:00
Raul Santos 54f8fb010c
Sync C# Array with Core
- Add `AddRange` method.
- Add `Fill` method.
- Add `Max` and `Min` methods.
- Add `PickRandom` method.
- Add `Reverse` method.
- Add `RecursiveEqual` method.
- Add `Sort` method.
- Add `Slice` and `GetSliceRange` methods.
- Add `IndexOf` overload that takes an index parameter.
- Add `LastIndexOf` method.
- Add `BinarySearch` method.
- Add/update documentation.
2023-01-30 05:41:53 +01:00
Dmitrii Maganov abe6d67232 GDScript: Fix test for read-only state of constants 2023-01-27 05:28:08 +02:00
Raul Santos 97610c8bfc
Add property usage to array indexer
This makes the `Array` indexer show as returning `Variant` instead of `void` in the documentation.
2023-01-19 14:22:11 +01:00
Rémi Verschelde 2d2902b49b
Merge pull request #70745 from rcorre/array_dup_doc
Explain that Array.duplicate will not deep-copy Object.
2023-01-10 10:45:30 +01:00
Ryan Roden-Corrent 1f6a5e8bb1
Warn against erasing array elements while iterating.
Erasing array elements while iterating does not appear to be safe.
For example, the following prints nothing:

```
var a := [0,1,2,3,4,5,6]
for i in a:
        if i % 2 == 0:
                a.erase(i)
        else:
                print(i)
```

While this is often true for array implementations, it still seems worth
documenting explicitly. I copied the wording from Dictionary.xml.
2023-01-06 08:21:01 -05:00
Ryan Roden-Corrent 53181e4090
Explain that Array.duplicate will not deep-copy Object.
This was somewhat implied by specifically calling out nested arrays and
dictionaries, but I was still unsure and had to test it myself.
One might expect that `Resource` objects, which have a `duplicate`
method, might be deep-copied.
2022-12-30 11:59:07 -05:00
Micky 67cdac6db8 Remove `Array.find_last()` 2022-11-25 18:34:50 +01:00
Rémi Verschelde f7c611ab71
Style: Misc docs and comment style and language fixes
- 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`.
2022-11-02 19:01:18 +01:00
kleonc 221a89f2ef Docs Clarify `Array.fill` behavior when reference type is passed in 2022-10-30 13:42:24 +01:00
Max Hilbrunner 5cefc07d90
Merge pull request #67444 from nonunknown/array_pick_random
Add ability to pick random value from array
2022-10-21 16:25:52 +02:00
Nonunknown 9f4dbf415d add ability to pick random value from array 2022-10-20 08:39:47 -03:00
Max Hilbrunner e6311c8e5e
Merge pull request #67001 from KoBeWi/🎲
Fill random docs
2022-10-19 21:58:03 +02:00
Hugo Locurcio 85b617a6a3
Document `Array.sort()` and `sort_custom()` using unstable sorting 2022-10-08 01:16:41 +02:00
kobewi 1b7aee3c8d Fill random docs 2022-10-07 20:10:18 +02:00
bruvzg 163257d51b
[GDExtension] Implement support for typed arrays. 2022-09-22 23:31:27 +03:00
Andy Maloney c7da28165b [doc] Fix grammar in class docs: less vs. fewer/lower 2022-08-18 12:35:54 -04:00
Andy Maloney 9b345e793a [doc] Use "param" instead of "code" to refer to parameters (8) 2022-08-12 14:00:25 -04:00
Yuri Sizov c5d7115038 Rename the argument tag to param in XML documentation 2022-08-08 22:34:31 +03:00
Danil Alexeev 8b97fa4dcd
Clarify `all` and `any` documentation for empty arrays 2022-06-16 20:50:31 +03:00
Hugo Locurcio a98e31aa3a
Add `any()` and `all()` methods to Array
These can be used as faster, more convenient shorthands to
using `filter()` + `size()`.
2022-05-25 16:09:10 +02:00
Rémi Verschelde c91f4ac419
Merge pull request #59910 from rcorre/array-remove-doc 2022-04-05 13:43:21 +02:00
Ryan Roden-Corrent f84e2db35e
Clarify Array.erase for nonexistant element.
The docs specify that Array.remove does nothing if the index does not
exist. Array.erase does not have a similar phrase, so it's unclear if
erase will print an error, or silently do nothing.
2022-04-05 07:07:56 -04:00
Hugo Locurcio de363db2a6
Improve documentation for Array operators 2022-03-30 20:04:45 +02:00
Karmavil aef97305db Add descriptions to operators 2022-03-27 12:13:56 -03:00
Yuri Roubinsky 32f2c47356 Remove generating of null comparison operators from documentation 2022-03-14 22:35:23 +03:00
Hugo Locurcio b68dd2e189
Add an XML schema for documentation
This makes it easier to spot syntax errors when editing the
class reference. The schema is referenced locally so validation
can still work offline.

Each class XML's schema conformance is also checked on GitHub Actions.
2022-02-15 00:03:31 +01:00
Hugo Locurcio 08541fe11d
Clarify identical `hash()` return values due to collisions 2022-02-12 22:21:37 +01:00
Rémi Verschelde 9912492e93
Merge pull request #56668 from akien-mga/array-slice-nicer-bound-checks 2022-01-18 13:22:35 +01:00
Lisandro Lorea 176a9c738f
Give example of one-liner for Array natural sort
The documentation for the sort method warns the user that it doesn't do natural sort but fails to provide a solution when it's just a one liner thanks to String.naturalnocasecmp_to() and lambda support

This suggests exactly the same algorithm as used by the filesystem dock for file sorting.

Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
2022-01-17 15:11:50 -03:00
Rémi Verschelde c6cefb1b79
`Array`: Relax `slice` bound checks to properly handle negative indices
The same is done for `Vector` (and thus `Packed*Array`).

`begin` and `end` can now take any value and will be clamped to
`[-size(), size()]`. Negative values are a shorthand for indexing the array
from the last element upward.

`end` is given a default `INT_MAX` value (which will be clamped to `size()`)
so that the `end` parameter can be omitted to go from `begin` to the max size
of the array.

This makes `slice` works similarly to numpy's and JavaScript's.
2022-01-10 22:42:03 +01:00
Nathan Franke dd30253cdc
PackedByteArray, Array slice end exclusive, rename subarray to slice 2021-11-26 22:13:12 -06:00
Lightning_A e078f970db Rename `remove()` to `remove_at()` when removing by index 2021-11-23 18:58:57 -07:00
kobewi f529a58f10 Improve sort_custom() example 2021-11-12 23:18:33 +01:00
Aaron Franke 6772ebcea0
Move the docs for constructors and operators out of methods section 2021-10-29 12:34:57 -05:00
Rémi Verschelde 788b3aa27a
doc: Fix style inconsistencies for `[b]Note:[/b]` paragraphs
And fix up formatting not supported by makerst.
2021-10-05 19:13:20 +02:00
Aaron Franke d54f2ad7ca
Don't generate empty doc sections and reduce code duplication 2021-09-20 20:59:33 -05:00
George Marques 455e142d37
Allow comparing equality between builtin types and null 2021-09-17 12:33:52 -03:00
Max Hilbrunner 5b49c6bba4 Fix docs for Array's slice() 2021-09-07 21:40:21 +02:00
Johannes Witt 48a8a59ad7
Specify description of Array.slices end parameter 2021-09-05 21:49:57 +02:00
Max Hilbrunner a2473d7ebe Fix Array class docs after #47406 2021-08-28 22:17:41 +02:00
Hugo Locurcio 60116b17b5
Add an `Array.pop_at()` method to pop an element at an arbitrary index
Negative indices are supported to pop an element relative from the end.
2021-08-27 00:51:17 +02:00
Rémi Verschelde 7adf4cc9b5
doc: Use self-closing tags for `return` and `argument`
For the time being we don't support writing a description for those, preferring
having all details in the method's description.

Using self-closing tags saves half the lines, and prevents contributors from
thinking that they should write the argument or return documentation there.
2021-07-30 15:29:52 +02:00
Nicholas Huelin 9a72b0d3d0 Fix doc typos
This pull request fixes an assortment of typos and improves conciseness in `Animation`, `Area2D`,  `Array`, `ArrayMesh`, `Control`, `Directory`, `EditorPlugin`, `Engine`, and `OS`.
2021-07-23 12:15:15 -04:00
Rémi Verschelde 74b3b0db0e
Merge pull request #47584 from HaSa1002/docs-lang-7 2021-06-11 14:35:45 +02:00
Johannes 23bc697239
Port code examples to C# (V)
Includes:
 * Variant
 * Viewport

and two fixes in Array that were pointed out in #40978
VisualScript classes are skipped on purpose.
That is the final commit of the inital code porting to C#. :)
2021-06-11 13:24:11 +02:00
kobewi 48f0368ddc Improve sort_custom() description 2021-06-03 17:43:39 +02:00