"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "docs/bin/plugin_formatter.py" between
ansible-2.7.6.tar.gz and ansible-2.7.7.tar.gz

About: Ansible is a platform for configuring and managing computers combining multi-node software deployment, ad hoc task execution, and configuration management.

plugin_formatter.py  (ansible-2.7.6):plugin_formatter.py  (ansible-2.7.7)
#!/usr/bin/env python #!/usr/bin/env python
# (c) 2012, Jan-Piet Mens <jpmens () gmail.com> # Copyright: (c) 2012, Jan-Piet Mens <jpmens () gmail.com>
# (c) 2012-2014, Michael DeHaan <michael@ansible.com> and others # Copyright: (c) 2012-2014, Michael DeHaan <michael@ansible.com> and others
# (c) 2017 Ansible Project # Copyright: (c) 2017, Ansible Project
#
# This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/
# gpl-3.0.txt)
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 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 absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
import datetime import datetime
import glob import glob
import optparse import optparse
import os import os
import re import re
import sys import sys
skipping to change at line 49 skipping to change at line 36
except ImportError: except ImportError:
# Python-3.2 or later # Python-3.2 or later
import cgi import cgi
def html_escape(text, quote=True): def html_escape(text, quote=True):
return cgi.escape(text, quote) return cgi.escape(text, quote)
import jinja2 import jinja2
import yaml import yaml
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
from jinja2.runtime import Undefined
from six import iteritems, string_types from six import iteritems, string_types
from ansible.errors import AnsibleError from ansible.errors import AnsibleError
from ansible.module_utils._text import to_bytes, to_text from ansible.module_utils._text import to_bytes, to_text
from ansible.module_utils.common.collections import is_sequence from ansible.module_utils.common.collections import is_sequence
from ansible.module_utils.parsing.convert_bool import boolean from ansible.module_utils.parsing.convert_bool import boolean
from ansible.plugins.loader import fragment_loader from ansible.plugins.loader import fragment_loader
from ansible.utils import plugin_docs from ansible.utils import plugin_docs
from ansible.utils.display import Display from ansible.utils.display import Display
skipping to change at line 150 skipping to change at line 138
def rst_fmt(text, fmt): def rst_fmt(text, fmt):
''' helper for Jinja2 to do format strings ''' ''' helper for Jinja2 to do format strings '''
return fmt % (text) return fmt % (text)
def rst_xline(width, char="="): def rst_xline(width, char="="):
''' return a restructured text line of a given length ''' ''' return a restructured text line of a given length '''
return char * width return char * width
def documented_type(text):
''' Convert any python type to a type for documentation '''
if isinstance(text, Undefined):
return '-'
if text == 'str':
return 'string'
if text == 'bool':
return 'boolean'
if text == 'int':
return 'integer'
if text == 'dict':
return 'dictionary'
return text
test_list = partial(is_sequence, include_strings=False) test_list = partial(is_sequence, include_strings=False)
def normalize_options(value): def normalize_options(value):
"""Normalize boolean option value.""" """Normalize boolean option value."""
if value.get('type') == 'bool' and 'default' in value: if value.get('type') == 'bool' and 'default' in value:
try: try:
value['default'] = boolean(value['default'], strict=True) value['default'] = boolean(value['default'], strict=True)
except TypeError: except TypeError:
pass pass
skipping to change at line 195 skipping to change at line 198
:returns: Tuple of two dicts containing module_info, categories, and :returns: Tuple of two dicts containing module_info, categories, and
aliases and a set listing deprecated modules: aliases and a set listing deprecated modules:
:module_info: mapping of module names to information about them. The fi elds of the dict are: :module_info: mapping of module names to information about them. The fi elds of the dict are:
:path: filesystem path to the module :path: filesystem path to the module
:deprecated: boolean. True means the module is deprecated otherwise not. :deprecated: boolean. True means the module is deprecated otherwise not.
:aliases: set of aliases to this module name :aliases: set of aliases to this module name
:metadata: The modules metadata (as recorded in the module) :metadata: The modules metadata (as recorded in the module)
:doc: The documentation structure for the module :doc: The documentation structure for the module
:seealso: The list of dictionaries with references to related subjec ts
:examples: The module's examples :examples: The module's examples
:returndocs: The module's returndocs :returndocs: The module's returndocs
:categories: maps category names to a dict. The dict contains at :categories: maps category names to a dict. The dict contains at
least one key, '_modules' which contains a list of module names in least one key, '_modules' which contains a list of module names in
that category. Any other keys in the dict are subcategories with that category. Any other keys in the dict are subcategories with
the same structure. the same structure.
''' '''
skipping to change at line 349 skipping to change at line 353
# Can be removed (and template switched to use namespace) when we no longer need to build # Can be removed (and template switched to use namespace) when we no longer need to build
# with <Jinja-2.10 # with <Jinja-2.10
env.globals['to_kludge_ns'] = to_kludge_ns env.globals['to_kludge_ns'] = to_kludge_ns
env.globals['from_kludge_ns'] = from_kludge_ns env.globals['from_kludge_ns'] = from_kludge_ns
if 'max' not in env.filters: if 'max' not in env.filters:
# Jinja < 2.10 # Jinja < 2.10
env.filters['max'] = do_max env.filters['max'] = do_max
templates = {} templates = {}
if typ == 'rst': if typ == 'rst':
env.filters['convert_symbols_to_format'] = rst_ify env.filters['rst_ify'] = rst_ify
env.filters['html_ify'] = html_ify env.filters['html_ify'] = html_ify
env.filters['fmt'] = rst_fmt env.filters['fmt'] = rst_fmt
env.filters['xline'] = rst_xline env.filters['xline'] = rst_xline
env.filters['documented_type'] = documented_type
env.tests['list'] = test_list env.tests['list'] = test_list
templates['plugin'] = env.get_template('plugin.rst.j2') templates['plugin'] = env.get_template('plugin.rst.j2')
if plugin_type == 'module': if plugin_type == 'module':
name = 'modules' name = 'modules'
else: else:
name = 'plugins' name = 'plugins'
templates['category_list'] = env.get_template('%s_by_category.rst.j2' % name) templates['category_list'] = env.get_template('%s_by_category.rst.j2' % name)
templates['support_list'] = env.get_template('%s_by_support.rst.j2' % na me) templates['support_list'] = env.get_template('%s_by_support.rst.j2' % na me)
skipping to change at line 448 skipping to change at line 453
# Strip old version_added for the module # Strip old version_added for the module
if too_old(added): if too_old(added):
del doc['version_added'] del doc['version_added']
option_names = [] option_names = []
if 'options' in doc and doc['options']: if 'options' in doc and doc['options']:
for (k, v) in iteritems(doc['options']): for (k, v) in iteritems(doc['options']):
# Error out if there's no description # Error out if there's no description
if 'description' not in doc['options'][k]: if 'description' not in doc['options'][k]:
raise AnsibleError("Missing required description for option %s in %s " % (k, module)) raise AnsibleError("Missing required description for paramet er '%s' in '%s' " % (k, module))
# Error out if required isn't a boolean (people have been puttin g # Error out if required isn't a boolean (people have been puttin g
# information on when something is required in here. Those need # information on when something is required in here. Those need
# to go in the description instead). # to go in the description instead).
required_value = doc['options'][k].get('required', False) required_value = doc['options'][k].get('required', False)
if not isinstance(required_value, bool): if not isinstance(required_value, bool):
raise AnsibleError("Invalid required value '%s' for option ' %s' in '%s' (must be truthy)" % (required_value, k, module)) raise AnsibleError("Invalid required value '%s' for paramete r '%s' in '%s' (must be truthy)" % (required_value, k, module))
# Strip old version_added information for options # Strip old version_added information for options
if 'version_added' in doc['options'][k] and too_old(doc['options '][k]['version_added']): if 'version_added' in doc['options'][k] and too_old(doc['options '][k]['version_added']):
del doc['options'][k]['version_added'] del doc['options'][k]['version_added']
# Make sure description is a list of lines for later formatting # Make sure description is a list of lines for later formatting
if not isinstance(doc['options'][k]['description'], list): if not isinstance(doc['options'][k]['description'], list):
doc['options'][k]['description'] = [doc['options'][k]['descr iption']] doc['options'][k]['description'] = [doc['options'][k]['descr iption']]
option_names.append(k) option_names.append(k)
 End of changes. 8 change blocks. 
21 lines changed or deleted 27 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)