Commit faed1b2d by Brian Coca

better error reporting when doc parsing fails

parent b27d7620
...@@ -81,43 +81,46 @@ class DocCLI(CLI): ...@@ -81,43 +81,46 @@ class DocCLI(CLI):
text = '' text = ''
for module in self.args: for module in self.args:
filename = module_loader.find_plugin(module) try:
if filename is None: filename = module_loader.find_plugin(module)
self.display.warning("module %s not found in %s\n" % (module, DocCLI.print_paths(module_loader))) if filename is None:
continue self.display.warning("module %s not found in %s\n" % (module, DocCLI.print_paths(module_loader)))
continue
if any(filename.endswith(x) for x in self.BLACKLIST_EXTS): if any(filename.endswith(x) for x in self.BLACKLIST_EXTS):
continue continue
try: try:
doc, plainexamples, returndocs = module_docs.get_docstring(filename) doc, plainexamples, returndocs = module_docs.get_docstring(filename)
except: except:
self.display.vvv(traceback.print_exc()) self.display.vvv(traceback.print_exc())
self.display.error("module %s has a documentation error formatting or is missing documentation\nTo see exact traceback use -vvv" % module) self.display.error("module %s has a documentation error formatting or is missing documentation\nTo see exact traceback use -vvv" % module)
continue continue
if doc is not None: if doc is not None:
all_keys = [] all_keys = []
for (k,v) in doc['options'].iteritems(): for (k,v) in doc['options'].iteritems():
all_keys.append(k) all_keys.append(k)
all_keys = sorted(all_keys) all_keys = sorted(all_keys)
doc['option_keys'] = all_keys doc['option_keys'] = all_keys
doc['filename'] = filename doc['filename'] = filename
doc['docuri'] = doc['module'].replace('_', '-') doc['docuri'] = doc['module'].replace('_', '-')
doc['now_date'] = datetime.date.today().strftime('%Y-%m-%d') doc['now_date'] = datetime.date.today().strftime('%Y-%m-%d')
doc['plainexamples'] = plainexamples doc['plainexamples'] = plainexamples
doc['returndocs'] = returndocs doc['returndocs'] = returndocs
if self.options.show_snippet: if self.options.show_snippet:
text += DocCLI.get_snippet_text(doc) text += DocCLI.get_snippet_text(doc)
else:
text += DocCLI.get_man_text(doc)
else: else:
text += DocCLI.get_man_text(doc) # this typically means we couldn't even parse the docstring, not just that the YAML is busted,
else: # probably a quoting issue.
# this typically means we couldn't even parse the docstring, not just that the YAML is busted, raise AnsibleError("Parsing produced an empty object.")
# probably a quoting issue. except Exception, e:
self.display.warning("module %s missing documentation (or could not parse documentation)\n" % module) raise AnsibleError("module %s missing documentation (or could not parse documentation): %s\n" % (module, str(e)))
CLI.pager(text) CLI.pager(text)
return 0 return 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment