Jump to content
TeardownMods

Unofficial API.lua Workspace Library Converted from xml for VSCode 1.0.0

   (1 review)

2 Screenshots

About This File

After getting frustrated by having to search the api.xml file every time I needed to call a function, rather than being able to use VSCode's Intellisense to autocomplete and check them, as well as getting no good answer on how I could use the XML as a library or what IDE would support it; I decided to use a series of long regex replacements to convert it from .xml format to .lua format so that I could use the lua.workspace.library setting in Sumneko's LUA extension to add the api to intellisense. I am providing it here because I put 7 hours into this and I don't want anyone who has the same problem to have to do the same thing if I can provide a solution for them.

Bear in mind that this was done with regex replacement, so it's not perfect. And also note that I could not find a way to mark an argument/parameter as optional in a lua library... I may rebuild it and add that to the description section if I get the motivation.

 

Special thanks to https://regexr.com/ for making the process achievable for me. Without it and it's tools, I would never have been able to finish this project.

 

 

If you are interested, here is an example of the crazy regex I ended up using... This isn't even the longest one...

Find: (?:---@return (\b\w+\b ).+?[\s\S]+?)?(?:---@return (\b\w+\b ).+?[\s\S]+?)?(?:---@return (\b\w+\b ).+?[\s\S]+?)?(?:---@return (\b\w+\b ).+?[\s\S]+?)?function (?:\b\w+\b)

replace:$&\n\treturn $1\n\treturn $2\n\treturn $3\n\treturn $4\n


What's New in Version 1.0.0   See changelog

Released

No changelog available for this version.

  • Like 2

User Feedback

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest

Cheejins

   1 of 1 member found this review helpful 1 / 1 member

Amazing. Thank you for making this, it will help lots of modders out there.

Link to comment
×
×
  • Create New...

How to Disable AdBlock - And why you should do it?

I have disabled AdBlocker. Refresh the page.