mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Updating the module formatter to deal with the new repo structure.
This commit is contained in:
parent
e5116d2f9b
commit
bceb0026a5
4 changed files with 15 additions and 10 deletions
4
Makefile
4
Makefile
|
@ -91,7 +91,7 @@ NOSETESTS ?= nosetests
|
||||||
all: clean python
|
all: clean python
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
PYTHONPATH=./lib ANSIBLE_LIBRARY=./library $(NOSETESTS) -d -w test/units -v
|
PYTHONPATH=./lib ANSIBLE_LIBRARY=./lib/ansible/modules $(NOSETESTS) -d -w test/units -v
|
||||||
|
|
||||||
authors:
|
authors:
|
||||||
sh hacking/authors.sh
|
sh hacking/authors.sh
|
||||||
|
@ -114,7 +114,7 @@ pep8:
|
||||||
@echo "# Running PEP8 Compliance Tests"
|
@echo "# Running PEP8 Compliance Tests"
|
||||||
@echo "#############################################"
|
@echo "#############################################"
|
||||||
-pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225,E261,E241 lib/ bin/
|
-pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225,E261,E241 lib/ bin/
|
||||||
-pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225,E261,E241 --filename "*" library/
|
# -pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225,E261,E241 --filename "*" library/
|
||||||
|
|
||||||
pyflakes:
|
pyflakes:
|
||||||
pyflakes lib/ansible/*.py lib/ansible/*/*.py bin/*
|
pyflakes lib/ansible/*.py lib/ansible/*/*.py bin/*
|
||||||
|
|
|
@ -40,7 +40,7 @@ clean:
|
||||||
.PHONEY: docs clean
|
.PHONEY: docs clean
|
||||||
|
|
||||||
modules: $(FORMATTER) ../hacking/templates/rst.j2
|
modules: $(FORMATTER) ../hacking/templates/rst.j2
|
||||||
PYTHONPATH=../lib $(FORMATTER) -t rst --template-dir=../hacking/templates --module-dir=../library -o rst/
|
PYTHONPATH=../lib $(FORMATTER) -t rst --template-dir=../hacking/templates --module-dir=../lib/ansible/modules -o rst/
|
||||||
|
|
||||||
staticmin:
|
staticmin:
|
||||||
cat _themes/srtd/static/css/theme.css | sed -e 's/^[ \t]*//g; s/[ \t]*$$//g; s/\([:{;,]\) /\1/g; s/ {/{/g; s/\/\*.*\*\///g; /^$$/d' | sed -e :a -e '$$!N; s/\n\(.\)/\1/; ta' > _themes/srtd/static/css/theme.min.css
|
cat _themes/srtd/static/css/theme.css | sed -e 's/^[ \t]*//g; s/[ \t]*$$//g; s/\([:{;,]\) /\1/g; s/ {/{/g; s/\/\*.*\*\///g; /^$$/d' | sed -e :a -e '$$!N; s/\n\(.\)/\1/; ta' > _themes/srtd/static/css/theme.min.css
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# (c) 2012, Jan-Piet Mens <jpmens () gmail.com>
|
# (c) 2012, Jan-Piet Mens <jpmens () gmail.com>
|
||||||
|
# (c) 2012-2014, Michael DeHaan <michael@ansible.com> and others
|
||||||
#
|
#
|
||||||
# This file is part of Ansible
|
# This file is part of Ansible
|
||||||
#
|
#
|
||||||
|
@ -44,7 +45,7 @@ TO_OLD_TO_BE_NOTABLE = 1.0
|
||||||
|
|
||||||
# Get parent directory of the directory this script lives in
|
# Get parent directory of the directory this script lives in
|
||||||
MODULEDIR=os.path.abspath(os.path.join(
|
MODULEDIR=os.path.abspath(os.path.join(
|
||||||
os.path.dirname(os.path.realpath(__file__)), os.pardir, 'library'
|
os.path.dirname(os.path.realpath(__file__)), os.pardir, 'lib', 'ansible', 'modules'
|
||||||
))
|
))
|
||||||
|
|
||||||
# The name of the DOCUMENTATION template
|
# The name of the DOCUMENTATION template
|
||||||
|
@ -106,7 +107,9 @@ def write_data(text, options, outputname, module):
|
||||||
''' dumps module output to a file or the screen, as requested '''
|
''' dumps module output to a file or the screen, as requested '''
|
||||||
|
|
||||||
if options.output_dir is not None:
|
if options.output_dir is not None:
|
||||||
f = open(os.path.join(options.output_dir, outputname % module), 'w')
|
fname = os.path.join(options.output_dir, outputname % module)
|
||||||
|
fname = fname.replace(".py","")
|
||||||
|
f = open(fname, 'w')
|
||||||
f.write(text.encode('utf-8'))
|
f.write(text.encode('utf-8'))
|
||||||
f.close()
|
f.close()
|
||||||
else:
|
else:
|
||||||
|
@ -114,23 +117,24 @@ def write_data(text, options, outputname, module):
|
||||||
|
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
|
|
||||||
|
|
||||||
def list_modules(module_dir):
|
def list_modules(module_dir):
|
||||||
''' returns a hash of categories, each category being a hash of module names to file paths '''
|
''' returns a hash of categories, each category being a hash of module names to file paths '''
|
||||||
|
|
||||||
categories = dict(all=dict())
|
categories = dict(all=dict())
|
||||||
files = glob.glob("%s/*" % module_dir)
|
files = glob.glob("%s/*/*" % module_dir)
|
||||||
for d in files:
|
for d in files:
|
||||||
if os.path.isdir(d):
|
if os.path.isdir(d):
|
||||||
files2 = glob.glob("%s/*" % d)
|
files2 = glob.glob("%s/*" % d)
|
||||||
for f in files2:
|
for f in files2:
|
||||||
|
|
||||||
if f.endswith(".ps1"):
|
if not f.endswith(".py") or f.endswith('__init__.py'):
|
||||||
# windows powershell modules have documentation stubs in python docstring
|
# windows powershell modules have documentation stubs in python docstring
|
||||||
# format (they are not executed) so skip the ps1 format files
|
# format (they are not executed) so skip the ps1 format files
|
||||||
continue
|
continue
|
||||||
|
|
||||||
tokens = f.split("/")
|
tokens = f.split("/")
|
||||||
module = tokens[-1]
|
module = tokens[-1].replace(".py","")
|
||||||
category = tokens[-2]
|
category = tokens[-2]
|
||||||
if not category in categories:
|
if not category in categories:
|
||||||
categories[category] = {}
|
categories[category] = {}
|
||||||
|
@ -191,7 +195,7 @@ def process_module(module, options, env, template, outputname, module_map):
|
||||||
fname = module_map[module]
|
fname = module_map[module]
|
||||||
|
|
||||||
# ignore files with extensions
|
# ignore files with extensions
|
||||||
if "." in os.path.basename(fname):
|
if not os.path.basename(fname).endswith(".py"):
|
||||||
return
|
return
|
||||||
|
|
||||||
# use ansible core library to parse out doc metadata YAML and plaintext examples
|
# use ansible core library to parse out doc metadata YAML and plaintext examples
|
||||||
|
@ -201,6 +205,7 @@ def process_module(module, options, env, template, outputname, module_map):
|
||||||
if doc is None and module not in ansible.utils.module_docs.BLACKLIST_MODULES:
|
if doc is None and module not in ansible.utils.module_docs.BLACKLIST_MODULES:
|
||||||
sys.stderr.write("*** ERROR: CORE MODULE MISSING DOCUMENTATION: %s, %s ***\n" % (fname, module))
|
sys.stderr.write("*** ERROR: CORE MODULE MISSING DOCUMENTATION: %s, %s ***\n" % (fname, module))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if doc is None:
|
if doc is None:
|
||||||
return "SKIPPED"
|
return "SKIPPED"
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 385a037cd6bc42fc64e387973c0e7ef539b04df7
|
Subproject commit 617a52b20d512a4eb5e88fdc76658b220ff80266
|
Loading…
Add table
Reference in a new issue