diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2021-09-01 12:38:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-01 11:38:19 -0500 |
commit | 463cf9fe244430249701509fc3ee7636a18afc44 (patch) | |
tree | 95d6ff1769c928a36594ffc00859b820cc686672 | |
parent | 8c105c0f61b2ef5a97d421f0788aca2ad0a68904 (diff) | |
download | ansible-463cf9fe244430249701509fc3ee7636a18afc44.tar.gz |
Attributes compat (#75563)
* ignore attributes in output
* ignore 'attributes' for json dump
* actually add file
* clog
* sometimtes its not a dict
* always ignore
* also allow validation to work on newer modules
* remove attributes doc
let existing overrides display, wont be full info but still pertinent info
though user will have to check newer versions
4 files changed, 28 insertions, 0 deletions
diff --git a/changelogs/fragments/attributes_compat.yml b/changelogs/fragments/attributes_compat.yml new file mode 100644 index 0000000000..74dabd3ef1 --- /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 130e9046cb..047f6d65a7 100644 --- a/lib/ansible/cli/doc.py +++ b/lib/ansible/cli/doc.py @@ -334,6 +334,7 @@ class DocCLI(CLI, RoleMixin): # 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) @@ -686,6 +687,12 @@ class DocCLI(CLI, RoleMixin): docs = self._get_plugins_docs(plugin_type, loader) if do_json: + for entry in docs.keys(): + for forbid in DocCLI.JSON_IGNORE: + try: + del docs[entry]['doc'][forbid] + except (KeyError, TypeError): + pass jdump(docs) else: text = [] 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 0000000000..ea8fa7c9c6 --- /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 ecf63557f7..359773e5ab 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 @@ -505,6 +505,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: |