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_md.py
Views: 1799
1
import os
2
import time
3
import emitter
4
5
class MDEmitter(emitter.Emitter):
6
def preface(self):
7
if os.getenv('BRDOC') is not None:
8
now = time.strftime('%Y-%m-%dT%H:%M:%S%z')
9
now = now[:-2] + ':' + now[-2:]
10
return '\n'.join((
11
'+++',
12
'title = "Onboard Log Messages"',
13
'description = "Message listing for DataFlash autopilot logs."',
14
f'date = {now}',
15
'template = "docs/page.html"',
16
'sort_by = "weight"',
17
'weight = 30',
18
'draft = false',
19
'[extra]',
20
'toc = true',
21
'top = false',
22
'+++\n',
23
'<!-- Dynamically generated using Tools/autotest/logger_metadata/parse.py',
24
'DO NOT EDIT -->',
25
'This is a list of log messages which may be present in DataFlash (`.bin`) '
26
'logs produced and stored onboard ArduSub vehicles (see [Log Parameters]'
27
'(../parameters/#log-parameters) for creation details). '
28
'It is possible to [add a new message]'
29
'(https://ardupilot.org/dev/docs/code-overview-adding-a-new-log-message.html) '
30
'by modifying the firmware.\n',
31
'DataFlash logs can be downloaded and analysed '
32
'[from a computer](http://www.ardusub.com/reference/data-logging.html#downloading) '
33
'or [through BlueOS]'
34
'(@/software/onboard/BlueOS-1.1/advanced-usage/index.md#log-browser).\n'
35
))
36
37
return """<!-- Dynamically generated list of Logger Messages
38
This page was generated using Tools/autotest/logger_metdata/parse.py
39
40
DO NOT EDIT
41
-->
42
43
44
<h3 style="text-align: center">Onboard Message Log Messages</h3>
45
<hr />
46
47
<p>This is a list of log messages which may be present in logs produced and stored onboard ArduPilot vehicles.</p>
48
49
<!-- add auto-generated table of contents with "Table of Contents Plus" plugin -->
50
[toc exclude="Onboard Message Log Messages"]
51
52
"""
53
def postface(self):
54
return ""
55
56
def start(self):
57
self.fh = open("LogMessages.md", mode='w')
58
print(self.preface(), file=self.fh)
59
60
def emit(self, doccos, enumerations=None):
61
self.start()
62
for docco in doccos:
63
print(f'## {docco.name}', file=self.fh)
64
desc = ''
65
if docco.description is not None:
66
desc += docco.description
67
if docco.url is not None:
68
desc += f' ([Read more...]({docco.url}))'
69
print(desc, file=self.fh)
70
print("\n|FieldName|Units/Type|Description|\n|---|---|---|", file=self.fh)
71
for f in docco.fields_order:
72
if "description" in docco.fields[f]:
73
fdesc = docco.fields[f]["description"]
74
else:
75
fdesc = ""
76
if "units" in docco.fields[f] and docco.fields[f]["units"]!="":
77
ftypeunits = docco.fields[f]["units"]
78
elif "fmt" in docco.fields[f] and "char" in docco.fields[f]["fmt"]:
79
ftypeunits = docco.fields[f]["fmt"]
80
elif "bitmaskenum" in docco.fields[f]:
81
ftypeunits = "bitmask"
82
elif "valueenum" in docco.fields[f]:
83
ftypeunits = "enum"
84
else:
85
ftypeunits = ""
86
print(f'|{f}|{ftypeunits}|{fdesc}|', file=self.fh)
87
print("", file=self.fh)
88
self.stop()
89
90
def stop(self):
91
print(self.postface(), file=self.fh)
92
self.fh.close()
93
94