summaryrefslogtreecommitdiffstats
path: root/bin/ansible-doc
diff options
context:
space:
mode:
authorBrian Coca <brian.coca+git@gmail.com>2014-10-30 03:33:31 +0100
committerBrian Coca <brian.coca+git@gmail.com>2014-10-30 03:33:31 +0100
commit1b70ef6cbaa23fa2399204689a489d39be7a76fb (patch)
treecc0ca91bcda91d847767084196fade475d95ded4 /bin/ansible-doc
parentfixed typo (diff)
downloadansible-1b70ef6cbaa23fa2399204689a489d39be7a76fb.tar.xz
ansible-1b70ef6cbaa23fa2399204689a489d39be7a76fb.zip
Several changes to ansible-doc
added display of deprecated to ansible-doc now it does better job of using tty columns fixed indication truncation of desc with trailing ... removed extension from module list, also fixed matching exlusion blacklist
Diffstat (limited to 'bin/ansible-doc')
-rwxr-xr-xbin/ansible-doc45
1 files changed, 34 insertions, 11 deletions
diff --git a/bin/ansible-doc b/bin/ansible-doc
index 8a7faadb24..3c4f84964a 100755
--- a/bin/ansible-doc
+++ b/bin/ansible-doc
@@ -164,7 +164,11 @@ def get_snippet_text(doc):
return "\n".join(text)
def get_module_list_text(module_list):
+ columns = max(60, int(os.popen('stty size', 'r').read().split()[1]))
+ displace = max(len(x) for x in module_list)
+ linelimit = columns - displace - 5
text = []
+ deprecated = []
for module in sorted(set(module_list)):
if module in module_docs.BLACKLIST_MODULES:
@@ -181,13 +185,22 @@ def get_module_list_text(module_list):
try:
doc, plainexamples = module_docs.get_docstring(filename)
- desc = tty_ify(doc.get('short_description', '?'))
- if len(desc) > 55:
- desc = desc + '...'
- text.append("%-20s %-60.60s" % (module, desc))
+ desc = tty_ify(doc.get('short_description', '?')).strip()
+ if len(desc) > linelimit:
+ desc = desc[:linelimit] + '...'
+
+ if module.startswith('_'): # Handle replecated
+ module = module[1:]
+ deprecated.append("%-*s %-*.*s" % (displace, module, linelimit, len(desc), desc))
+ else:
+ text.append("%-*s %-*.*s" % (displace, module, linelimit, len(desc), desc))
except:
traceback.print_exc()
sys.stderr.write("ERROR: module %s has a documentation error formatting or is missing documentation\n" % module)
+
+ if len(deprecated) > 0:
+ text.append("\nDEPRECATED:")
+ text.extend(deprecated)
return "\n".join(text)
def main():
@@ -208,6 +221,11 @@ def main():
default=False,
dest='list_dir',
help='List available modules')
+ p.add_option("-c", "--list-columns",
+ action="store_true",
+ default=False,
+ dest='list_columns',
+ help='List modules in columns')
p.add_option("-s", "--snippet",
action="store_true",
default=False,
@@ -221,20 +239,25 @@ def main():
for i in options.module_path.split(os.pathsep):
utils.plugins.module_finder.add_directory(i)
- if options.list_dir:
- # list all modules
+ if options.list_dir or options.list_deprecated:
+ # list modules
paths = utils.plugins.module_finder._get_paths()
module_list = []
- deprecated_list = []
- module_aliases = {}
for path in paths:
- # os.system("ls -C %s" % (path))
if os.path.isdir(path):
for module in os.listdir(path):
- if module.startswith('_') or any(module.endswith(x) for x in BLACKLIST_EXTS):
+ if any(module.endswith(x) for x in BLACKLIST_EXTS):
continue
- module_list.append(module)
+ elif module.startswith('__'):
+ continue
+ elif module.startswith('_'):
+ fullpath = '/'.join([path,module])
+ if os.path.islink(fullpath): # avoids aliases
+ continue
+ module = os.path.splitext(module)[0] # removes the extension
+ module_list.append(module)
+
pager(get_module_list_text(module_list))
sys.exit()