-
Notifications
You must be signed in to change notification settings - Fork 105
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
196d616
to
802c044
Compare
4626943
to
7ec427e
Compare
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.
75f89b0
to
673b0fd
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.
1cc22bb
to
2f7e62d
Compare
3f995c6
to
cd039ff
Compare
a8596f7
to
cd467d2
Compare
@@ -13,7 +13,13 @@ jobs: | |||
- name: Install Dependencies | |||
run: | | |||
sudo apt-get update -y | |||
sudo apt-get install --fix-missing -y lua-ldoc lua-markdown jq p7zip-full libsdl2-2.0-0 libopenal1 | |||
sudo apt-get install --fix-missing -y jq p7zip-full libsdl2-2.0-0 libopenal1 |
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.
@badosu I removed lua-ldoc and lua-markdown, but maybe none of these are needed anymore?
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.
Should not be
@@ -55,8 +53,8 @@ jobs: | |||
id: site-changes | |||
if: steps.check-ghpages.outputs.exists == 'true' | |||
run: | | |||
git diff --stat origin/gh-pages master:doc/site | |||
git diff --quiet origin/gh-pages master:doc/site && (echo "modified=false" > $GITHUB_OUTPUT) || (echo "modified=true" > $GITHUB_OUTPUT) | |||
git diff --stat origin/gh-pages ${{ github.ref_name }}:doc/site |
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.
@badosu pls see changes made here. github.ref_name
should be the branch that triggered the merge. This allows testing of this workflow from an alternative branch during development.
The removal of ref:
from actions/checkout
also will default to the action branch.
In general I expect this will still run on master when executed by cron
.
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.
That said, it might make sense to run this job when master changes rather than on a timer? I also noticed that it's running on my fork (and presumably every other fork), and just failing every time.
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'd rather have it on a timer simply due to the fact it's not critical docs are updated more frequently than daily, but we have more updates than once a day. But this is my opinion.
---Note the callin won't be executed at the time of calling this method, | ||
---but later, on the Update cycle (before other Update and Draw callins). | ||
--- | ||
---@string filePath VFS path to the file, for example "fonts/myfont.ttf". Uses VFS.RAW_FIRST access mode. |
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.
here are some ldoc strings
I think it'd be better to not have autogenerated stuff in the same repo, maybe a different repo linked through submodule could have a similar effect. I think it would pollute the git history here, make the repo larger, complicate checking diff between commits a bit, and eventually may cause other problems. Also for linking into other repos, like game repos, I think submodule approach will make it easier for them too, otherwise even if they can restrict to having just a subfolder in the working tree they probably will need to deal with the whole recoil repo and history and keep it around to be able to update. Not saying this is a blocker, just a concern. |
Otherwise at least maybe don't put it under rts/ (or cont/) since that's where cpp/lua code lives and it will complicate text searching there if we have autogenerated stuff. |
Sounds good, maybe inside |
I agree with @saurtron here, but my primary concern is with BAR requiring the entire history of this repo just for a few files. My original approach was to keep the lua files here (generated by the workflow) but then have them copied into an additional repo that can be used as a submodule by BAR (and any other engine consumer). This is primarily because there is support hand-authored lua library files (currently just I think maybe these hand-authored library files can live in |
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
).Submodule approach:
Follow up:
Post-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