Add support for additional EXAMPLES string in Ansible modules

return DOC and EXAMPLES as a list
add moduledev explanation
more
This commit is contained in:
Jan-Piet Mens 2013-02-18 15:31:38 +01:00
parent 093935ede1
commit 396a07bcc7
7 changed files with 50 additions and 7 deletions

View file

@ -30,11 +30,14 @@ BLACKLIST_MODULES = [
def get_docstring(filename, verbose=False):
"""
Search for assignment of the DOCUMENTATION variable in the given file.
Parse that from YAML and return the YAML doc or None.
Search for assignment of the DOCUMENTATION and EXAMPLES variables
in the given file.
Parse DOCUMENTATION from YAML and return the YAML doc or None
together with EXAMPLES, as plain text.
"""
doc = None
plainexamples = None
try:
# Thank you, Habbie, for this bit of code :-)
@ -43,8 +46,11 @@ def get_docstring(filename, verbose=False):
if isinstance(child, ast.Assign):
if 'DOCUMENTATION' in (t.id for t in child.targets):
doc = yaml.load(child.value.s)
if 'EXAMPLES' in (t.id for t in child.targets):
plainexamples = child.value.s[1:] # Skip first empty line
except:
if verbose == True:
traceback.print_exc()
print "unable to parse %s" % filename
return doc
return doc, plainexamples