mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Docs: Show parameter types (in purple) (#49966)
* Docs: Show parameter types (in purple) * Changes based on feedback * Remove leftover statement after review * Simplify TOC and support section * Add missing 'v' to version_added * Remove the v for version * Update docs/templates/plugin.rst.j2 Co-Authored-By: dagwieers <dag@wieers.com> * Update docs/templates/plugin.rst.j2 Co-Authored-By: dagwieers <dag@wieers.com> * Move Author into Support section * Avoid more "isn't included in any toctree" errors * Add Red Hat support section, list module status
This commit is contained in:
parent
14b03ac15f
commit
76450fd1c2
3 changed files with 56 additions and 53 deletions
|
@ -1,22 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
# (c) 2012, Jan-Piet Mens <jpmens () gmail.com>
|
||||
# (c) 2012-2014, Michael DeHaan <michael@ansible.com> and others
|
||||
# (c) 2017 Ansible Project
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# 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/>.
|
||||
# Copyright: (c) 2012, Jan-Piet Mens <jpmens () gmail.com>
|
||||
# Copyright: (c) 2012-2014, Michael DeHaan <michael@ansible.com> and others
|
||||
# Copyright: (c) 2017, Ansible Project
|
||||
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
@ -47,6 +34,7 @@ except ImportError:
|
|||
import jinja2
|
||||
import yaml
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
from jinja2.runtime import Undefined
|
||||
from six import iteritems, string_types
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
|
@ -159,6 +147,22 @@ def rst_xline(width, char="="):
|
|||
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)
|
||||
|
||||
|
||||
|
@ -388,6 +392,7 @@ def jinja2_environment(template_dir, typ, plugin_type):
|
|||
env.filters['html_ify'] = html_ify
|
||||
env.filters['fmt'] = rst_fmt
|
||||
env.filters['xline'] = rst_xline
|
||||
env.filters['documented_type'] = documented_type
|
||||
env.tests['list'] = test_list
|
||||
templates['plugin'] = env.get_template('plugin.rst.j2')
|
||||
|
||||
|
@ -486,14 +491,14 @@ def process_plugins(module_map, templates, outputname, output_dir, ansible_versi
|
|||
for (k, v) in iteritems(doc['options']):
|
||||
# Error out if there's no description
|
||||
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 parameter '%s' in '%s' " % (k, module))
|
||||
|
||||
# Error out if required isn't a boolean (people have been putting
|
||||
# information on when something is required in here. Those need
|
||||
# to go in the description instead).
|
||||
required_value = doc['options'][k].get('required', False)
|
||||
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 parameter '%s' in '%s' (must be truthy)" % (required_value, k, module))
|
||||
|
||||
# Strip old version_added information for options
|
||||
if 'version_added' in doc['options'][k] and too_old(doc['options'][k]['version_added']):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue