mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
px_process_airframes: add image path as optional argument for markdown output
usage: ./px_process_airframes.py -m -i ../image/path
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
from xml.sax.saxutils import escape
|
from xml.sax.saxutils import escape
|
||||||
import codecs
|
import codecs
|
||||||
|
import os
|
||||||
|
|
||||||
class MarkdownTablesOutput():
|
class MarkdownTablesOutput():
|
||||||
def __init__(self, groups, board):
|
def __init__(self, groups, board, image_path):
|
||||||
result = ("# Airframes Reference\n"
|
result = ("# Airframes Reference\n"
|
||||||
"> **Note** **This list is auto-generated from the source code**.\n"
|
"> **Note** **This list is auto-generated from the source code**.\n"
|
||||||
"> \n"
|
"> \n"
|
||||||
@@ -28,7 +29,8 @@ class MarkdownTablesOutput():
|
|||||||
image_name = group.GetImageName()
|
image_name = group.GetImageName()
|
||||||
result += '<div>\n'
|
result += '<div>\n'
|
||||||
if image_name != 'AirframeUnknown':
|
if image_name != 'AirframeUnknown':
|
||||||
result += '<img src="../../assets/airframes/types/%s.svg" width="29%%" style="max-height: 180px;"/>\n' % (image_name)
|
image_name = os.path.join(image_path, image_name)
|
||||||
|
result += '<img src="%s.svg" width="29%%" style="max-height: 180px;"/>\n' % (image_name)
|
||||||
|
|
||||||
# check if all outputs are equal for the group: if so, show them
|
# check if all outputs are equal for the group: if so, show them
|
||||||
# only once
|
# only once
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
# Copyright (C) 2013-2015 PX4 Development Team. All rights reserved.
|
# Copyright (C) 2013-2017 PX4 Development Team. All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
@@ -35,10 +35,11 @@
|
|||||||
#
|
#
|
||||||
# PX4 airframe config processor (main executable file)
|
# PX4 airframe config processor (main executable file)
|
||||||
#
|
#
|
||||||
# This tool scans the PX4 source code for declarations of airframes
|
# This tool scans the PX4 ROMFS code for declarations of airframes
|
||||||
#
|
#
|
||||||
# Currently supported formats are:
|
# Currently supported formats are:
|
||||||
# * XML for the parametric UI generator
|
# * XML for the parametric UI generator
|
||||||
|
# * Markdown for the PX4 dev guide (https://github.com/PX4/Devguide)
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
@@ -67,6 +68,12 @@ def main():
|
|||||||
metavar="FILENAME",
|
metavar="FILENAME",
|
||||||
help="Create Markdown file"
|
help="Create Markdown file"
|
||||||
" (default FILENAME: airframes_reference.md)")
|
" (default FILENAME: airframes_reference.md)")
|
||||||
|
default_image_path = '../../assets/airframes/types'
|
||||||
|
parser.add_argument("-i", "--image-path",
|
||||||
|
default=default_image_path,
|
||||||
|
metavar="IMAGEPATH",
|
||||||
|
help="HTML image path for Markdown (containing the airframe svg files)"
|
||||||
|
" (default IMAGEPATH: "+default_image_path+")")
|
||||||
parser.add_argument("-s", "--start-script",
|
parser.add_argument("-s", "--start-script",
|
||||||
nargs='?',
|
nargs='?',
|
||||||
const="rc.autostart",
|
const="rc.autostart",
|
||||||
@@ -108,7 +115,7 @@ def main():
|
|||||||
# Output to markdown file
|
# Output to markdown file
|
||||||
if args.markdown:
|
if args.markdown:
|
||||||
if args.verbose: print("Creating markdown file " + args.markdown)
|
if args.verbose: print("Creating markdown file " + args.markdown)
|
||||||
out = markdownout.MarkdownTablesOutput(param_groups, args.board)
|
out = markdownout.MarkdownTablesOutput(param_groups, args.board, args.image_path)
|
||||||
out.Save(args.markdown)
|
out.Save(args.markdown)
|
||||||
|
|
||||||
if args.start_script:
|
if args.start_script:
|
||||||
|
|||||||
Reference in New Issue
Block a user