Skip to content

Commit

Permalink
fixes to ansible-doc (ansible#47682)
Browse files Browse the repository at this point in the history
 fixes to ansible-doc
 - change json to always be type dependent
 - change changelog generation to loop over the options
 - warn about ignoring module path
  • Loading branch information
bcoca authored Dec 10, 2018
1 parent 18bf48c commit 2027068
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/docfixes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "ansible-doc, --json now is 'type intelligent' and reinstated --all option"
18 changes: 9 additions & 9 deletions lib/ansible/cli/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,18 @@ def run(self):

# 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))

Expand Down
6 changes: 5 additions & 1 deletion packaging/release/changelogs/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
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')
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 2027068

Please sign in to comment.