1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

optimized module docs

This commit is contained in:
Brian Coca 2015-07-27 20:52:07 -04:00
parent 65c649aa3e
commit 164092a835

View file

@ -52,7 +52,13 @@ def get_docstring(filename, verbose=False):
M = ast.parse(''.join(open(filename)))
for child in M.body:
if isinstance(child, ast.Assign):
if 'DOCUMENTATION' in (t.id for t in child.targets):
for t in child.targets:
try:
theid = t.id
except AttributeError as e:
continue #TODO: should log these to figure out why this happens
if 'DOCUMENTATION' in theid:
doc = yaml.safe_load(child.value.s)
fragments = doc.get('extends_documentation_fragment', [])
@ -98,10 +104,10 @@ def get_docstring(filename, verbose=False):
else:
raise Exception("Attempt to extend a documentation fragement of unknown type")
if 'EXAMPLES' in (t.id for t in child.targets):
elif 'EXAMPLES' in theid:
plainexamples = child.value.s[1:] # Skip first empty line
if 'RETURN' in (t.id for t in child.targets):
elif 'RETURN' in theid:
returndocs = child.value.s[1:]
except:
traceback.print_exc() # temp