Add --all option to ansible-doc.
This commit is contained in:
parent
ead0022255
commit
43785aa246
2 changed files with 26 additions and 18 deletions
|
@ -59,6 +59,8 @@ class DocCLI(CLI):
|
||||||
help='List available modules')
|
help='List available modules')
|
||||||
self.parser.add_option("-s", "--snippet", action="store_true", default=False, dest='show_snippet',
|
self.parser.add_option("-s", "--snippet", action="store_true", default=False, dest='show_snippet',
|
||||||
help='Show playbook snippet for specified module(s)')
|
help='Show playbook snippet for specified module(s)')
|
||||||
|
self.parser.add_option("-a", "--all", action="store_true", default=False, dest='all_modules',
|
||||||
|
help='Show documentation for all modules')
|
||||||
|
|
||||||
super(DocCLI, self).parse()
|
super(DocCLI, self).parse()
|
||||||
|
|
||||||
|
@ -81,6 +83,13 @@ class DocCLI(CLI):
|
||||||
self.pager(self.get_module_list_text())
|
self.pager(self.get_module_list_text())
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
# process all modules
|
||||||
|
if self.options.all_modules:
|
||||||
|
paths = module_loader._get_paths()
|
||||||
|
for path in paths:
|
||||||
|
self.find_modules(path)
|
||||||
|
self.args = sorted(set(self.module_list) - module_docs.BLACKLIST_MODULES)
|
||||||
|
|
||||||
if len(self.args) == 0:
|
if len(self.args) == 0:
|
||||||
raise AnsibleOptionsError("Incorrect options passed")
|
raise AnsibleOptionsError("Incorrect options passed")
|
||||||
|
|
||||||
|
@ -143,13 +152,13 @@ class DocCLI(CLI):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def find_modules(self, path):
|
def find_modules(self, path):
|
||||||
|
|
||||||
if os.path.isdir(path):
|
|
||||||
for module in os.listdir(path):
|
for module in os.listdir(path):
|
||||||
|
full_path = '/'.join([path, module])
|
||||||
|
|
||||||
if module.startswith('.'):
|
if module.startswith('.'):
|
||||||
continue
|
continue
|
||||||
elif os.path.isdir(module):
|
elif os.path.isdir(full_path):
|
||||||
self.find_modules(module)
|
continue
|
||||||
elif any(module.endswith(x) for x in C.BLACKLIST_EXTS):
|
elif any(module.endswith(x) for x in C.BLACKLIST_EXTS):
|
||||||
continue
|
continue
|
||||||
elif module.startswith('__'):
|
elif module.startswith('__'):
|
||||||
|
@ -157,11 +166,11 @@ class DocCLI(CLI):
|
||||||
elif module in C.IGNORE_FILES:
|
elif module in C.IGNORE_FILES:
|
||||||
continue
|
continue
|
||||||
elif module.startswith('_'):
|
elif module.startswith('_'):
|
||||||
fullpath = '/'.join([path,module])
|
if os.path.islink(full_path): # avoids aliases
|
||||||
if os.path.islink(fullpath): # avoids aliases
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
module = os.path.splitext(module)[0] # removes the extension
|
module = os.path.splitext(module)[0] # removes the extension
|
||||||
|
module = module.lstrip('_') # remove underscore from deprecated modules
|
||||||
self.module_list.append(module)
|
self.module_list.append(module)
|
||||||
|
|
||||||
def get_module_list_text(self):
|
def get_module_list_text(self):
|
||||||
|
|
|
@ -41,7 +41,6 @@ except ImportError:
|
||||||
# modules that are ok that they do not have documentation strings
|
# modules that are ok that they do not have documentation strings
|
||||||
BLACKLIST_MODULES = frozenset((
|
BLACKLIST_MODULES = frozenset((
|
||||||
'async_wrapper',
|
'async_wrapper',
|
||||||
'accelerate',
|
|
||||||
))
|
))
|
||||||
|
|
||||||
def get_docstring(filename, verbose=False):
|
def get_docstring(filename, verbose=False):
|
||||||
|
|
Loading…
Reference in a new issue