CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/autotest/logger_metadata/emit_html.py
Views: 1799
1
from __future__ import print_function
2
3
import emitter
4
5
class HTMLEmitter(emitter.Emitter):
6
def preface(self):
7
return """<!-- Dynamically generated list of Logger Messages
8
This page was generated using Tools/autotest/logger_metdata/parse.py
9
10
DO NOT EDIT
11
-->
12
13
14
<h3 style="text-align: center">Onboard Message Log Messages</h3>
15
<hr />
16
17
<p>This is a list of log messages which may be present in logs produced and stored onboard ArduPilot vehicles.</p>
18
19
<!-- add auto-generated table of contents with "Table of Contents Plus" plugin -->
20
[toc exclude="Onboard Message Log Messages"]
21
22
"""
23
def postface(self):
24
return ""
25
26
def start(self):
27
self.fh = open("LogMessages.html", mode='w')
28
print(self.preface(), file=self.fh)
29
30
def emit(self, doccos, enumerations):
31
self.start()
32
for docco in doccos:
33
print(' <h1>%s</h1>' % docco.name, file=self.fh)
34
if docco.url is not None:
35
print(' <a href="%s">More information</a>' % docco.url, file=self.fh)
36
if docco.description is not None:
37
print(' <h2>%s</h2>' %
38
docco.description, file=self.fh)
39
print(' <table>', file=self.fh)
40
print(" <tr><th>FieldName</th><th>Units/Type</th><th>Description</th><tr>",
41
file=self.fh)
42
for f in docco.fields_order:
43
if "description" in docco.fields[f]:
44
fdesc = docco.fields[f]["description"]
45
else:
46
fdesc = ""
47
if "units" in docco.fields[f] and docco.fields[f]["units"]!="":
48
ftypeunits = docco.fields[f]["units"]
49
elif "fmt" in docco.fields[f] and "char" in docco.fields[f]["fmt"]:
50
ftypeunits = docco.fields[f]["fmt"]
51
elif "bitmaskenum" in docco.fields[f]:
52
ftypeunits = "bitmask"
53
elif "valueenum" in docco.fields[f]:
54
ftypeunits = "enum"
55
else:
56
ftypeunits = ""
57
print(' <tr><td>%s</td><td>%s</td><td>%s</td></tr>' % (f, ftypeunits, fdesc),
58
file=self.fh)
59
print(' </table>', file=self.fh)
60
61
print("", file=self.fh)
62
self.stop()
63
64
def stop(self):
65
print(self.postface(), file=self.fh)
66
self.fh.close()
67
68