Browse Source

Tools: param_parse: rejig selection of emitters

c415-sdk
Peter Barker 4 years ago committed by Peter Barker
parent
commit
5a927d84c8
  1. 3
      Tools/autotest/param_metadata/emit.py
  2. 59
      Tools/autotest/param_metadata/param_parse.py
  3. 10
      Tools/autotest/param_metadata/rstemit.py

3
Tools/autotest/param_metadata/emit.py

@ -20,6 +20,3 @@ class Emit: @@ -20,6 +20,3 @@ class Emit:
def emit(self, g):
pass
def set_annotate_with_vehicle(self, value):
self.annotate_with_vehicle = value

59
Tools/autotest/param_metadata/param_parse.py

@ -395,9 +395,38 @@ for library in libraries: @@ -395,9 +395,38 @@ for library in libraries:
for param in library.params:
validate(param)
if not args.emit_params:
sys.exit(error_count)
all_emitters = {
'json': JSONEmit,
'xml': XmlEmit,
'html': HtmlEmit,
'rst': RSTEmit,
'md': MDEmit,
'xml_mp': XmlEmitMP,
}
try:
from ednemit import EDNEmit
all_emitters['edn'] = EDNEmit
except ImportError:
# if the user wanted edn only then don't hide any errors
if args.output_format == 'edn':
raise
if args.verbose:
print("Unable to emit EDN, install edn_format and pytz if edn is desired")
def do_emit(emit):
emit.set_annotate_with_vehicle(len(vehicles) > 1)
# filter to just the ones we want to emit:
emitters_to_use = []
for emitter_name in all_emitters.keys():
if args.output_format == 'all' or args.output_format == emitter_name:
emitters_to_use.append(emitter_name)
# actually invoke each emiiter:
for emitter_name in emitters_to_use:
emit = all_emitters[emitter_name]()
for vehicle in vehicles:
emit.emit(vehicle)
@ -409,30 +438,4 @@ def do_emit(emit): @@ -409,30 +438,4 @@ def do_emit(emit):
emit.close()
if args.emit_params:
if args.output_format == 'all' or args.output_format == 'json':
do_emit(JSONEmit())
if args.output_format == 'all' or args.output_format == 'xml':
do_emit(XmlEmit())
if args.output_format == 'all' or args.output_format == 'html':
do_emit(HtmlEmit())
if args.output_format == 'all' or args.output_format == 'rst':
do_emit(RSTEmit())
if args.output_format == 'all' or args.output_format == 'md':
do_emit(MDEmit())
if args.output_format == 'all' or args.output_format == 'xml_mp':
do_emit(XmlEmitMP())
if args.output_format == 'all' or args.output_format == 'edn':
try:
from ednemit import EDNEmit
do_emit(EDNEmit())
except ImportError:
# if the user wanted edn only then don't hide any errors
if args.output_format == 'edn':
raise
if args.verbose:
print("Unable to emit EDN, install edn_format and pytz if edn is desired")
sys.exit(error_count)

10
Tools/autotest/param_metadata/rstemit.py

@ -212,10 +212,7 @@ Complete Parameter List @@ -212,10 +212,7 @@ Complete Parameter List
# Get param path if defined (i.e. is duplicate parameter)
param_path = getattr(param, 'path', '')
if self.annotate_with_vehicle:
name = param.name
else:
name = param.name.split(':')[-1]
name = param.name.split(':')[-1]
tag_param_path = ' (%s)' % param_path if param_path else ''
tag = '%s%s: %s' % (self.escape(name), self.escape(tag_param_path), self.escape(param.DisplayName),)
@ -223,10 +220,7 @@ Complete Parameter List @@ -223,10 +220,7 @@ Complete Parameter List
tag = tag.strip()
reference = param.name
# remove e.g. "ArduPlane:" from start of parameter name:
if self.annotate_with_vehicle:
reference = g.name + "_" + reference.split(":")[-1]
else:
reference = reference.split(":")[-1]
reference = reference.split(":")[-1]
if param_path:
reference += '__' + param_path

Loading…
Cancel
Save