コード例 #1
0
def main():
    # Parse command line arguments
    parser = argparse.ArgumentParser(description="Process airframe documentation.")
    parser.add_argument("-a", "--airframes-path",
                        default="../ROMFS/px4fmu_common",
                        metavar="PATH",
                        help="path to source files to scan for parameters")
    parser.add_argument("-x", "--xml",
                        nargs='?',
                        const="airframes.xml",
                        metavar="FILENAME",
                        help="Create XML file"
                             " (default FILENAME: airframes.xml)")
    parser.add_argument("-s", "--start-script",
                        nargs='?',
                        const="rc.autostart",
                        metavar="FILENAME",
                        help="Create start script file")
    parser.add_argument("-b", "--board",
                         nargs='?',
                         const="",
                         metavar="BOARD",
                         help="Board to create airframes xml for")
    parser.add_argument("-v", "--verbose", help="verbose output")
    args = parser.parse_args()

    # Check for valid command
    if not (args.xml) and not (args.start_script):
        print("Error: You need to specify at least one output method!\n")
        parser.print_usage()
        sys.exit(1)

    # Initialize source scanner and parser
    scanner = srcscanner.SourceScanner()
    parser = srcparser.SourceParser()

    # Scan directories, and parse the files
    if args.verbose: print("Scanning source path " + args.airframes_path)
    if not scanner.ScanDir(args.airframes_path, parser):
        sys.exit(1)
    # We can't validate yet
    # if not parser.Validate():
    #     sys.exit(1)
    param_groups = parser.GetParamGroups()

    # Output to XML file
    if args.xml:
        if args.verbose: print("Creating XML file " + args.xml)
        out = xmlout.XMLOutput(param_groups, args.board)
        out.Save(args.xml)

    if args.start_script:
        if args.verbose: print("Creating start script " + args.start_script)
        out = rcout.RCOutput(param_groups, args.board)
        out.Save(args.start_script)

    if (args.verbose): print("All done!")
コード例 #2
0
def main():
    # Parse command line arguments
    parser = argparse.ArgumentParser(
        description="Process airframe documentation.")
    parser.add_argument("-a",
                        "--airframes-path",
                        default="../ROMFS/px4fmu_common",
                        metavar="PATH",
                        help="path to source files to scan for parameters")
    parser.add_argument("-x",
                        "--xml",
                        nargs='?',
                        const="airframes.xml",
                        metavar="FILENAME",
                        help="Create XML file"
                        " (default FILENAME: airframes.xml)")
    parser.add_argument("-m",
                        "--markdown",
                        nargs='?',
                        const="airframe_reference.md",
                        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",
                        metavar="FILENAME",
                        help="Create start script file")
    parser.add_argument("-b",
                        "--board",
                        nargs='?',
                        const="",
                        metavar="BOARD",
                        help="Board to create airframes xml for")
    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        help="verbose output")
    args = parser.parse_args()

    # Check for valid command
    if not (args.xml) and not (args.start_script) and not args.markdown:
        print("Error: You need to specify at least one output method!\n")
        parser.print_usage()
        sys.exit(1)

    # Initialize source scanner and parser
    scanner = srcscanner.SourceScanner()
    parser = srcparser.SourceParser()

    # Scan directories, and parse the files
    if args.verbose: print("Scanning source path " + args.airframes_path)
    if not scanner.ScanDir(args.airframes_path, parser):
        sys.exit(1)
    # We can't validate yet
    # if not parser.Validate():
    #     sys.exit(1)
    param_groups = parser.GetParamGroups()

    # Output to XML file
    if args.xml:
        if args.verbose: print("Creating XML file " + args.xml)
        out = xmlout.XMLOutput(param_groups, args.board)
        out.Save(args.xml)

    # Output to markdown file
    if args.markdown:
        if args.verbose: print("Creating markdown file " + args.markdown)
        out = markdownout.MarkdownTablesOutput(param_groups, args.board,
                                               args.image_path)
        out.Save(args.markdown)

    if args.start_script:
        if args.verbose: print("Creating start script " + args.start_script)
        out = rcout.RCOutput(param_groups, args.board)
        out.Save(args.start_script)

    if (args.verbose): print("All done!")