From c0821346fcb8f37db3a9b8c6985e197b93f4c2f1 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 22 Mar 2024 00:40:46 +0100 Subject: [PATCH] Do not mangle plugin names in collections that start with an underscore. (#82574) --- ...74-ansible-test-ansible-doc-underscore.yml | 2 ++ .../ns/col/plugins/modules/_module3.py | 32 +++++++++++++++++++ .../_internal/commands/sanity/ansible_doc.py | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/82574-ansible-test-ansible-doc-underscore.yml create mode 100644 test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/modules/_module3.py diff --git a/changelogs/fragments/82574-ansible-test-ansible-doc-underscore.yml b/changelogs/fragments/82574-ansible-test-ansible-doc-underscore.yml new file mode 100644 index 00000000000..8414231b0f6 --- /dev/null +++ b/changelogs/fragments/82574-ansible-test-ansible-doc-underscore.yml @@ -0,0 +1,2 @@ +bugfixes: + - "ansible-test ansible-doc sanity test - do not remove underscores from plugin names in collections before calling ``ansible-doc`` (https://github.com/ansible/ansible/pull/82574)." diff --git a/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/modules/_module3.py b/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/modules/_module3.py new file mode 100644 index 00000000000..41784aeee09 --- /dev/null +++ b/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/modules/_module3.py @@ -0,0 +1,32 @@ +#!/usr/bin/python +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import annotations + +DOCUMENTATION = ''' +module: _module3 +short_description: Another test module +description: This is a test module that has not been deprecated. +author: + - Ansible Core Team +''' + +EXAMPLES = ''' +- minimal: +''' + +RETURN = '''''' + +from ansible.module_utils.basic import AnsibleModule + + +def main(): + module = AnsibleModule( + argument_spec={}, + ) + + module.exit_json() + + +if __name__ == '__main__': + main() diff --git a/test/lib/ansible_test/_internal/commands/sanity/ansible_doc.py b/test/lib/ansible_test/_internal/commands/sanity/ansible_doc.py index ff035ef9138..1b3b4023e46 100644 --- a/test/lib/ansible_test/_internal/commands/sanity/ansible_doc.py +++ b/test/lib/ansible_test/_internal/commands/sanity/ansible_doc.py @@ -79,7 +79,7 @@ class AnsibleDocTest(SanitySingleVersion): plugin_parts = os.path.relpath(plugin_file_path, plugin_path).split(os.path.sep) plugin_name = os.path.splitext(plugin_parts[-1])[0] - if plugin_name.startswith('_'): + if plugin_name.startswith('_') and not data_context().content.collection: plugin_name = plugin_name[1:] plugin_fqcn = data_context().content.prefix + '.'.join(plugin_parts[:-1] + [plugin_name])