2013-05-26 19:25:24 -03:00
|
|
|
#!/usr/bin/env python
|
2016-07-31 07:22:06 -03:00
|
|
|
"""
|
2016-08-01 08:45:07 -03:00
|
|
|
Emit docs in a form acceptable to the old Ardupilot wordpress docs site
|
2016-07-31 07:22:06 -03:00
|
|
|
"""
|
2013-05-26 19:25:24 -03:00
|
|
|
|
2017-05-02 07:36:14 -03:00
|
|
|
from param import known_param_fields, known_units
|
2013-05-26 19:25:24 -03:00
|
|
|
from emit import Emit
|
2013-05-27 10:17:47 -03:00
|
|
|
import cgi
|
2013-05-26 19:25:24 -03:00
|
|
|
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2013-05-26 19:25:24 -03:00
|
|
|
class HtmlEmit(Emit):
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2013-05-26 19:25:24 -03:00
|
|
|
def __init__(self):
|
2016-07-31 07:22:06 -03:00
|
|
|
Emit.__init__(self)
|
2013-05-26 19:25:24 -03:00
|
|
|
html_fname = 'Parameters.html'
|
|
|
|
self.f = open(html_fname, mode='w')
|
2016-07-31 07:22:06 -03:00
|
|
|
self.preamble = """<!-- Dynamically generated list of documented parameters
|
2013-05-26 19:25:24 -03:00
|
|
|
This page was generated using Tools/autotest/param_metadata/param_parse.py
|
|
|
|
|
|
|
|
DO NOT EDIT
|
|
|
|
-->
|
|
|
|
|
2013-05-27 21:11:56 -03:00
|
|
|
|
2013-05-29 23:36:05 -03:00
|
|
|
<h3 style="text-align: center">Complete Parameter List</h3>
|
|
|
|
<hr />
|
2013-05-29 23:19:24 -03:00
|
|
|
|
2013-05-27 21:11:56 -03:00
|
|
|
<p>This is a complete list of the parameters which can be set via the MAVLink protocol in the EEPROM of your APM to control vehicle behaviour. This list is automatically generated from the latest ardupilot source code, and so may contain parameters which are not yet in the stable released versions of the code.</p>
|
|
|
|
|
2013-05-29 23:36:05 -03:00
|
|
|
<!-- add auto-generated table of contents with "Table of Contents Plus" plugin -->
|
|
|
|
[toc exclude="Complete Parameter List"]
|
|
|
|
|
2016-07-31 07:22:06 -03:00
|
|
|
"""
|
2013-05-26 19:25:24 -03:00
|
|
|
self.t = ''
|
|
|
|
|
|
|
|
def escape(self, s):
|
|
|
|
s = s.replace(' ', '-')
|
|
|
|
s = s.replace(':', '-')
|
|
|
|
s = s.replace('(', '')
|
|
|
|
s = s.replace(')', '')
|
|
|
|
return s
|
|
|
|
|
|
|
|
def close(self):
|
|
|
|
self.f.write(self.preamble)
|
|
|
|
self.f.write(self.t)
|
|
|
|
self.f.close()
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2013-05-26 19:25:24 -03:00
|
|
|
def start_libraries(self):
|
2015-06-15 21:01:03 -03:00
|
|
|
pass
|
2016-07-31 07:22:06 -03:00
|
|
|
|
|
|
|
def emit(self, g, f):
|
2013-05-26 19:25:24 -03:00
|
|
|
tag = '%s Parameters' % g.name
|
2016-07-31 07:22:06 -03:00
|
|
|
t = '\n\n<h1>%s</h1>\n' % tag
|
|
|
|
|
2013-05-26 19:25:24 -03:00
|
|
|
for param in g.params:
|
|
|
|
if not hasattr(param, 'DisplayName') or not hasattr(param, 'Description'):
|
|
|
|
continue
|
2013-05-27 21:11:56 -03:00
|
|
|
d = param.__dict__
|
2013-05-26 19:25:24 -03:00
|
|
|
tag = '%s (%s)' % (param.DisplayName, param.name)
|
|
|
|
t += '\n\n<h2>%s</h2>' % tag
|
2016-07-31 07:22:06 -03:00
|
|
|
if d.get('User', None) == 'Advanced':
|
2013-05-27 21:11:56 -03:00
|
|
|
t += '<em>Note: This parameter is for advanced users</em><br>'
|
2013-05-27 10:17:47 -03:00
|
|
|
t += "\n\n<p>%s</p>\n" % cgi.escape(param.Description)
|
2013-05-26 19:25:24 -03:00
|
|
|
t += "<ul>\n"
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2013-05-26 19:25:24 -03:00
|
|
|
for field in param.__dict__.keys():
|
|
|
|
if field not in ['name', 'DisplayName', 'Description', 'User'] and field in known_param_fields:
|
|
|
|
if field == 'Values' and Emit.prog_values_field.match(param.__dict__[field]):
|
|
|
|
values = (param.__dict__[field]).split(',')
|
|
|
|
t += "<table><th>Value</th><th>Meaning</th>\n"
|
|
|
|
for value in values:
|
|
|
|
v = value.split(':')
|
2018-03-25 22:35:13 -03:00
|
|
|
if len(v) != 2:
|
|
|
|
raise ValueError("Bad value (%s)" % v)
|
2013-05-26 19:25:24 -03:00
|
|
|
t += "<tr><td>%s</td><td>%s</td></tr>\n" % (v[0], v[1])
|
|
|
|
t += "</table>\n"
|
2017-05-02 07:36:14 -03:00
|
|
|
elif field == 'Units':
|
|
|
|
abreviated_units = param.__dict__[field]
|
|
|
|
if abreviated_units != '':
|
|
|
|
units = known_units[abreviated_units] # use the known_units dictionary to convert the abreviated unit into a full textual one
|
|
|
|
t += "<li>%s: %s</li>\n" % (field, cgi.escape(units))
|
2013-05-26 19:25:24 -03:00
|
|
|
else:
|
2013-05-27 10:17:47 -03:00
|
|
|
t += "<li>%s: %s</li>\n" % (field, cgi.escape(param.__dict__[field]))
|
2013-05-26 19:25:24 -03:00
|
|
|
t += "</ul>\n"
|
|
|
|
self.t += t
|