Skip to content

Document the return values of resize on packed arrays #10760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
theraot opened this issue Mar 12, 2025 · 8 comments
Closed

Document the return values of resize on packed arrays #10760

theraot opened this issue Mar 12, 2025 · 8 comments
Labels
area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository enhancement

Comments

@theraot
Copy link

theraot commented Mar 12, 2025

Your Godot version:

v4.4.stable.official [4c311cbee]

Issue description:

The resize method of packed array returns int, but the documentation does not explain what the value is. In practices it returns 0 and for what I understand from the source code it is an Error. So, I presume the only other possible value is ERR_OUT_OF_MEMORY.

Note that it is not hard to imagine that the return value is something related to the size.

URL to the documentation page (if already existing):

@theraot
Copy link
Author

theraot commented Mar 12, 2025

The method append/push_back also has an undocumented return value.

Addednum: Looking at the source code, I find that append/push_back return true if resize failed internally, and false if it completed normally.

@Monochrome-debug
Copy link

So you just want resize() to show it's return value in the docs?

Monochrome-debug added a commit to Monochrome-debug/godot-docs that referenced this issue Mar 16, 2025
@Monochrome-debug
Copy link

So like the commit I just made?

@theraot
Copy link
Author

theraot commented Mar 16, 2025

That's the idea. But no. Make the commit against the main Godot repository: https://github.com/godotengine/godot/tree/master/doc As far as I know the files you edited are autogenerated from that. And then a pull request saying it fixes my issue, so it can be reviewed and merged.

I made the issue because these in particular can be confusing (resize returns and int, but it has nothing to do with size, and append returns a bool, but it is true on failure). But there are other things you can add like that to the docs if you want to continue doing this kind of commits.

@Monochrome-debug
Copy link

Is the new description I made good?

@theraot
Copy link
Author

theraot commented Mar 16, 2025

It does what I asked. Yet, take other parts of the documentation as example of how to phrase it. For instance Array Insert: https://docs.godotengine.org/en/stable/classes/class_array.html#class-array-method-insert and once you make a pull request against the main godot repository it would be reviewed, and if there is anything missing or unclear they will tell you. In fact, I'm hoping somebody more familiar with it to have a look at it, not just me.

@Monochrome-debug
Copy link

I made some changes in the official godot repo and declared a pull request: godotengine/godot#104258

@tetrapod00 tetrapod00 added enhancement area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository labels Apr 10, 2025
@tetrapod00
Copy link
Contributor

Closed by godotengine/godot#104258

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:class reference Issues and PRs about the class reference, which should be addressed on the Godot engine repository enhancement
Projects
None yet
Development

No branches or pull requests

3 participants