Page 1 of 1

Parsing wiki information

Posted: Sat Aug 22, 2020 7:03 pm
by jcranmer
I've been working on a tool to automatically convert the Factorio Lua data into a JSON format more reasonable for other tooling. To this end, I'm looking at parsing the Wiki data to automatically write the parser [1]. One thing I've noticed is that the semantic mediawiki information for the prototype definitions don't have the default information. The template for parsing a file only adds information on the name, type, and optionality:

Code: Select all

 |Prototype property name={{{1}}}
 |Prototype property type={{{2}}}
 |Prototype property optional={{{optional|false}}}
 |Prototype property pagename={{FULLPAGENAME}}
 
But there's no inclusion of the default value (which would be {{{3}}} in wiki terms). Could this be added?


[1] So it's kind of like a compiler compiler compiler. Don't you love getting all meta?

Re: Parsing wiki information

Posted: Mon Aug 24, 2020 7:24 am
by Bilka
jcranmer wrote:
Sat Aug 22, 2020 7:03 pm
But there's no inclusion of the default value (which would be {{{3}}} in wiki terms). Could this be added?
Theoretically, yes. Practically, it is not there because it does not have consistent formatting, making it basically useless for "machine reading". To illustrate, the value may or may not be wrapped in nowiki tags, may have extra text describing what it does, may only be that extra text without the actual value, or may be completely missing for some properties while existing for others that have the same default.
It may be added to the properties in the future when I have the time to unify the formatting/values, however this is would not happen anytime soon as other things, such as updating the prototype documentation to 1.0.0 in the first place, have much higher priority.

Aside from this, how do you plan to handle the fact that the Types/ pages are not part of the SMW information?
Furthermore, could you explain to me why you need the prototype definitions to convert the data.raw Lua table to Json in the first place? The Json conversion should be pretty easily done by writing a mod that just stringifies the data.raw table to Json using using a Lua Json library, no need for external syntax definitions.

Re: Parsing wiki information

Posted: Mon Aug 21, 2023 1:22 pm
by Bilka
A few years later and we now have machine readable information for the prototype defaults and the Types over at https://lua-api.factorio.com/latest/aux ... otype.html. I hope it helps :D