defold-annotations icon indicating copy to clipboard operation
defold-annotations copied to clipboard

Annotation typos and outdated meta information

Open astrochili opened this issue 1 year ago • 28 comments

Fixing annotation typos and outdated meta information requires edits to the Defold source code, as this is the main source of documentation generation.

This issue is an attempt to collect that kind of bugs in one place and prepare pull requests to Defold batchwise. So feel free to share any annotation issues here. It will be more useful than fixing these bugs locally or just ignoring them.

astrochili avatar Jan 22 '24 16:01 astrochili

This may be a Defold doc bug as well? particlefx.stop is annotated with a required options parameter, but it is actually optional as seen at https://defold.com/manuals/particlefx/?q=particlefx.stop#controlling-a-particle-effect - however the Defold API reference does NOT indicate it is optional at the moment.

---Stopping a particle FX does not remove already spawned particles.
---Which particle FX to stop is identified by the URL.
---@param url string|hash|url the particle fx that should stop playing
---@param options table Options when stopping the particle fx. Supported options:
---
---boolean clear: instantly clear spawned particles
---
function particlefx.stop(url, options) end
image

swajj avatar Jan 23 '24 05:01 swajj

The annotations are missing operators for vector3/4. image

I had these added to my custom copy of what you're currently storing in types.lua, they work for me to prevent things like the above:

---@class vector3
---@operator sub(vector3): vector3
---@operator add(vector3): vector3
---@operator mul(number): vector3
---@operator unm: vector3

---@class vector4
---@operator sub(vector4): vector4
---@operator add(vector4): vector4
---@operator mul(number): vector4
---@operator unm: vector4

swajj avatar Jan 23 '24 05:01 swajj

gui.is_enabled() should have the second argument as optional.

image

Jerakin avatar Apr 07 '24 11:04 Jerakin

gui.set_text() should also accepts integers. image

Jerakin avatar Apr 07 '24 15:04 Jerakin

Prepared everything mentioned above in this commit - https://github.com/astrochili/defold/commit/6637dec175ba5f6e79b3276ee137140f95f10043.

Waiting for a while, in case @Jerakin finds something else, and I'll send the PR to Defold.

Also I added operators for vector3/4 and matrix4 defenition to this repository.

astrochili avatar Apr 07 '24 20:04 astrochili

Can the "standard" functions within Defold be annotated? image

I am using a my template editor extension currently when creating new files to get the annotations but would be neat if some basic ones could be automatic, (I bet the action table would be hard) - of course there isn't much to annotate, but if possible why not :)

Jerakin avatar Apr 07 '24 21:04 Jerakin

To be honest, I don't know how to do it globally, as each update function has its own file context... and at the same time they are global dublicates for LLS. This requires experimentation.

But in templates you can of course just write:

---@param self table (or your local `SCRIPT_NAME.self` class?)
---@param dt number
function update(self, dt)
  ...
end

astrochili avatar Apr 07 '24 22:04 astrochili

Created PR to Defold https://github.com/defold/defold/pull/8776

astrochili avatar Apr 09 '24 23:04 astrochili

Updated the 1.7.0 release with all these fixes. Also added a lot of known table defenitions according https://github.com/astrochili/defold-annotations/issues/1.

Feel free to tell me about 'yellow underlines' if you see them. I may have made mistakes in tables or annotations, the edit was a major one.

astrochili avatar Apr 09 '24 23:04 astrochili

gui.set_parent(node, parent, keep_scene_transform) should accepts nil as parent. Supplying nil "parents" it to the scene (i.e remove the parent). image

Jerakin avatar Apr 13 '24 10:04 Jerakin

gui.set_parent(node, parent, keep_scene_transform) should accepts nil as parent. Supplying nil "parents" it to the scene (i.e remove the parent). image

astrochili avatar Apr 13 '24 15:04 astrochili

sys.reboot params should be string|nil

---@param arg1 string argument 1
---@param arg2 string argument 2
---@param arg3 string argument 3
---@param arg4 string argument 4
---@param arg5 string argument 5
---@param arg6 string argument 6
function sys.reboot(arg1, arg2, arg3, arg4, arg5, arg6) end

Insality avatar May 23 '24 19:05 Insality

sys.reboot params should be string|nil

---@param arg1 string argument 1
---@param arg2 string argument 2
---@param arg3 string argument 3
---@param arg4 string argument 4
---@param arg5 string argument 5
---@param arg6 string argument 6
function sys.reboot(arg1, arg2, arg3, arg4, arg5, arg6) end

Interesting. Are you sure? I am not good at c++, but in the source code some 6 arguments are processed.

astrochili avatar May 24 '24 09:05 astrochili

Ah okay, sorry, just need to add |nil! 👍

astrochili avatar May 24 '24 09:05 astrochili

sys.reboot params should be string|nil

Added PR https://github.com/defold/defold/pull/8976 Updated manually 1.8.0 annotations release.

astrochili avatar May 24 '24 09:05 astrochili