Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module_formatter can output lists of files to process (.rst and .tex) #1169

Merged
merged 1 commit into from
Sep 30, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions hacking/module_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -230,24 +235,38 @@ 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
env.filters['fmt'] = rst_fmt
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):
Expand All @@ -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)

Expand Down