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