Tools: autotest: param_metadata: mdemit: update to new BR docs structure

This commit is contained in:
ES-Alexander 2022-10-24 19:19:37 +11:00 committed by Willian Galvani
parent 682fc07017
commit ca402ffb2e
1 changed files with 23 additions and 8 deletions

View File

@ -5,9 +5,14 @@ Emit parameter documentation in markdown format
from param import known_param_fields
from emit import Emit
import time
import re
import os
# ArduSub documentation uses the page title as the top level heading.
# OFFSET drops headings one level when compiling for those docs.
OFFSET = '#' if os.getenv('BRDOC') else ''
# Parameter groups disabled at compile time (Vehicle-specific)
sub_blacklist = ['AVOID_', 'CIRCLE_', 'FLOW', 'MIS_', 'PRX', 'RALLY_', 'RCMAP_', 'RPM', 'TERRAIN_', 'WPNAV_']
@ -27,7 +32,19 @@ class MDEmit(Emit):
# Flag to generate navigation header for BlueRobotics' ArduSub docs
if os.getenv('BRDOC') is not None:
self.header = """---\nlayout: default\ntitle: "Parameters"\npermalink: /parameters/\nnav:"""
now = time.strftime('%Y-%m-%dT%H:%M:%S%z')
now = now[:-2] + ':' + now[-2:]
self.header = """+++
title = "Parameters"
description = "Firmware parameter details."
date = %s
template = "docs/page.html"
sort_by = "weight"
weight = 10
draft = false
[extra]
toc = true
top = false""" % now
self.preamble = """\nThis 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. Some parameters may only be available for developers, and are enabled at compile-time."""
self.t = ''
@ -36,7 +53,7 @@ class MDEmit(Emit):
# Write navigation header for BlueRobotics' ArduSub docs
if os.getenv('BRDOC') is not None:
self.f.write(self.header)
self.f.write('\n---\n')
self.f.write('\n+++\n')
self.f.write(self.preamble)
self.f.write(self.t)
@ -71,11 +88,7 @@ class MDEmit(Emit):
tag = tag.replace('_', '')
link = tag.replace(' ', '-')
# Add group to navigation header for BlueRobotics' ArduSub docs
if os.getenv('BRDOC') is not None:
self.header += "\n- %s: %s" % (link.split('-')[0],link.lower())
t = '\n\n# %s' % tag
t = '\n\n%s# %s' % (OFFSET, tag)
for param in g.params:
if not hasattr(param, 'DisplayName') or not hasattr(param, 'Description'):
@ -85,7 +98,9 @@ class MDEmit(Emit):
if nparam:
name = re.sub('\d+', 'n', name, 1)
tag = '%s: %s' % (name, param.DisplayName)
t += '\n\n## %s' % tag
t += '\n\n%s## %s' % (OFFSET, tag)
if os.getenv('DIFF'):
continue
if d.get('User', None) == 'Advanced':
t += '\n\n*Note: This parameter is for advanced users*'
t += "\n\n%s" % param.Description