Reading API documentation programically

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
CzBuCHi
Long Handed Inserter
Long Handed Inserter
Posts: 90
Joined: Thu Feb 22, 2018 10:25 pm
Contact:

Reading API documentation programically

Post by CzBuCHi »

Hello, i would like to programically read all LUA class definitions, but i only found HTML documentation at http://lua-api.factorio.com/latest/, which is not ideal data source :/ (its doable but bleh...)

has factorio some other public methods to read api (json, xml) ?

PS: im guessing that documentation HTML is generated and not hand written, so there must be some machine readable data source that can be used ...

PSS: Reason why i wanna to do this is because in trying to create mod, but currently spending 90% of time in browser searching how to write stuff (new to lua too) and also i found this: https://github.com/Perryvw/TypescriptToLua ... so im thinking about creating mod written in typescript and then transpiled to lua via node script...

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Reading API documentation programically

Post by DaveMcW »

HTML is generated from C++ class definitions, which are not publicly available.

Lua is very easy to learn, easier than the Factorio API!

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Reading API documentation programically

Post by eradicator »

How does cross-compiling a mod from another language help you learn the factorio api?

CzBuCHi
Long Handed Inserter
Long Handed Inserter
Posts: 90
Joined: Thu Feb 22, 2018 10:25 pm
Contact:

Re: Reading API documentation programically

Post by CzBuCHi »

HTML is generated from C++ class definitions, which are not publicly available.
So "only" thing, that needs to be done is writing generator, that will generate xml or json intead of html? --or-- make C++ class declarations (not definitions ofc) public :)

PS: Faster solution may be adding special html attribtues into generated html.
- for example only way i found out how to determine, that html is describing property is by looking for " :: " string as first child of <span class="attribute-type">. :/
Also property type may be spread across multiple html elements (LuaLogisticPoint or array of LuaLogisticPoint, etc.)

How does cross-compiling a mod from another language help you learn the factorio api?
In typescript i can write (generate) type definition file, that will be then picked up by IDE for intellisense, so i wouldn't need to remember (search for) correct syntax for factorio api related stuff...

fiery_salmon
Fast Inserter
Fast Inserter
Posts: 128
Joined: Wed Dec 13, 2017 1:20 pm
Contact:

Re: Reading API documentation programically

Post by fiery_salmon »

CzBuCHi wrote:so im thinking about creating mod written in typescript and then transpiled to lua via node script...
I am betting that any time saved by this contraption would be small compared to setting it up and debugging

CzBuCHi
Long Handed Inserter
Long Handed Inserter
Posts: 90
Joined: Thu Feb 22, 2018 10:25 pm
Contact:

Re: Reading API documentation programically

Post by CzBuCHi »

fiery_salmon wrote:
CzBuCHi wrote:so im thinking about creating mod written in typescript and then transpiled to lua via node script...
I am betting that any time saved by this contraption would be small compared to setting it up and debugging
probably :) ... but i have no idea how to debug lua using vscode ... also i dont wanna insall yet another ide for editing lua ....

PS: also i think that writing type definitions for typescript will force me to learn whole factorio api anyway :)

Bilka
Factorio Staff
Factorio Staff
Posts: 3129
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Reading API documentation programically

Post by Bilka »

If you are using vscode, just use this already existing extension for autocompletion that also includes a script to parse the documentation: https://github.com/simonvizzini/vscode- ... er/scraper
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

CzBuCHi
Long Handed Inserter
Long Handed Inserter
Posts: 90
Joined: Thu Feb 22, 2018 10:25 pm
Contact:

Re: Reading API documentation programically

Post by CzBuCHi »

Bilka wrote:If you are using vscode, just use this already existing extension for autocompletion that also includes a script to parse the documentation: https://github.com/simonvizzini/vscode- ... er/scraper
i tryied that extension already, but didnt look at the code so i definely look atparser code .... thx

Post Reply

Return to “Modding discussion”