Factorio Lua API Docs

Place to post guides, observations, things related to modding that are not mods themselves.
User avatar
Hares
Filter Inserter
Filter Inserter
Posts: 581
Joined: Sat Oct 22, 2022 8:05 pm
Contact:

Factorio Lua API Docs

Post by Hares »

The Factorio provides documentation for its API in the two formats -- HTML (Web) and JSON.
However, most IDEs require specific format for the built-in functions, and for Lua it's LuaDoc or LDoc (which is newer version of LuaDoc).
I was unable to find any on the Internet, so I've created parser for that.
Posting it here for sharing purposes.
Factorio LuaDocs Generator
Image This works fine with EmmyLua plugin for VSCode or JetBrains products (PyCharm, IDEA, and other), however the last ones could sometimes fail to parse methods.
Image

The CI and automated releases are not yet set up, so I've prepared a precompiled archive for versions 1.1.80 .. 1.1.82
Usage
Feature not yet implemented are marked in strikethrough.
If you want to use it by yourself, there are three two ways to do so:
  • Download the precompiled archive from the attachments above or from the releases section on GitLab and extract it.
  • Download and install tool source code, then compile the required version. Full details on the ReadMe of the repository
  • Install tool from PyPI via pip
You should then mark the directory with the extracted/generated content as an additional sources root or library root for your project.
Attachments
factorio-luadocs-1.1.8x.zip
Precompiled LuaDocs for Factorio 1.1.80 .. 1.1.82
(426.87 KiB) Downloaded 73 times
Bilka
Factorio Staff
Factorio Staff
Posts: 3310
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Factorio Lua API Docs

Post by Bilka »

Hey, the Factorio Modding Tool Kit (FMTK) can also do this and much more. It supports the format used by sumneko.lua, which is based on EmmyLua: https://github.com/LuaLS/lua-language-s ... nnotations
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
User avatar
Hares
Filter Inserter
Filter Inserter
Posts: 581
Joined: Sat Oct 22, 2022 8:05 pm
Contact:

Re: Factorio Lua API Docs

Post by Hares »

Thanks for the suggestion. I've seen this one before, but it exists only for VSCode which I personally don't like.
However, even Factorio Modding Tool Kit can't export Lua API in external format so other apps can use it.
Bilka
Factorio Staff
Factorio Staff
Posts: 3310
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Factorio Lua API Docs

Post by Bilka »

Hares wrote: Sat May 27, 2023 8:09 pm However, even Factorio Modding Tool Kit can't export Lua API in external format so other apps can use it.
You should be able to use the npm package with "fmtk sumneko-3rd" to generate the file and then use that file with other programs, see the first link in my previous post. sumneko.lua supports a lot of editors since it just uses LSP, no need for VSCode.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Post Reply

Return to “Modding discussion”