Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/Tools/autotest/param_metadata/htmlemit.py
Views: 1799
"""1Emit docs in a form acceptable to the old Ardupilot wordpress docs site2"""34from param import known_param_fields, known_units5from emit import Emit6try:7from cgi import escape as cescape8except Exception:9from html import escape as cescape101112class HtmlEmit(Emit):1314def __init__(self, *args, **kwargs):15Emit.__init__(self, *args, **kwargs)16html_fname = 'Parameters.html'17self.f = open(html_fname, mode='w')18self.preamble = """<!-- Dynamically generated list of documented parameters19This page was generated using Tools/autotest/param_metadata/param_parse.py2021DO NOT EDIT22-->232425<h3 style="text-align: center">Complete Parameter List</h3>26<hr />2728<p>This is a complete list of the parameters which can be set via the MAVLink protocol in the EEPROM of your autopilot 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>2930<!-- add auto-generated table of contents with "Table of Contents Plus" plugin -->31[toc exclude="Complete Parameter List"]3233"""34self.t = ''3536def escape(self, s):37s = s.replace(' ', '-')38s = s.replace(':', '-')39s = s.replace('(', '')40s = s.replace(')', '')41return s4243def close(self):44self.f.write(self.preamble)45self.f.write(self.t)46self.f.close()4748def start_libraries(self):49pass5051def emit(self, g):52tag = '%s Parameters' % g.reference53t = '\n\n<h1>%s</h1>\n' % tag5455for param in g.params:56if not hasattr(param, 'DisplayName') or not hasattr(param, 'Description'):57continue58d = param.__dict__59tag = '%s (%s)' % (param.DisplayName, param.name)60t += '\n\n<h2>%s</h2>' % tag61if d.get('User', None) == 'Advanced':62t += '<em>Note: This parameter is for advanced users</em><br>'63t += "\n\n<p>%s</p>\n" % cescape(param.Description)64t += "<ul>\n"6566for field in param.__dict__.keys():67if not self.should_emit_field(param, field):68continue69if field not in ['name', 'DisplayName', 'Description', 'User', 'SortValues'] and field in known_param_fields:70if field == 'Values' and Emit.prog_values_field.match(param.__dict__[field]):71values = (param.__dict__[field]).split(',')72t += "<table><th>Value</th><th>Meaning</th>\n"73for value in values:74v = value.split(':')75if len(v) != 2:76raise ValueError("Bad value (%s)" % v)77t += "<tr><td>%s</td><td>%s</td></tr>\n" % (v[0], v[1])78t += "</table>\n"79elif field == 'Units':80abreviated_units = param.__dict__[field]81if abreviated_units != '':82units = known_units[abreviated_units] # use the known_units dictionary to convert the abreviated unit into a full textual one83t += "<li>%s: %s</li>\n" % (field, cescape(units))84else:85t += "<li>%s: %s</li>\n" % (field, cescape(param.__dict__[field]))86t += "</ul>\n"87self.t += t888990