@ -24,18 +24,6 @@ def read_docstring(filename, verbose=True, ignore_errors=True):
Parse DOCUMENTATION from YAML and return the YAML doc or None together with EXAMPLES , as plain text .
"""
# FIXME: Should refactor this so that we have a docstring parsing
# function and a separate variable parsing function
# Can have a function one higher that invokes whichever is needed
#
# Should look roughly like this:
# get_plugin_doc(filename, verbose=False)
# documentation = extract_docstring(plugin_ast, identifier, verbose=False)
# if not documentation and not (filter or test):
# documentation = extract_variables(plugin_ast)
# documentation['metadata'] = extract_metadata(plugin_ast)
# return documentation
data = {
' doc ' : None ,
' plainexamples ' : None ,
@ -52,18 +40,7 @@ def read_docstring(filename, verbose=True, ignore_errors=True):
try :
b_module_data = open ( filename , ' rb ' ) . read ( )
M = ast . parse ( b_module_data )
try :
display . debug ( ' Attempt first docstring is yaml docs ' )
docstring = yaml . load ( M . body [ 0 ] . value . s )
for string in string_to_vars . keys ( ) :
if string in docstring :
data [ string_to_vars [ string ] ] = docstring [ string ]
display . debug ( ' assigned : %s ' % string_to_vars [ string ] )
except Exception as e :
display . debug ( ' failed docstring parsing: %s ' % str ( e ) )
if ' docs ' not in data or not data [ ' docs ' ] :
display . debug ( ' Fallback to vars parsing ' )
for child in M . body :
if isinstance ( child , ast . Assign ) :
for t in child . targets :