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: 57
Joined: Thu Feb 22, 2018 10:25 pm
Contact:

Reading API documentation programically

Post by CzBuCHi » Thu Apr 05, 2018 7:56 pm

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: 2767
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Reading API documentation programically

Post by DaveMcW » Thu Apr 05, 2018 9:43 pm

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: 3068
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Reading API documentation programically

Post by eradicator » Fri Apr 06, 2018 11:12 am

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

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

Re: Reading API documentation programically

Post by CzBuCHi » Fri Apr 06, 2018 12:15 pm

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: 119
Joined: Wed Dec 13, 2017 1:20 pm
Contact:

Re: Reading API documentation programically

Post by fiery_salmon » Fri Apr 06, 2018 1:24 pm

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: 57
Joined: Thu Feb 22, 2018 10:25 pm
Contact:

Re: Reading API documentation programically

Post by CzBuCHi » Fri Apr 06, 2018 1:28 pm

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: 1879
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Reading API documentation programically

Post by Bilka » Fri Apr 06, 2018 3:39 pm

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: 57
Joined: Thu Feb 22, 2018 10:25 pm
Contact:

Re: Reading API documentation programically

Post by CzBuCHi » Fri Apr 06, 2018 5:35 pm

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”

Who is online

Users browsing this forum: ratchetfreak