|
|
@ -25,7 +25,7 @@ import json
|
|
|
|
import ast
|
|
|
|
import ast
|
|
|
|
from jinja2 import Environment, FileSystemLoader
|
|
|
|
from jinja2 import Environment, FileSystemLoader
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
import argparse
|
|
|
|
import getopt
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
import datetime
|
|
|
|
import datetime
|
|
|
|
import subprocess
|
|
|
|
import subprocess
|
|
|
@ -174,58 +174,72 @@ def return_data(text, args, outputname, module):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
|
|
|
|
class Object(object):
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type_choices = ['html', 'latex', 'man', 'rst', 'json']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args = Object()
|
|
|
|
|
|
|
|
args.ansible_version = 'unknown'
|
|
|
|
|
|
|
|
args.module_dir = MODULEDIR
|
|
|
|
|
|
|
|
args.template_dir = 'hacking/templates'
|
|
|
|
|
|
|
|
args.type = 'latex'
|
|
|
|
|
|
|
|
args.module_list = []
|
|
|
|
|
|
|
|
args.verbose = False
|
|
|
|
|
|
|
|
args.output_dir = None
|
|
|
|
|
|
|
|
args.includes_file = None
|
|
|
|
|
|
|
|
args.do_boilerplate = False
|
|
|
|
|
|
|
|
|
|
|
|
p = argparse.ArgumentParser(description="Convert Ansible module DOCUMENTATION strings to other formats")
|
|
|
|
try:
|
|
|
|
|
|
|
|
opts, arguments = getopt.getopt(sys.argv[1:], 'A:M:T:t:m:vo:I:GVh',
|
|
|
|
p.add_argument("-A", "--ansible-version",
|
|
|
|
[ 'ansible-version=', 'module-dir=', 'template-dir=', 'type=',
|
|
|
|
action="store",
|
|
|
|
'module=', 'verbose', 'output-dir=', 'includes-file=',
|
|
|
|
dest="ansible_version",
|
|
|
|
'generate', 'version', 'help', ])
|
|
|
|
default="unknown",
|
|
|
|
except getopt.error, e:
|
|
|
|
help="Ansible version number")
|
|
|
|
print >>sys.stderr, 'ERROR: %s'% str(e)
|
|
|
|
p.add_argument("-M", "--module-dir",
|
|
|
|
sys.exit(1)
|
|
|
|
action="store",
|
|
|
|
|
|
|
|
dest="module_dir",
|
|
|
|
for opt, arg in opts:
|
|
|
|
default=MODULEDIR,
|
|
|
|
if opt in ('-A', '--ansible-version'):
|
|
|
|
help="Ansible modules/ directory")
|
|
|
|
args.ansible_version = arg
|
|
|
|
p.add_argument("-T", "--template-dir",
|
|
|
|
elif opt in ('-M', '--module-dir'):
|
|
|
|
action="store",
|
|
|
|
args.module_dir = arg
|
|
|
|
dest="template_dir",
|
|
|
|
elif opt in ('-T', '--template-dir'):
|
|
|
|
default="hacking/templates",
|
|
|
|
args.template_dir = arg
|
|
|
|
help="directory containing Jinja2 templates")
|
|
|
|
elif opt in ('-t', '--type'):
|
|
|
|
p.add_argument("-t", "--type",
|
|
|
|
args.type = arg
|
|
|
|
action='store',
|
|
|
|
if args.type not in type_choices:
|
|
|
|
dest='type',
|
|
|
|
print >>sys.stderr, 'ERROR: Type %s not in possible types %s.' % (args.type, type_choices)
|
|
|
|
choices=['html', 'latex', 'man', 'rst', 'json', 'js'],
|
|
|
|
sys.exit(1)
|
|
|
|
default='latex',
|
|
|
|
elif opt in ('-m', '--module'):
|
|
|
|
help="Output type")
|
|
|
|
args.module_list.append(arg)
|
|
|
|
p.add_argument("-m", "--module",
|
|
|
|
elif opt in ('-v', '--verbose'):
|
|
|
|
action='append',
|
|
|
|
args.verbose = True
|
|
|
|
default=[],
|
|
|
|
elif opt in ('-o', '--output-dir'):
|
|
|
|
dest='module_list',
|
|
|
|
args.output_dir = arg
|
|
|
|
help="Add modules to process in module_dir")
|
|
|
|
elif opt in ('-I', '--includes-file'):
|
|
|
|
p.add_argument("-v", "--verbose",
|
|
|
|
args.includes_file = arg
|
|
|
|
action='store_true',
|
|
|
|
elif opt in ('-G', '--generate'):
|
|
|
|
default=False,
|
|
|
|
args.do_boilerplate = True
|
|
|
|
help="Verbose")
|
|
|
|
elif opt in ('-V', '--version'):
|
|
|
|
p.add_argument("-o", "--output-dir",
|
|
|
|
print >>sys.stderr, '%(prog)s 1.0'
|
|
|
|
action="store",
|
|
|
|
elif opt in ('-h', '--help'):
|
|
|
|
dest="output_dir",
|
|
|
|
print >>sys.stderr, '''Convert Ansible module DOCUMENTATION strings to other formats
|
|
|
|
default=None,
|
|
|
|
|
|
|
|
help="Output directory for module files")
|
|
|
|
-A, --ansible-version= Ansible version number
|
|
|
|
p.add_argument("-I", "--includes-file",
|
|
|
|
-M, --module-dir= Ansible modules/ directory
|
|
|
|
action="store",
|
|
|
|
-T, --template-dir= Directory containing Jinja2 templates
|
|
|
|
dest="includes_file",
|
|
|
|
-t, --type= Output type
|
|
|
|
default=None,
|
|
|
|
-m, --module= Add modules to process in module_dir
|
|
|
|
help="Create a file containing list of processed modules")
|
|
|
|
-v, --verbose Verbose
|
|
|
|
p.add_argument("-G", "--generate",
|
|
|
|
-o, --output-dir= Output directory for module files
|
|
|
|
action="store_true",
|
|
|
|
-I, --includes-file= Create a file containing list of processed modules
|
|
|
|
dest="do_boilerplate",
|
|
|
|
-G, --generate Generate boilerplate DOCUMENTATION to stdout
|
|
|
|
default=False,
|
|
|
|
'''
|
|
|
|
help="generate boilerplate DOCUMENTATION to stdout")
|
|
|
|
sys.exit(0)
|
|
|
|
p.add_argument('-V', '--version', action='version', version='%(prog)s 1.0')
|
|
|
|
else:
|
|
|
|
|
|
|
|
print >>sys.stderr, 'ERROR: Option %s unknown to getopt' % opt
|
|
|
|
module_dir = None
|
|
|
|
sys.exit(1)
|
|
|
|
args = p.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# print "M: %s" % args.module_dir
|
|
|
|
# print "M: %s" % args.module_dir
|
|
|
|
# print "t: %s" % args.type
|
|
|
|
# print "t: %s" % args.type
|
|
|
|