docs: print deprecation collection name (#84126)

While showing the deprecation message, mention the collection name
from which the module is removed.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/84191/head
Abhijeet Kasurde 1 year ago committed by GitHub
parent c9ac477e53
commit ab1a8cb3b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,3 @@
---
minor_changes:
- docs - add collection name in message from which the module is being deprecated (https://github.com/ansible/ansible/issues/84116).

@ -1396,7 +1396,7 @@ class DocCLI(CLI, RoleMixin):
if 'removed_at_date' not in doc['deprecated'] and 'version' in doc['deprecated'] and 'removed_in' not in doc['deprecated']:
doc['deprecated']['removed_in'] = doc['deprecated']['version']
try:
text.append('\t' + C.config.get_deprecated_msg_from_config(doc['deprecated'], True))
text.append('\t' + C.config.get_deprecated_msg_from_config(doc['deprecated'], True, collection_name=collection_name))
except KeyError as e:
raise AnsibleError("Invalid deprecation documentation structure", orig_exc=e)
else:

@ -682,12 +682,14 @@ class ConfigManager(object):
self._plugins[plugin_type][name] = defs
@staticmethod
def get_deprecated_msg_from_config(dep_docs, include_removal=False):
def get_deprecated_msg_from_config(dep_docs, include_removal=False, collection_name=None):
removal = ''
if include_removal:
if 'removed_at_date' in dep_docs:
removal = f"Will be removed in a release after {dep_docs['removed_at_date']}\n\t"
elif collection_name:
removal = f"Will be removed in: {collection_name} {dep_docs['removed_in']}\n\t"
else:
removal = f"Will be removed in: Ansible {dep_docs['removed_in']}\n\t"

@ -12,7 +12,7 @@
messages.
DEPRECATED:
Reason: Test deprecation
Will be removed in: Ansible 3.0.0
Will be removed in: testns.testcol 3.0.0
Alternatives: Use some other module
OPTIONS (= indicates it is required):

@ -30,6 +30,9 @@ ansible-doc -t keyword -l | grep "${GREP_OPTS[@]}" 'vars_prompt: list of variabl
ansible-doc -t keyword vars_prompt | grep "${GREP_OPTS[@]}" 'description: list of variables to prompt for.'
ansible-doc -t keyword asldkfjaslidfhals 2>&1 | grep "${GREP_OPTS[@]}" 'Skipping Invalid keyword'
echo "Check if deprecation collection name is printed"
ansible-doc --playbook-dir ./ testns.testcol.randommodule 2>&1 | grep "${GREP_OPTS[@]}" "Will be removed in: testns.testcol"
# collections testing
(
unset ANSIBLE_PLAYBOOK_DIR

Loading…
Cancel
Save