From 7eda5c50ae2d14e05db32ef7a4fa303cbd075472 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Thu, 25 Oct 2018 11:30:04 -0700 Subject: [PATCH] Update ansible-doc for invariants in the metadata/plugin_doc api * There will always be metadata returned so no need to check for its existence first. * There won't be version or metadata_version as those are being removed by the api. So all checks for those need to be removed. --- lib/ansible/cli/doc.py | 25 ++++++++++--------------- lib/ansible/constants.py | 2 +- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py index 7a95083be77..edefaf041d3 100644 --- a/lib/ansible/cli/doc.py +++ b/lib/ansible/cli/doc.py @@ -263,7 +263,7 @@ class DocCLI(CLI): return text else: - if 'removed' in metadata.get('status', []): + if 'removed' in metadata['status']: display.warning("%s %s has been removed\n" % (plugin_type, plugin)) return @@ -512,26 +512,21 @@ class DocCLI(CLI): 'community': 'The Ansible Community', 'curated': 'A Third Party', } - if doc['metadata'].get('metadata_version') in ('1.0', '1.1'): - return [" * This module is maintained by %s" % support_level_msg[doc['metadata']['supported_by']]] - - return [] + return [" * This module is maintained by %s" % support_level_msg[doc['metadata']['supported_by']]] @staticmethod def get_metadata_block(doc): text = [] - if doc['metadata'].get('metadata_version') in ('1.0', '1.1'): - text.append("METADATA:") - text.append('\tSUPPORT LEVEL: %s' % doc['metadata']['supported_by']) - for k in (m for m in doc['metadata'] if m not in ('version', 'metadata_version', 'supported_by')): - if isinstance(k, list): - text.append("\t%s: %s" % (k.capitalize(), ", ".join(doc['metadata'][k]))) - else: - text.append("\t%s: %s" % (k.capitalize(), doc['metadata'][k])) - return text + text.append("METADATA:") + text.append('\tSUPPORT LEVEL: %s' % doc['metadata']['supported_by']) - return [] + for k in (m for m in doc['metadata'] if m != 'supported_by'): + if isinstance(k, list): + text.append("\t%s: %s" % (k.capitalize(), ", ".join(doc['metadata'][k]))) + else: + text.append("\t%s: %s" % (k.capitalize(), doc['metadata'][k])) + return text def get_man_text(self, doc): diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index 225361ddd73..79fe78c6400 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -106,7 +106,7 @@ DEFAULT_SU_PASS = None # FIXME: expand to other plugins, but never doc fragments CONFIGURABLE_PLUGINS = ('cache', 'callback', 'connection', 'inventory', 'lookup', 'shell', 'cliconf', 'httpapi') # NOTE: always update the docs/docsite/Makefile to match -DOCUMENTABLE_PLUGINS = ('cache', 'callback', 'connection', 'inventory', 'lookup', 'shell', 'module', 'strategy', 'vars') +DOCUMENTABLE_PLUGINS = CONFIGURABLE_PLUGINS + ('module', 'strategy', 'vars') IGNORE_FILES = ("COPYING", "CONTRIBUTING", "LICENSE", "README", "VERSION", "GUIDELINES") # ignore during module search INTERNAL_RESULT_KEYS = ('add_host', 'add_group') LOCALHOST = ('127.0.0.1', 'localhost', '::1')