1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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
This commit is contained in:
Brian Coca 2018-12-10 11:37:15 -05:00 committed by GitHub
parent 18bf48cec2
commit 20270680fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 10 deletions

View file

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

View file

@ -127,18 +127,18 @@ class DocCLI(CLI):
# process all plugins of type
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:
plugin_data = {}
for plugin_type in C.DOCUMENTABLE_PLUGINS:
plugin_data[plugin_type] = dict()
plugin_names = self.get_all_plugins_of_type(plugin_type)
for plugin_name in plugin_names:
plugin_info = self.get_plugin_metadata(plugin_type, plugin_name)
if plugin_info is not None:
plugin_data[plugin_type][plugin_name] = plugin_info
plugin_names = self.get_all_plugins_of_type(plugin_type)
for plugin_name in plugin_names:
plugin_info = self.get_plugin_metadata(plugin_type, plugin_name)
if plugin_info is not None:
plugin_data[plugin_name] = plugin_info
self.pager(json.dumps(plugin_data, sort_keys=True, indent=4))

View file

@ -24,6 +24,8 @@ try:
except ImportError:
argcomplete = None
from ansible import constants as C
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
CHANGELOG_DIR = os.path.join(BASE_DIR, 'changelogs')
CONFIG_PATH = os.path.join(CHANGELOG_DIR, 'config.yaml')
@ -173,7 +175,9 @@ def load_plugins(version, force_reload):
LOGGER.info('refreshing plugin cache')
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
for section in plugins_data['plugins'].values():