def format_docstring(owner_name, docstring, formatters):
 format_params = {}
 for (target, doc_for_target) in iteritems(formatters):
  regex = re.compile(((('^(\\s*)' + '({') + target) + '})$'), re.MULTILINE)
  matches = regex.findall(docstring)
  if (not matches):
   raise ValueError("Couldn't find template for parameter {!r} in docstring for {}.\nParameter name must be alone on a line surrounded by braces.".format(target, owner_name))
  elif (len(matches) > 1):
   raise ValueError("Couldn't found multiple templates for parameter {!r}in docstring for {}.\nParameter should only appear once.".format(target, owner_name))
  (leading_whitespace, _) = matches[0]
  format_params[target] = pad_lines_after_first(leading_whitespace, doc_for_target)
 return docstring.format(**format_params)

def format_docstring ( owner_name , docstring , formatters ) : format_params = { } for ( target , doc_for_target ) in iteritems ( formatters ) : regex = re . compile ( ( ( ( '^(\\s*)' + '({' ) + target ) + '})$' ) , re . MULTILINE ) matches = regex . findall ( docstring ) if ( not matches ) : raise ValueError ( "Couldn't find template for parameter {!r} in docstring for {}.\nParameter name must be alone on a line surrounded by braces." . format ( target , owner_name ) ) elif ( len ( matches ) > 1 ) : raise ValueError ( "Couldn't found multiple templates for parameter {!r}in docstring for {}.\nParameter should only appear once." . format ( target , owner_name ) ) ( leading_whitespace , _ ) = matches [ 0 ] format_params [ target ] = pad_lines_after_first ( leading_whitespace , doc_for_target ) return docstring . format ( ** format_params )
template formatters into docstring .