docs: PEP8 compliance (#24681)

- Make PEP8 compliant
pull/25219/head
Dag Wieers 8 years ago committed by John R Barker
parent 44121352fe
commit 47738eb1dd

@ -16,22 +16,21 @@
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
from __future__ import print_function
__metaclass__ = type
import os
import cgi
import datetime
import glob
import sys
import yaml
import re
import optparse
import datetime
import cgi
import os
import re
import sys
import warnings
from collections import defaultdict
import yaml
from collections import defaultdict
from jinja2 import Environment, FileSystemLoader
from six import iteritems
@ -63,7 +62,7 @@ _URL = re.compile(r"U\(([^)]+)\)")
_CONST = re.compile(r"C\(([^)]+)\)")
DEPRECATED = b" (D)"
#####################################################################################
def rst_ify(text):
''' convert symbols like I(this is in italics) to valid restructured text '''
@ -79,7 +78,6 @@ def rst_ify(text):
return t
#####################################################################################
def html_ify(text):
''' convert symbols like I(this is in italics) to valid HTML '''
@ -94,21 +92,17 @@ def html_ify(text):
return t
#####################################################################################
def rst_fmt(text, fmt):
''' helper for Jinja2 to do format strings '''
return fmt % (text)
#####################################################################################
def rst_xline(width, char="="):
''' return a restructured text line of a given length '''
return char * width
#####################################################################################
def write_data(text, options, outputname, module):
''' dumps module output to a file or the screen, as requested '''
@ -122,8 +116,6 @@ def write_data(text, options, outputname, module):
else:
print(text)
#####################################################################################
def list_modules(module_dir, depth=0):
''' returns a hash of categories, each category being a hash of module names to file paths '''
@ -176,7 +168,6 @@ def list_modules(module_dir, depth=0):
return module_info, categories, aliases
#####################################################################################
def generate_parser():
''' generate an optparse parser '''
@ -197,15 +188,13 @@ def generate_parser():
p.add_option('-V', action='version', help='Show version number and exit')
return p
#####################################################################################
def jinja2_environment(template_dir, typ):
env = Environment(loader=FileSystemLoader(template_dir),
variable_start_string="@{",
variable_end_string="}@",
trim_blocks=True,
)
trim_blocks=True)
env.globals['xline'] = rst_xline
if typ == 'rst':
@ -220,7 +209,7 @@ def jinja2_environment(template_dir, typ):
return env, template, outputname
#####################################################################################
def too_old(added):
if not added:
return False
@ -233,6 +222,7 @@ def too_old(added):
return False
return (added_float < TO_OLD_TO_BE_NOTABLE)
def process_module(module, options, env, template, outputname, module_map, aliases):
fname = module_map[module]
@ -271,7 +261,7 @@ def process_module(module, options, env, template, outputname, module_map, alias
all_keys = []
if not 'version_added' in doc:
if 'version_added' not in doc:
sys.exit("*** ERROR: missing version_added in: %s ***\n" % module)
added = 0
@ -289,7 +279,7 @@ def process_module(module, options, env, template, outputname, module_map, alias
# don't show version added information if it's too old to be called out
if 'version_added' in doc['options'][k] and too_old(doc['options'][k]['version_added']):
del doc['options'][k]['version_added']
if not 'description' in doc['options'][k]:
if 'description' not in doc['options'][k]:
raise AnsibleError("Missing required description for option %s in %s " % (k, module))
required_value = doc['options'][k].get('required', False)
@ -328,7 +318,6 @@ def process_module(module, options, env, template, outputname, module_map, alias
write_data(text, options, outputname, module)
return doc['short_description']
#####################################################################################
def print_modules(module, category_file, deprecated, options, env, template, outputname, module_map, aliases):
modstring = module
@ -340,9 +329,10 @@ def print_modules(module, category_file, deprecated, options, env, template, out
category_file.write(b" %s - %s <%s_module>\n" % (to_bytes(modstring), to_bytes(rst_ify(module_map[module][1])), to_bytes(modname)))
def process_category(category, categories, options, env, template, outputname):
### FIXME:
# FIXME:
# We no longer conceptually deal with a mapping of category names to
# modules to file paths. Instead we want several different records:
# (1) Mapping of module names to file paths (what's presently used
@ -424,7 +414,6 @@ def process_category(category, categories, options, env, template, outputname):
# TODO: end a new category file
#####################################################################################
def validate_options(options):
''' validate option parser options '''
@ -436,7 +425,6 @@ def validate_options(options):
if not options.template_dir:
sys.exit("--template-dir must be specified")
#####################################################################################
def main():
@ -465,9 +453,7 @@ def main():
for category in category_names:
category_list_file.write(b" list_of_%s_modules\n" % to_bytes(category))
#
# Import all the docs into memory
#
module_map = mod_info.copy()
for modname in module_map:
@ -477,11 +463,10 @@ def main():
else:
categories['all'][modname] = (categories['all'][modname], result)
#
# Render all the docs to rst via category pages
#
for category in category_names:
process_category(category, categories, options, env, template, outputname)
if __name__ == '__main__':
main()

@ -1,11 +1,6 @@
contrib/inventory/freeipa.py
contrib/inventory/rackhd.py
contrib/inventory/vmware_inventory.py
docs/api/conf.py
docs/bin/dump_keywords.py
docs/bin/plugin_formatter.py
docs/docsite/rst/conf.py
docs/docsite/rst/intro_inventory.rst
lib/ansible/cli/__init__.py
lib/ansible/cli/adhoc.py
lib/ansible/cli/console.py

Loading…
Cancel
Save