fixes to ansible-doc (#47682)

fixes to ansible-doc
 - change json to always be type dependent
 - change changelog generation to loop over the options
 - warn about ignoring module path
pull/27859/head
Brian Coca 6 years ago committed by GitHub
parent 18bf48cec2
commit 20270680fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- "ansible-doc, --json now is 'type intelligent' and reinstated --all option"

@ -127,18 +127,18 @@ class DocCLI(CLI):
# process all plugins of type # process all plugins of type
if self.options.all_plugins: if self.options.all_plugins:
self.args = self.get_all_plugins_of_type(plugin_type, loader) self.args = self.get_all_plugins_of_type(plugin_type)
if self.options.module_path:
display.warning('Ignoring "--module-path/-M" option as "--all/-a" only displays builtins')
# dump plugin metadata as JSON # dump plugin desc/metadata as JSON
if self.options.json_dump: if self.options.json_dump:
plugin_data = {} plugin_data = {}
for plugin_type in C.DOCUMENTABLE_PLUGINS: plugin_names = self.get_all_plugins_of_type(plugin_type)
plugin_data[plugin_type] = dict() for plugin_name in plugin_names:
plugin_names = self.get_all_plugins_of_type(plugin_type) plugin_info = self.get_plugin_metadata(plugin_type, plugin_name)
for plugin_name in plugin_names: if plugin_info is not None:
plugin_info = self.get_plugin_metadata(plugin_type, plugin_name) plugin_data[plugin_name] = plugin_info
if plugin_info is not None:
plugin_data[plugin_type][plugin_name] = plugin_info
self.pager(json.dumps(plugin_data, sort_keys=True, indent=4)) self.pager(json.dumps(plugin_data, sort_keys=True, indent=4))

@ -24,6 +24,8 @@ try:
except ImportError: except ImportError:
argcomplete = None argcomplete = None
from ansible import constants as C
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')) BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
CHANGELOG_DIR = os.path.join(BASE_DIR, 'changelogs') CHANGELOG_DIR = os.path.join(BASE_DIR, 'changelogs')
CONFIG_PATH = os.path.join(CHANGELOG_DIR, 'config.yaml') CONFIG_PATH = os.path.join(CHANGELOG_DIR, 'config.yaml')
@ -173,7 +175,9 @@ def load_plugins(version, force_reload):
LOGGER.info('refreshing plugin cache') LOGGER.info('refreshing plugin cache')
plugins_data['version'] = version plugins_data['version'] = version
plugins_data['plugins'] = json.loads(subprocess.check_output([os.path.join(BASE_DIR, 'bin', 'ansible-doc'), '--json'])) for plugin_type in C.DOCUMENTABLE_PLUGINS:
plugins_data['plugins'][plugin_type] = json.loads(subprocess.check_output([os.path.join(BASE_DIR, 'bin', 'ansible-doc'),
'--json', '-t', plugin_type]))
# remove empty namespaces from plugins # remove empty namespaces from plugins
for section in plugins_data['plugins'].values(): for section in plugins_data['plugins'].values():

Loading…
Cancel
Save