Merge pull request #2120 from jpmens/doc_ex1

Add support for additional EXAMPLES string in Ansible modules
This commit is contained in:
Michael DeHaan 2013-02-23 08:58:34 -08:00
commit e51707711c
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