def build_doc(doc, opts):
 doclist = doc.split(u'\n')
 newdoc = []
 flags_doc = []
 for line in doclist:
  linelist = line.split()
  if (not linelist):
   continue
  if (u',' in linelist[0]):
   flag = linelist[0].split(u',')[0]
  else:
   flag = linelist[0]
  attr = opts.get(flag)
  if (attr is not None):
   linelist[0] = (u'%s :\n    ' % str(attr))
   newline = u' '.join(linelist)
   newdoc.append(newline)
  elif line[0].isspace():
   flags_doc.append(line)
 return format_params(newdoc, flags_doc)

def build_doc ( doc , opts ) : doclist = doc . split ( u'\n' ) newdoc = [ ] flags_doc = [ ] for line in doclist : linelist = line . split ( ) if ( not linelist ) : continue if ( u',' in linelist [ 0 ] ) : flag = linelist [ 0 ] . split ( u',' ) [ 0 ] else : flag = linelist [ 0 ] attr = opts . get ( flag ) if ( attr is not None ) : linelist [ 0 ] = ( u'%s :\n    ' % str ( attr ) ) newline = u' ' . join ( linelist ) newdoc . append ( newline ) elif line [ 0 ] . isspace ( ) : flags_doc . append ( line ) return format_params ( newdoc , flags_doc )
build docstring from doc and options parameters rep_doc : string documentation string opts : dict dictionary of option attributes and keys .