Skip to content
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

Lua API: Add inline documentation for pretty much everything #6483

Merged
merged 29 commits into from Feb 17, 2022

Conversation

CelticMinstrel
Copy link
Member

@CelticMinstrel CelticMinstrel commented Feb 3, 2022

I did this several months ago but never got around to submitting it, so there might be something missing here and there if things have changed since then.

In addition to covering things defined in Lua, this includes stub definitions with documentation of everything defined in C++, in the utils/emmylua folder.

The Lua add-on for Visual Studio Code uses this format to improve tooltips and auto-completion.

@github-actions github-actions bot added the Lua API Issues with the Lua engine and API. label Feb 3, 2022
@@ -120,7 +162,7 @@ if wesnoth.kernel_type() == "Game Lua Kernel" then
elseif key == 2 then
return self.y
elseif type(key) ~= string or (#key > 0 and key[0] ~= '_') then
return hex_mt[key]
return hex_methods[key]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an issue here, as a) I don't remember why the ~= string test was added and b) the ~= string test itself is wrong. I think it's out of scope for this PR though.

utils/emmylua/gui.lua Outdated Show resolved Hide resolved
---A generic container that lays out its children in a grid
---@class grid : widget

---@class gui.widget
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not confident that the above covers every possible type of widget… can anyone see one I've missed?

data/lua/core/map.lua Outdated Show resolved Hide resolved
@CelticMinstrel CelticMinstrel marked this pull request as draft February 3, 2022 15:00
data/lua/core/map.lua Outdated Show resolved Hide resolved
@github-actions github-actions bot added AI Issues with the AI engine, including micro AIs. Campaign (any) Deprecated tag, replaced with separate tags for each mainline campaign labels Feb 4, 2022
@stevecotton
Copy link
Contributor

stevecotton commented Feb 4, 2022 via email

@CelticMinstrel
Copy link
Member Author

Oh right, you're probably right. So I'll delete that last commit then.

@CelticMinstrel CelticMinstrel marked this pull request as ready for review February 6, 2022 03:35
@CelticMinstrel
Copy link
Member Author

Okay, I see three unresolved comments… not counting the two that are unrelated to the actual content of this PR.

utils/emmylua/wml.lua Outdated Show resolved Hide resolved
@stevecotton
Copy link
Contributor

@CelticMinstrel , I've now finished reading all the files.

@CelticMinstrel
Copy link
Member Author

Okay, unless you have further comments regarding my replies and latest commits, I think this is ready to squash.

---@field plague_type string If the attack inflicts plague, this specifies the unit type it is converted to.
---@field backstabs boolean
---@field rounds integer The number of rounds of combat.
---@field firststrike boolean Indicates whether the attack always strikes first.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, but suspect many of the booleans here are whether the ability is active in the particular fight (whether the opponent is immune to poison, also has firststrike, etc).

@CelticMinstrel CelticMinstrel merged commit e1300e2 into master Feb 17, 2022
@CelticMinstrel CelticMinstrel deleted the luadoc branch February 17, 2022 18:43
Asheviere pushed a commit to Asheviere/wesnoth that referenced this pull request Feb 18, 2022
…ert existing docs (wesnoth#6483)


The new format is EmmyLua-based and can be used with (at least) Visual Studio Code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI Issues with the AI engine, including micro AIs. Campaign (any) Deprecated tag, replaced with separate tags for each mainline campaign Lua API Issues with the Lua engine and API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants