mirror of https://github.com/ArduPilot/ardupilot
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):
|
||||
pass
|
||||
|
||||
def emit(self, g, f):
|
||||
def emit(self, g):
|
||||
for param in g.params:
|
||||
output_dict = dict()
|
||||
# lowercase all keywords
|
||||
|
|
|
@ -18,7 +18,7 @@ class Emit:
|
|||
def start_libraries(self):
|
||||
pass
|
||||
|
||||
def emit(self, g, f):
|
||||
def emit(self, g):
|
||||
pass
|
||||
|
||||
def set_annotate_with_vehicle(self, value):
|
||||
|
|
|
@ -47,7 +47,7 @@ DO NOT EDIT
|
|||
def start_libraries(self):
|
||||
pass
|
||||
|
||||
def emit(self, g, f):
|
||||
def emit(self, g):
|
||||
tag = '%s Parameters' % g.name
|
||||
t = '\n\n<h1>%s</h1>\n' % tag
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class MDEmit(Emit):
|
|||
def start_libraries(self):
|
||||
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_)
|
||||
|
||||
if g.name == 'ArduSub':
|
||||
|
|
|
@ -22,6 +22,12 @@ parser.add_option("--no-emit",
|
|||
action='store_false',
|
||||
default=True,
|
||||
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()
|
||||
|
||||
|
||||
|
@ -318,28 +324,38 @@ for library in libraries:
|
|||
def do_emit(emit):
|
||||
emit.set_annotate_with_vehicle(len(vehicles) > 1)
|
||||
for vehicle in vehicles:
|
||||
emit.emit(vehicle, f)
|
||||
emit.emit(vehicle)
|
||||
|
||||
emit.start_libraries()
|
||||
|
||||
for library in libraries:
|
||||
if library.params:
|
||||
emit.emit(library, f)
|
||||
emit.emit(library)
|
||||
|
||||
emit.close()
|
||||
|
||||
|
||||
if opts.emit_params:
|
||||
do_emit(XmlEmit())
|
||||
do_emit(WikiEmit())
|
||||
do_emit(HtmlEmit())
|
||||
do_emit(RSTEmit())
|
||||
do_emit(MDEmit())
|
||||
try:
|
||||
from ednemit import EDNEmit
|
||||
do_emit(EDNEmit())
|
||||
except ImportError:
|
||||
if opts.verbose:
|
||||
print("Unable to emit EDN, install edn_format and pytz if edn is desired")
|
||||
if opts.output_format == 'all' or opts.output_format == 'xml':
|
||||
do_emit(XmlEmit())
|
||||
if opts.output_format == 'all' or opts.output_format == 'wiki':
|
||||
do_emit(WikiEmit())
|
||||
if opts.output_format == 'all' or opts.output_format == 'html':
|
||||
do_emit(HtmlEmit())
|
||||
if opts.output_format == 'all' or opts.output_format == 'rst':
|
||||
do_emit(RSTEmit())
|
||||
if opts.output_format == 'all' or opts.output_format == 'md':
|
||||
do_emit(MDEmit())
|
||||
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)
|
||||
|
|
|
@ -179,7 +179,7 @@ Complete Parameter List
|
|||
rows.append(v)
|
||||
return self.tablify(rows, headings=render_info["headings"])
|
||||
|
||||
def emit(self, g, f):
|
||||
def emit(self, g):
|
||||
tag = '%s Parameters' % self.escape(g.name)
|
||||
reference = "parameters_" + g.name
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class WikiEmit(Emit):
|
|||
def start_libraries(self):
|
||||
self.emit_comment("Libraries")
|
||||
|
||||
def emit(self, g, f):
|
||||
def emit(self, g):
|
||||
t = "\n\n== %s Parameters ==\n" % (self.camelcase_escape(g.name))
|
||||
|
||||
for param in g.params:
|
||||
|
|
|
@ -31,7 +31,7 @@ class XmlEmit(Emit):
|
|||
self.f.write('</vehicles>')
|
||||
self.f.write('<libraries>')
|
||||
|
||||
def emit(self, g, f):
|
||||
def emit(self, g):
|
||||
t = '''<parameters name=%s>\n''' % quoteattr(g.name) # i.e. ArduPlane
|
||||
|
||||
for param in g.params:
|
||||
|
|
Loading…
Reference in New Issue