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