Page 1 of 1

Reading API documentation programically

Posted: Thu Apr 05, 2018 7:56 pm
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...

Re: Reading API documentation programically

Posted: Thu Apr 05, 2018 9:43 pm
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!

Re: Reading API documentation programically

Posted: Fri Apr 06, 2018 11:12 am
by eradicator
How does cross-compiling a mod from another language help you learn the factorio api?

Re: Reading API documentation programically

Posted: Fri Apr 06, 2018 12:15 pm
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...

Re: Reading API documentation programically

Posted: Fri Apr 06, 2018 1:24 pm
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

Re: Reading API documentation programically

Posted: Fri Apr 06, 2018 1:28 pm
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 :)

Re: Reading API documentation programically

Posted: Fri Apr 06, 2018 3:39 pm
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

Re: Reading API documentation programically

Posted: Fri Apr 06, 2018 5:35 pm
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