px4-firmware/Tools/px4params/dokuwikiout.py

69 lines
2.4 KiB
Python
Raw Normal View History

2013-10-17 20:47:15 -03:00
import output
from xml.sax.saxutils import escape
2013-10-17 20:47:15 -03:00
class DokuWikiOutput(output.Output):
def Generate(self, groups):
pre_text = """<?xml version='1.0'?>
<methodCall>
<methodName>wiki.putPage</methodName>
<params>
<param>
<value>
2014-01-29 14:18:44 -04:00
<string>:firmware:parameters</string>
</value>
</param>
<param>
<value>
<string>"""
result = "====== Parameter Reference ======\nThis list is auto-generated every few minutes and contains the most recent parameter names and default values."
2013-10-17 20:47:15 -03:00
for group in groups:
result += "==== %s ====\n\n" % group.GetName()
result += "|< 100% 20% 20% 10% 10% 10% 30%>|\n"
result += "^ Name ^ Description ^ Min ^ Max ^ Default ^ Comment ^\n"
2013-10-17 20:47:15 -03:00
for param in group.GetParams():
code = param.GetFieldValue("code")
name = param.GetFieldValue("short_desc")
min_val = param.GetFieldValue("min")
max_val = param.GetFieldValue("max")
def_val = param.GetFieldValue("default")
long_desc = param.GetFieldValue("long_desc")
name = name.replace("\n", " ")
result += "| %s | %s |" % (code, name)
2013-10-17 20:47:15 -03:00
if min_val is not None:
result += " %s |" % min_val
2014-01-13 03:33:25 -04:00
else:
result += " |"
2013-10-17 20:47:15 -03:00
if max_val is not None:
result += " %s |" % max_val
2014-01-13 03:33:25 -04:00
else:
result += " |"
2013-10-17 20:47:15 -03:00
if def_val is not None:
result += " %s |" % def_val
2014-01-13 03:33:25 -04:00
else:
result += " |"
2014-01-13 03:33:25 -04:00
if long_desc is not None:
long_desc = long_desc.replace("\n", " ")
result += " %s |" % long_desc
2014-01-13 03:33:25 -04:00
else:
result += " |"
result += "\n"
2014-01-13 03:33:25 -04:00
result += "\n"
post_text = """</string>
</value>
</param>
<param>
<value>
<name>sum</name>
<string>Updated parameters automagically from code.</string>
</value>
</param>
</params>
</methodCall>"""
return pre_text + escape(result) + post_text