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

Convert LDoc to lua-language-server #1775

Draft
wants to merge 49 commits into
base: master
Choose a base branch
from

Conversation

rhys-vdw
Copy link
Contributor

@rhys-vdw rhys-vdw commented Nov 17, 2024

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

Merge steps:

  • Move repos into BAR org
  • Get privileges for both.
  • Update library generator workflow
    • Get PAT with "content" write privileges enabled for recoil-lua-library
    • Set this as RECOIL_LUA_LIBRARY_GITHUB_TOKEN in Spring repo

Post-merge steps:

Stuff to follow up on

  • What types are these

    spring/rts/Lua/LuaFBOs.cpp

    Lines 412 to 415 in 38598d1

    /***
    * @table attachment
    * attachment ::= luaTex or `RBO.rbo` or nil or { luaTex [, num target [, num level ] ] }
    */
  • What table are these LuaHandle functions on?
    /*** Called when the game is (re)loaded.
    *
    * @function LoadCode
    */
  • Same as LuaMenu ☝️
  • GetSolidObjectPieceInfoHelper returns [x,y,z] and other things return { x:, y:, z: }. Come up with good names for them (currently latter is float3).
  • PieceInfo class to use float3 type
  • Same with rgb in LuaUnsyncedCtrl::SetAtmosphere, this is an array, but would it also support a table?
  • Centralize shared types into their own file.
  • Two different and conflicting definitions of 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)
  • Same as cmdSpec ☝️ (this is the same, but has the nested cmdOpts so is it the same?
  • Possible error in LuaUnsyncedCtrl::GiveOrder — returns 1 without pushing return value?
  • Unify GLenum type name and table name (GL). Bit confusing as is!
  • Do a final search for @func x and replace with @param x function
  • Consider defining a float type?
  • LuaZip.cpp seems to be completely unused, it has some methods on Spring and VFS and others on a table called ZipFileWriter but they're not referenced anywhere in Recoil in BAR.
  • Lots of duplication in LuaConstGL.cpp
  • Docs look completely wrong for:
    • 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

@rhys-vdw rhys-vdw marked this pull request as draft November 17, 2024 05:44
@rhys-vdw
Copy link
Contributor Author

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.

@sprunk
Copy link
Collaborator

sprunk commented Nov 17, 2024

In that case check the other files because sometimes you do @param type name and sometimes @param name type.

* @param a1 integer
* @param a2 integer

* @param number x
* @param number z

@rhys-vdw
Copy link
Contributor Author

rhys-vdw commented Nov 17, 2024

In that case check the other files because sometimes you do @param type name and sometimes @param name type.

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 sed. I'm quite motivated to get it all done, but you'll need to wait a little bit. There's only so much that can be achieved with regex replace!

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.

@rhys-vdw
Copy link
Contributor Author

Hm, actually you're right. The initial sed pass did output the @param args in the wrong order... Hm! I might fix it and rebase the changes in. Probably will be a net time saving.

@rhys-vdw
Copy link
Contributor Author

In that case check the other files because sometimes you do @param type name and sometimes @param name type.

Good catch @sprunk. I've updated the regex and rebase the other commits on top. 9696f51

@rhys-vdw rhys-vdw force-pushed the rhys-vdw/lua-language-server branch 2 times, most recently from adc2667 to 54b564b Compare November 18, 2024 08:31
rts/Lua/LuaSyncedCtrl.cpp Outdated Show resolved Hide resolved
@rhys-vdw
Copy link
Contributor Author

I've opened a draft PR on BAR repo with my latest generated docs: beyond-all-reason/Beyond-All-Reason#3949

@rhys-vdw rhys-vdw force-pushed the rhys-vdw/lua-language-server branch 2 times, most recently from d7284c9 to f22ef88 Compare November 20, 2024 17:09
Written by badosu
@saurtron saurtron added the documentation Improvements or additions to documentation label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants