-
Notifications
You must be signed in to change notification settings - Fork 103
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
Convert LDoc to lua-language-server #1775
base: master
Are you sure you want to change the base?
Convert LDoc to lua-language-server #1775
Conversation
Is there a way to stop CI from running while the PR is in draft? I didn't realize it was going to keep spinning up CI every time I pushed. |
In that case check the other files because sometimes you do Lines 61 to 62 in f9d2bc7
spring/rts/Lua/LuaSyncedRead.cpp Lines 1346 to 1347 in f9d2bc7
|
Sorry it's really going to take a while, I have a full time job. I spent the entire weekend writing the code extractor, and then did a first pass with Happy to receive feedback, but pls focus on the files I've checked off in the folded up "manual conversion checklist" in the PR description. |
Hm, actually you're right. The initial |
9e70eb3
to
aae1c98
Compare
adc2667
to
54b564b
Compare
I've opened a draft PR on BAR repo with my latest generated docs: beyond-all-reason/Beyond-All-Reason#3949 |
d7284c9
to
f22ef88
Compare
Using a set of simple regexp replacements to convert from LDoc compatible lua doc syntax. Script used: https://github.com/rhys-vdw/spring-lua-doc-converter
dab73e0
to
c2fe27b
Compare
Written by badosu
196d616
to
802c044
Compare
802c044
to
6f071d8
Compare
4626943
to
7ec427e
Compare
Fixing a bunch of bad stuff.
Change the command to generate from root, because of a bug where using relative paths causes duplicated generation.
7a42c8e
to
eb26ffe
Compare
---@enum CMD | ||
CMD = { | ||
---@type -1 | ||
FIRESTATE_NONE = nil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can convince lua-ls to actually define the constant with the number we already know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was generated by my lua-doc-extractor, so we do have full control over how it is generated.
It is actually defined as that constant. Constants are types in LLS, so @type -1
is correctly defining the value, LuaLS then disregards the nil
. I can't remember exactly why I did it this way, but I think it was just easier to generate and seems to work fine.
However, I noticed that this style of enum declaration (marking a table as an enum) does not export to docs properly (it ends up just knowing there is an enum called CMD
, but is not aware of its members). I believe it is "correct" in terms of the Lua interface, given that there is indeed a table called CMD
defined in the global table. So I'd probably prefer to take this issue up with LuaLS maintainers and have it fixed upstream rather than screw around with the generation to make it conform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Goal
Completely convert over to lua-language-server compatible Lua type annotations that can be imported into BAR and other projects that use Recoil.
Plan has been discussed with @badosu. It's going to take a little while.
Steps
LuaConstCMD.cpp
CMD enumLuaConstCMDTYPE.cpp
CMDTYPE enumluarc.json
to springrts/Lua/*.cpp
).Merge steps:
recoil-lua-librarynot needed, consumers can use submodule from main reporecoil-lua-library
RECOIL_LUA_LIBRARY_GITHUB_TOKEN
in Spring repoPost-merge steps:
Stuff to follow up on
spring/rts/Lua/LuaFBOs.cpp
Lines 412 to 415 in 38598d1
LuaHandle
functions on?spring/rts/Lua/LuaHandle.cpp
Lines 490 to 493 in 38598d1
LuaMenu
☝️GetSolidObjectPieceInfoHelper
returns[x,y,z]
and other things return{ x:, y:, z: }
. Come up with good names for them (currently latter isfloat3
).PieceInfo
class to usefloat3
typergb
inLuaUnsyncedCtrl::SetAtmosphere
, this is an array, but would it also support a table?cmdOpts
— one claims that it can be provided as an array of values, but has different fields — confirm which is true and whether array is supported (and which params are supported in this array)LuaUnsyncedCtrl.cpp
LuaHandle.cpp
cmdSpec
☝️ (this is the same, but has the nestedcmdOpts
so is it the same?LuaUnsyncedCtrl::GiveOrder
— returns1
without pushing return value?GLenum
type name and table name (GL
). Bit confusing as is!@func x
and replace with@param x function
LuaZip.cpp
seems to be completely unused, it has some methods onSpring
andVFS
and others on a table calledZipFileWriter
but they're not referenced anywhere in Recoil in BAR.LuaConstGL.cpp
CLuaHandle::UnitCommand
CLuaHandle::UnitCmdDone
LuaOpenGL.cpp
is mostly undocumented.Manual conversion checklist
LuaBitOps.cpp
LuaConstCMD.cpp
(blocked by enums)LuaConstCMDTYPE.cpp
(blocked by enums)LuaConstCOB.cpp
LuaConstEngine.cpp
LuaConstGL.cpp
LuaConstGame.cpp
LuaConstPlatform.cpp
LuaFBOs.cpp
LuaHandle.cpp
LuaHandleSynced.cpp
LuaMathExtra.cpp
LuaMenu.cpp
LuaMetalMap.cpp
LuaOpenGL.cpp
LuaRBOs.cpp
LuaRules.cpp
LuaShaders.cpp
LuaSyncedCtrl.cpp
LuaSyncedMoveCtrl.cpp
LuaSyncedRead.cpp
LuaUnsyncedCtrl.cpp
LuaUnsyncedRead.cpp
LuaVAO.cpp
LuaVAOImpl.cpp
LuaVBO.cpp
LuaVBOImpl.cpp
LuaVFS.cpp
LuaZip.cpp