diff --git a/changelogs/fragments/attributes_compat.yml b/changelogs/fragments/attributes_compat.yml new file mode 100644 index 00000000000..74dabd3ef1a --- /dev/null +++ b/changelogs/fragments/attributes_compat.yml @@ -0,0 +1,2 @@ +bugfixes: + - make previous versions compatible we new attributres w/o implementing them. diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py index ac1bf38a8d2..e658f07bcd9 100644 --- a/lib/ansible/cli/doc.py +++ b/lib/ansible/cli/doc.py @@ -71,6 +71,7 @@ class DocCLI(CLI): # default ignore list for detailed views IGNORE = ('module', 'docuri', 'version_added', 'short_description', 'now_date', 'plainexamples', 'returndocs', 'collection') + JSON_IGNORE = ('attributes',) # Warning: If you add more elements here, you also need to add it to the docsite build (in the # ansible-community/antsibull repo) @@ -262,8 +263,13 @@ class DocCLI(CLI): plugin_docs[plugin] = DocCLI._combine_plugin_doc(plugin, plugin_type, doc, plainexamples, returndocs, metadata) if do_json: + for entry in plugin_docs.keys(): + for forbid in DocCLI.JSON_IGNORE: + try: + del plugin_docs[entry]['doc'][forbid] + except (KeyError, TypeError): + pass jdump(plugin_docs) - else: # Some changes to how plain text docs are formatted text = [] @@ -278,7 +284,6 @@ class DocCLI(CLI): if text: DocCLI.pager(''.join(text)) - return 0 @staticmethod diff --git a/lib/ansible/plugins/doc_fragments/action_common_attributes.py b/lib/ansible/plugins/doc_fragments/action_common_attributes.py new file mode 100644 index 00000000000..ea8fa7c9c6e --- /dev/null +++ b/lib/ansible/plugins/doc_fragments/action_common_attributes.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +# Copyright: 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 + + +# NOTE: this file is here to allow modules using the new attributes feature to +# work w/o errors in this version of ansible, it does NOT provide the full +# attributes feature, just a shim to avoid the fragment not being found. + +class ModuleDocFragment(object): + + # Standard documentation fragment + DOCUMENTATION = r''' +options: {} +''' diff --git a/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py b/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py index 42a2ada4afb..50254f2d2b7 100644 --- a/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py +++ b/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py @@ -448,6 +448,7 @@ def doc_schema(module_name, for_collection=False, deprecated_module=False): 'options': Any(None, *list_dict_option_schema(for_collection)), 'extends_documentation_fragment': Any(list_string_types, *string_types), 'version_added_collection': collection_name, + 'attributes': object, } if for_collection: