mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Python 3 fixes for ansible-doc.
This commit is contained in:
parent
b18263cf36
commit
88dbb5a630
2 changed files with 5 additions and 5 deletions
|
@ -101,7 +101,7 @@ class DocCLI(CLI):
|
||||||
try:
|
try:
|
||||||
doc, plainexamples, returndocs = module_docs.get_docstring(filename, verbose=(self.options.verbosity > 0))
|
doc, plainexamples, returndocs = module_docs.get_docstring(filename, verbose=(self.options.verbosity > 0))
|
||||||
except:
|
except:
|
||||||
display.vvv(traceback.print_exc())
|
display.vvv(traceback.format_exc())
|
||||||
display.error("module %s has a documentation error formatting or is missing documentation\nTo see exact traceback use -vvv" % module)
|
display.error("module %s has a documentation error formatting or is missing documentation\nTo see exact traceback use -vvv" % module)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ class DocCLI(CLI):
|
||||||
# probably a quoting issue.
|
# probably a quoting issue.
|
||||||
raise AnsibleError("Parsing produced an empty object.")
|
raise AnsibleError("Parsing produced an empty object.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
display.vvv(traceback.print_exc())
|
display.vvv(traceback.format_exc())
|
||||||
raise AnsibleError("module %s missing documentation (or could not parse documentation): %s\n" % (module, str(e)))
|
raise AnsibleError("module %s missing documentation (or could not parse documentation): %s\n" % (module, str(e)))
|
||||||
|
|
||||||
if text:
|
if text:
|
||||||
|
|
|
@ -97,10 +97,10 @@ def get_docstring(filename, verbose=False):
|
||||||
fragment_yaml = getattr(fragment_class, fragment_var, '{}')
|
fragment_yaml = getattr(fragment_class, fragment_var, '{}')
|
||||||
fragment = AnsibleLoader(fragment_yaml, file_name=filename).get_single_data()
|
fragment = AnsibleLoader(fragment_yaml, file_name=filename).get_single_data()
|
||||||
|
|
||||||
if fragment.has_key('notes'):
|
if 'notes' in fragment:
|
||||||
notes = fragment.pop('notes')
|
notes = fragment.pop('notes')
|
||||||
if notes:
|
if notes:
|
||||||
if not doc.has_key('notes'):
|
if 'notes' not in doc:
|
||||||
doc['notes'] = []
|
doc['notes'] = []
|
||||||
doc['notes'].extend(notes)
|
doc['notes'].extend(notes)
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ def get_docstring(filename, verbose=False):
|
||||||
raise Exception("missing options in fragment, possibly misformatted?")
|
raise Exception("missing options in fragment, possibly misformatted?")
|
||||||
|
|
||||||
for key, value in fragment.items():
|
for key, value in fragment.items():
|
||||||
if not doc.has_key(key):
|
if key not in doc:
|
||||||
doc[key] = value
|
doc[key] = value
|
||||||
else:
|
else:
|
||||||
if isinstance(doc[key], MutableMapping):
|
if isinstance(doc[key], MutableMapping):
|
||||||
|
|
Loading…
Reference in a new issue