Document all filter and test plugins (#4597)

* Fix/improve docs.

* Document the a_module test.

* Document the dict filter.

* Linting.

* Add more filter docs.

* More filters.

* Update BOTMETA.

* Add another plugin.

* Fix typos.

* Add explicit entries.

* Fix lookup documentation.
This commit is contained in:
Felix Fontein 2022-05-02 07:25:45 +02:00 committed by GitHub
commit f055f47161
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 1080 additions and 20 deletions

View file

@ -6,6 +6,60 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = '''
name: dict
short_description: Convert a list of tuples into a dictionary
version_added: 3.0.0
author: Felix Fontein (@felixfontein)
description:
- Convert a list of tuples into a dictionary. This is a filter version of the C(dict) function.
options:
_input:
description: A list of tuples (with exactly two elements).
type: list
elements: tuple
required: true
'''
EXAMPLES = '''
- name: Convert list of tuples into dictionary
ansible.builtin.set_fact:
dictionary: "{{ [[1, 2], ['a', 'b']] | community.general.dict }}"
# Result is {1: 2, 'a': 'b'}
- name: Create a list of dictionaries with map and the community.general.dict filter
ansible.builtin.debug:
msg: >-
{{ values | map('zip', ['k1', 'k2', 'k3'])
| map('map', 'reverse')
| map('community.general.dict') }}
vars:
values:
- - foo
- 23
- a
- - bar
- 42
- b
# Produces the following list of dictionaries:
# {
# "k1": "foo",
# "k2": 23,
# "k3": "a"
# },
# {
# "k1": "bar",
# "k2": 42,
# "k3": "b"
# }
'''
RETURN = '''
_value:
description: Whether the module or action plugin denoted by the input exists.
type: boolean
'''
def dict_filter(sequence):
'''Convert a list of tuples to a dictionary.