mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-09 09:28:31 -04:00
Tools: Allow specifying parameter metadata format
Also removes unneeded passing of a file pointer
This commit is contained in:
parent
681d8416e2
commit
bb7abc2935
@ -32,7 +32,7 @@ class EDNEmit(Emit):
|
|||||||
def start_libraries(self):
|
def start_libraries(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def emit(self, g, f):
|
def emit(self, g):
|
||||||
for param in g.params:
|
for param in g.params:
|
||||||
output_dict = dict()
|
output_dict = dict()
|
||||||
# lowercase all keywords
|
# lowercase all keywords
|
||||||
|
@ -18,7 +18,7 @@ class Emit:
|
|||||||
def start_libraries(self):
|
def start_libraries(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def emit(self, g, f):
|
def emit(self, g):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def set_annotate_with_vehicle(self, value):
|
def set_annotate_with_vehicle(self, value):
|
||||||
|
@ -47,7 +47,7 @@ DO NOT EDIT
|
|||||||
def start_libraries(self):
|
def start_libraries(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def emit(self, g, f):
|
def emit(self, g):
|
||||||
tag = '%s Parameters' % g.name
|
tag = '%s Parameters' % g.name
|
||||||
t = '\n\n<h1>%s</h1>\n' % tag
|
t = '\n\n<h1>%s</h1>\n' % tag
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class MDEmit(Emit):
|
|||||||
def start_libraries(self):
|
def start_libraries(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def emit(self, g, f):
|
def emit(self, g):
|
||||||
nparam = False # Flag indicating this is a parameter group with redundant information (ie RCn_, SERVOn_)
|
nparam = False # Flag indicating this is a parameter group with redundant information (ie RCn_, SERVOn_)
|
||||||
|
|
||||||
if g.name == 'ArduSub':
|
if g.name == 'ArduSub':
|
||||||
|
@ -22,6 +22,12 @@ parser.add_option("--no-emit",
|
|||||||
action='store_false',
|
action='store_false',
|
||||||
default=True,
|
default=True,
|
||||||
help="don't emit parameter documention, just validate")
|
help="don't emit parameter documention, just validate")
|
||||||
|
parser.add_option("--format",
|
||||||
|
dest='output_format',
|
||||||
|
action='store',
|
||||||
|
default='all',
|
||||||
|
choices=['all', 'html', 'rst', 'wiki', 'xml', 'edn', 'md'],
|
||||||
|
help="what output format to use")
|
||||||
(opts, args) = parser.parse_args()
|
(opts, args) = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
@ -318,28 +324,38 @@ for library in libraries:
|
|||||||
def do_emit(emit):
|
def do_emit(emit):
|
||||||
emit.set_annotate_with_vehicle(len(vehicles) > 1)
|
emit.set_annotate_with_vehicle(len(vehicles) > 1)
|
||||||
for vehicle in vehicles:
|
for vehicle in vehicles:
|
||||||
emit.emit(vehicle, f)
|
emit.emit(vehicle)
|
||||||
|
|
||||||
emit.start_libraries()
|
emit.start_libraries()
|
||||||
|
|
||||||
for library in libraries:
|
for library in libraries:
|
||||||
if library.params:
|
if library.params:
|
||||||
emit.emit(library, f)
|
emit.emit(library)
|
||||||
|
|
||||||
emit.close()
|
emit.close()
|
||||||
|
|
||||||
|
|
||||||
if opts.emit_params:
|
if opts.emit_params:
|
||||||
do_emit(XmlEmit())
|
if opts.output_format == 'all' or opts.output_format == 'xml':
|
||||||
do_emit(WikiEmit())
|
do_emit(XmlEmit())
|
||||||
do_emit(HtmlEmit())
|
if opts.output_format == 'all' or opts.output_format == 'wiki':
|
||||||
do_emit(RSTEmit())
|
do_emit(WikiEmit())
|
||||||
do_emit(MDEmit())
|
if opts.output_format == 'all' or opts.output_format == 'html':
|
||||||
try:
|
do_emit(HtmlEmit())
|
||||||
from ednemit import EDNEmit
|
if opts.output_format == 'all' or opts.output_format == 'rst':
|
||||||
do_emit(EDNEmit())
|
do_emit(RSTEmit())
|
||||||
except ImportError:
|
if opts.output_format == 'all' or opts.output_format == 'md':
|
||||||
if opts.verbose:
|
do_emit(MDEmit())
|
||||||
print("Unable to emit EDN, install edn_format and pytz if edn is desired")
|
if opts.output_format == 'all' or opts.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 opts.output_format == 'edn':
|
||||||
|
raise
|
||||||
|
|
||||||
|
if opts.verbose:
|
||||||
|
print("Unable to emit EDN, install edn_format and pytz if edn is desired")
|
||||||
|
|
||||||
sys.exit(error_count)
|
sys.exit(error_count)
|
||||||
|
@ -179,7 +179,7 @@ Complete Parameter List
|
|||||||
rows.append(v)
|
rows.append(v)
|
||||||
return self.tablify(rows, headings=render_info["headings"])
|
return self.tablify(rows, headings=render_info["headings"])
|
||||||
|
|
||||||
def emit(self, g, f):
|
def emit(self, g):
|
||||||
tag = '%s Parameters' % self.escape(g.name)
|
tag = '%s Parameters' % self.escape(g.name)
|
||||||
reference = "parameters_" + g.name
|
reference = "parameters_" + g.name
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class WikiEmit(Emit):
|
|||||||
def start_libraries(self):
|
def start_libraries(self):
|
||||||
self.emit_comment("Libraries")
|
self.emit_comment("Libraries")
|
||||||
|
|
||||||
def emit(self, g, f):
|
def emit(self, g):
|
||||||
t = "\n\n== %s Parameters ==\n" % (self.camelcase_escape(g.name))
|
t = "\n\n== %s Parameters ==\n" % (self.camelcase_escape(g.name))
|
||||||
|
|
||||||
for param in g.params:
|
for param in g.params:
|
||||||
|
@ -31,7 +31,7 @@ class XmlEmit(Emit):
|
|||||||
self.f.write('</vehicles>')
|
self.f.write('</vehicles>')
|
||||||
self.f.write('<libraries>')
|
self.f.write('<libraries>')
|
||||||
|
|
||||||
def emit(self, g, f):
|
def emit(self, g):
|
||||||
t = '''<parameters name=%s>\n''' % quoteattr(g.name) # i.e. ArduPlane
|
t = '''<parameters name=%s>\n''' % quoteattr(g.name) # i.e. ArduPlane
|
||||||
|
|
||||||
for param in g.params:
|
for param in g.params:
|
||||||
|
Loading…
Reference in New Issue
Block a user