From 73a16749cb1e70da9a2e6a1e80216fb0026fe9c4 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 12 Jun 2019 17:10:17 -0400 Subject: [PATCH] Enable adjacent collections for ansible-doc (#57764) * enable adjacent collections for ansible-doc --- changelogs/fragments/doc_adj_coll.yml | 2 ++ lib/ansible/cli/doc.py | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/doc_adj_coll.yml diff --git a/changelogs/fragments/doc_adj_coll.yml b/changelogs/fragments/doc_adj_coll.yml new file mode 100644 index 00000000000..d78625c70aa --- /dev/null +++ b/changelogs/fragments/doc_adj_coll.yml @@ -0,0 +1,2 @@ +minor_changes: + - Enable ansible-doc to work with 'adjacent' collections via --playbook-dir option. diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py index dc05a6ffcc5..e87d4b7e6ad 100644 --- a/lib/ansible/cli/doc.py +++ b/lib/ansible/cli/doc.py @@ -26,9 +26,9 @@ from ansible.parsing.metadata import extract_metadata from ansible.parsing.plugin_docs import read_docstub from ansible.parsing.yaml.dumper import AnsibleDumper from ansible.plugins.loader import action_loader, fragment_loader +from ansible.utils.collection_loader import set_collection_playbook_paths from ansible.utils.display import Display from ansible.utils.plugin_docs import BLACKLIST, get_docstring - display = Display() @@ -53,6 +53,7 @@ class DocCLI(CLI): epilog="See man pages for Ansible CLI options or website for tutorials https://docs.ansible.com" ) opt_help.add_module_options(self.parser) + opt_help.add_basedir_options(self.parser) self.parser.add_argument('args', nargs='*', help='Plugin', metavar='plugin') self.parser.add_argument("-t", "--type", action="store", default='module', dest='type', @@ -88,7 +89,11 @@ class DocCLI(CLI): else: raise AnsibleOptionsError("Unknown or undocumentable plugin type: %s" % plugin_type) - # add to plugin path from command line + # add to plugin paths from command line + basedir = context.CLIARGS['basedir'] + if basedir: + set_collection_playbook_paths(basedir) + loader.add_directory(basedir, with_subdir=True) if context.CLIARGS['module_path']: for path in context.CLIARGS['module_path']: if path: