filter: fix documentation (#81113)

* Updated urldecode documentation
* Misc typo fixes
* Better formatting
* Corrected some example

Fixes: #81112

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/81299/head
Abhijeet Kasurde 1 year ago committed by GitHub
parent 528e7859d0
commit 1e929ada6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -21,7 +21,7 @@ EXAMPLES: |
lola: "{{ 'bG9sYQ==' | b64decode }}"
# b64 decode the content of 'b64stuff' variable
stuff: "{{ b64stuff | b64encode }}"
stuff: "{{ b64stuff | b64decode }}"
RETURN:
_value:

@ -13,7 +13,7 @@ DOCUMENTATION:
EXAMPLES: |
# simply encrypt my key in a vault
# in vars
vars:
isbool: "{{ (a == b) | bool }} "
otherbool: "{{ anothervar | bool }} "

@ -16,7 +16,8 @@ DOCUMENTATION:
plugin_type: filter
EXAMPLES: |
# To get the longest common path (ex. '/foo/bar') from the given list of paths (ex. ['/foo/bar/foobar','/foo/bar'])
# To get the longest common path (for example - '/foo/bar') from the given list of paths
# (for example - ['/foo/bar/foobar','/foo/bar'])
{{ listofpaths | commonpath }}
RETURN:

@ -32,6 +32,16 @@ EXAMPLES: |
# items => [ { "key": "a", "value": 1 }, { "key": "b", "value": 2 } ]
items: "{{ {'a': 1, 'b': 2}| dict2items }}"
# files_dicts: [
# {
# "file": "users",
# "path": "/etc/passwd"
# },
# {
# "file": "groups",
# "path": "/etc/group"
# }
# ]
vars:
files:
users: /etc/passwd

@ -15,7 +15,7 @@ DOCUMENTATION:
plugin_type: filter
EXAMPLES: |
# To get a normalized path (ex. '/foo/bar') from the path (ex. '/foo//bar')
# To get a normalized path (for example - '/foo/bar') from the path (for example - '/foo//bar')
{{ path | normpath }}
RETURN:

@ -4,8 +4,8 @@ DOCUMENTATION:
version_added: "1.8"
short_description: Turn path into real path
description:
- Resolves/follows symliknks to return the 'real path' from a given path.
- Filters alwasy run on controller so this path is resolved using the controller's filesystem.
- Resolves/follows symlinks to return the 'real path' from a given path.
- Filters always run on the controller so this path is resolved using the controller's filesystem.
options:
_input:
description: A path.
@ -13,6 +13,7 @@ DOCUMENTATION:
required: true
EXAMPLES: |
# realpath => /usr/bin/somebinary
realpath: {{ '/path/to/synlink' | realpath }}
RETURN:

@ -1,48 +1,29 @@
DOCUMENTATION:
name: urlsplit
name: urldecode
version_added: "2.4"
short_description: get components from URL
short_description: Decode percent-encoded sequences
description:
- Split a URL into its component parts.
positional: _input, query
- Replace %xx escapes with their single-character equivalent in the given string.
- Also replace plus signs with spaces, as required for unquoting HTML form values.
positional: _input
options:
_input:
description: URL string to split.
description: URL encoded string to decode.
type: str
required: true
query:
description: Specify a single component to return.
type: str
choices: ["fragment", "hostname", "netloc", "password", "path", "port", "query", "scheme", "username"]
RETURN:
_value:
description:
- A dictionary with components as keyword and their value.
- If O(query) is provided, a string or integer will be returned instead, depending on O(query).
- URL decoded value for the given string
type: any
EXAMPLES: |
{{ "http://user:password@www.acme.com:9000/dir/index.html?query=term#fragment" | urlsplit }}
# =>
# {
# "fragment": "fragment",
# "hostname": "www.acme.com",
# "netloc": "user:password@www.acme.com:9000",
# "password": "password",
# "path": "/dir/index.html",
# "port": 9000,
# "query": "query=term",
# "scheme": "http",
# "username": "user"
# }
{{ "http://user:password@www.acme.com:9000/dir/index.html?query=term#fragment" | urlsplit('hostname') }}
# => 'www.acme.com'
{{ "http://user:password@www.acme.com:9000/dir/index.html?query=term#fragment" | urlsplit('query') }}
# => 'query=term'
# Decode urlencoded string
{{ '%7e/abc+def' | urldecode }}
# => "~/abc def"
{{ "http://user:password@www.acme.com:9000/dir/index.html?query=term#fragment" | urlsplit('path') }}
# => '/dir/index.html'
# Decode plus sign as well
{{ 'El+Ni%C3%B1o' | urldecode }}
# => "El Niño"

Loading…
Cancel
Save