From 41e53ef9493b04a91fe4c955acd9de1a8206072c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 2 May 2017 15:56:12 +0200 Subject: [PATCH] px_process_airframes: add image path as optional argument for markdown output usage: ./px_process_airframes.py -m -i ../image/path --- Tools/px4airframes/markdownout.py | 6 ++++-- Tools/px_process_airframes.py | 13 ++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Tools/px4airframes/markdownout.py b/Tools/px4airframes/markdownout.py index e48f078c66..8903d4e6d0 100644 --- a/Tools/px4airframes/markdownout.py +++ b/Tools/px4airframes/markdownout.py @@ -1,8 +1,9 @@ from xml.sax.saxutils import escape import codecs +import os class MarkdownTablesOutput(): - def __init__(self, groups, board): + def __init__(self, groups, board, image_path): result = ("# Airframes Reference\n" "> **Note** **This list is auto-generated from the source code**.\n" "> \n" @@ -28,7 +29,8 @@ class MarkdownTablesOutput(): image_name = group.GetImageName() result += '
\n' if image_name != 'AirframeUnknown': - result += '\n' % (image_name) + image_name = os.path.join(image_path, image_name) + result += '\n' % (image_name) # check if all outputs are equal for the group: if so, show them # only once diff --git a/Tools/px_process_airframes.py b/Tools/px_process_airframes.py index 4f3c74bea4..1adf977fa8 100755 --- a/Tools/px_process_airframes.py +++ b/Tools/px_process_airframes.py @@ -1,7 +1,7 @@ #!/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 # modification, are permitted provided that the following conditions @@ -35,10 +35,11 @@ # # 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: # * 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", help="Create Markdown file" " (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", nargs='?', const="rc.autostart", @@ -108,7 +115,7 @@ def main(): # Output to markdown file if 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) if args.start_script: