diff --git a/hacking/module_formatter.py b/hacking/module_formatter.py index daac30a5a12..e89540f384c 100755 --- a/hacking/module_formatter.py +++ b/hacking/module_formatter.py @@ -191,6 +191,11 @@ def main(): dest="output_dir", default=None, help="Output directory for module files") + p.add_argument("-I", "--includes-file", + action="store", + dest="includes_file", + default=None, + help="Create a file containing list of processed modules") p.add_argument("-G", "--generate", action="store_true", dest="do_boilerplate", @@ -230,14 +235,20 @@ def main(): env.filters['jpfunc'] = latex_ify template = env.get_template('latex.j2') outputname = "%s.tex" + includecmt = "% generated code\n" + includefmt = "\\input %s\n" if args.type == 'html': env.filters['jpfunc'] = html_ify template = env.get_template('html.j2') outputname = "%s.html" + includecmt = "" + includefmt = "" if args.type == 'man': env.filters['jpfunc'] = man_ify template = env.get_template('man.j2') outputname = "ansible.%s.man" + includecmt = "" + includefmt = "" if args.type == 'rst': env.filters['jpfunc'] = rst_ify env.filters['html_ify'] = html_ify @@ -245,9 +256,17 @@ def main(): env.filters['xline'] = rst_xline template = env.get_template('rst.j2') outputname = "%s.rst" + includecmt = ".. Generated by module_formatter\n" + includefmt = ".. include:: %s.rst\n" if args.type == 'json': env.filters['jpfunc'] = json_ify outputname = "%s.json" + includecmt = "" + includefmt = "" + + if args.includes_file is not None and includefmt != "": + incfile = open(args.includes_file, "w") + incfile.write(includecmt) for module in os.listdir(args.module_dir): if len(args.module_list): @@ -270,6 +289,9 @@ def main(): doc['now_date'] = datetime.date.today().strftime('%Y-%m-%d') doc['ansible_version'] = args.ansible_version + if args.includes_file is not None and includefmt != "": + incfile.write(includefmt % module) + if args.verbose: print json.dumps(doc, indent=4)